[cfe-dev] Best way to determine if preprocessor directives live in a source range?

Richard legalize at xmission.com
Wed May 27 09:31:31 PDT 2015


In article <CAOweq9+4kdBKeiKBg+SXzKs3SN-RNE7NQG7ysv4N4tsBCcWiCA at mail.gmail.com>,
    Alexander Kornienko <alexfh at google.com> writes:

> This problem is relevant to comments as well.
> 
> I'm not sure if there's an easy solution, but some hand-rolled options are
> available. One way is to re-lex the range and try to find preprocessor
> directives (and comments) by analyzing token sequences. Another approach
> would be to subscribe to PPCallbacks, gather all locations of #if/#else/...
> into a set and then look up any values in this set that fall between the
> bounds of your range.

Yeah, I think with PPCallbacks you could build a function that would
tell you something about preprocessor blocks based on source location.

For comments, I thought there was something about sprinkling comment
nodes into the AST?  Isn't this how the doxygen thing works?
-- 
"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