[PATCH] D99861: [Clang] Record tokens in attribute arguments for user-defined C++/C2x attributes
Josh Junon via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 4 09:48:56 PDT 2021
Qix- created this revision.
Qix- added a reviewer: aaron.ballman.
Qix- added a project: clang.
Herald added a subscriber: mgorny.
Qix- requested review of this revision.
Herald added a subscriber: cfe-commits.
Currently, user-defined attributes (e.g. those registered via Clang plugins) don't hold much information or allow for much to be done with them, as their argument tokens are discarded entirely in almost all cases.
However, since they are quite flexible with their syntax (pretty much anything can go in there), it would be massively helpful if plugins could be handed the pre-processed and parsed tokens as a listed to be consumed by third-party plugins and the like.
This diff creates a trailing data list for `ParsedAttr` objects and places the "recorded" tokens there from the lexer. I would have piggy-backed off of the normal backtrack system but unfortunately it doesn't call the handler for tokens being replayed from the backtrack cache, which in many cases we *do* care about. So I had to create a second recording callback.
The new plugin directory shows how this would be used from a plugin.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D99861
Files:
clang/examples/CMakeLists.txt
clang/examples/PrintAttributeTokens/CMakeLists.txt
clang/examples/PrintAttributeTokens/PrintAttributeTokens.cpp
clang/examples/PrintAttributeTokens/PrintAttributeTokens.exports
clang/examples/PrintAttributeTokens/README.txt
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Sema/ParsedAttr.h
clang/lib/Lex/Preprocessor.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Sema/ParsedAttr.cpp
clang/test/Frontend/plugin-print-attr-tokens.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99861.335151.patch
Type: text/x-patch
Size: 22980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210404/c1e449d9/attachment-0001.bin>
More information about the cfe-commits
mailing list