[cfe-dev] How to determine if a raw_id token is a macro name?

Richard via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 6 16:39:10 PST 2022


Hi Team,

Preprocessor::isMacroDefined seems to be what I want, but how can I
access the active preprocesor from inside a clang-tidy check?

Currently I have a check that walks over a declaration string with the
Lexer.  A bug was filed that this check had a negative interaction
with macros (no surprise).  I've got a hacked up solution that passes
my test cases, but it would be really nice to know if a raw_id token I
just encountered while lexing the declaration is the name of a macro.

For context, see:
Lexing state machine
<https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp#L118>
bug
<https://github.com/llvm/llvm-project/issues/43791>

Thanks,

-- Richard
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
             The Terminals Wiki <http://terminals-wiki.org>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>


More information about the cfe-dev mailing list