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

Gabor Kozar kozargabor at fastmail.fm
Thu May 28 02:32:47 PDT 2015


I think getting the PreprocessingRecord
(http://clang.llvm.org/doxygen/classclang_1_1PreprocessingRecord.html)
from the Preprocessor would also work; a PreprocessedEntity seems to
contain source information that you can use:
http://clang.llvm.org/doxygen/classclang_1_1PreprocessedEntity.html

---
Best regards,

Gábor 'ShdNx' Kozár http://gaborkozar.me


On Wed, May 27, 2015, at 18:31, Richard wrote:
>
> 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>
> _________________________________________________
> cfe-dev mailing list cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150528/a0c99d37/attachment.html>


More information about the cfe-dev mailing list