[cfe-dev] using AstMatchers to identify user defined pragmas

Richard legalize at xmission.com
Wed Jan 21 12:52:43 PST 2015


In article <CALLs9tteox05gFLZDyNJ6OyiN6kF4J3OjTC2jVxKU_UAcGrVvg at mail.gmail.com>,
    Deepak Rajendrakumaran <deepak3 at vt.edu> writes:

> I am trying to use AstMatchers to identify a custom user defined pragma(say
> "#pragma myPragma") in my source code. But when I dumped the AST for my
> source code, I do not see the pragma as part of the AST. Is it possible to
> use AstMatcher to figure out the user defined Pragmas using astMatchers??

#pragma is a directive to the preprocessor and those aren't recorded
in the AST and therefore not seen by matchers.  However, you can hook
into preprocessing through the PPCallbacks class:
<http://clang.llvm.org/doxygen/classclang_1_1PPCallbacks.html>
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>



More information about the cfe-dev mailing list