<div dir="ltr">Thanks to the pointer, but as far as I can tell, that is not actually ever called when running the Clang C API (nor is handleDeclOccurence from what I can tell).<div><br></div><div>When doing clang -Xclang -ast-dump, I get basically what I want (the macro is fully expanded), so there must be some way of coercing libclang to give me that same information.</div><div><br></div><div>Cheers,</div><div>Joe</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 28, 2018 at 11:45 PM, Fāng-ruì Sòng <span dir="ltr"><<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Is this relevant?<br>
clang::index::<wbr>IndexDataConsumer::<wbr>HandleMacroOccurence is not<br>
implemented (overriden) in clang/tools/libclang/<wbr>CXIndexDataConsumer.h<br>
<br>
I guess CXTranslationUnit_<wbr>DetailedPreprocessingRecord only makes macro<br>
expansions children of the translation unit AST, there is still no way<br>
to get their position in the macro replacement-list. I would also like<br>
to see the feature implemented in libclang.<br>
<div><div class="h5"><br>
On Wed, Feb 28, 2018 at 5:35 PM, Joe Turner via cfe-dev<br>
<<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
> I'm using libClang to parse the AST for Objective-C/C++ code, and have run<br>
> into an issue with macro-like functions. Given something like this:<br>
><br>
> #define FOO(a, b) a + b<br>
><br>
> int main() {<br>
>   int a = 0;<br>
>   int b = 1;<br>
>   int c = FOO(a, b);<br>
>   return c;<br>
> }<br>
><br>
> I would like to be able to see references to a and b in the AST when I parse<br>
> the "int c = FOO(a, b);" line. However, all I see in the AST is the "int c =<br>
> " part (a Decl and a VarDecl).<br>
><br>
> I've done a bunch of searching, and people mention using<br>
> CXTranslationUnit_<wbr>DetailedPreprocessingRecord, which doesn't work for me.<br>
> This adds children to the translation unit that reference the macro itself,<br>
> but it doesn't give me access to the arguments passed into the function-like<br>
> macro.<br>
><br>
> Short of using the C++ API, is there any way to get this information from<br>
> libClang?<br>
><br>
> Thanks!<br>
> Joe<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
宋方睿<br>
</font></span></blockquote></div><br></div>