[pseudo] Share the underly payload when stripping comments for a token stream
authorHaojian Wu <hokein.wu@gmail.com>
Fri, 15 Jul 2022 13:12:46 +0000 (15:12 +0200)
committerHaojian Wu <hokein.wu@gmail.com>
Fri, 15 Jul 2022 13:20:48 +0000 (15:20 +0200)
commit76910d4a56c8dba000f198bba13e71cf0492c8cb
tree1b9411567dce82b09e8cc9112b7cd5e03b06be93
parentec5f18e38afa93f238456f56e5d8b9a1bd44ec12
[pseudo] Share the underly payload when stripping comments for a token stream

`stripComments(cook(...))` is a common pattern being written.
Without this patch, this has a use-after-free issue (cook returns a temporary
TokenStream object which has its own payload, but the payload is not
shared with the one returned by stripComments).

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D125311
clang-tools-extra/pseudo/include/clang-pseudo/Token.h
clang-tools-extra/pseudo/lib/Lex.cpp
clang-tools-extra/pseudo/lib/Token.cpp