<div dir="ltr">Thanks a lot! It works.<div><br></div><div>Also there is no IR code generated for macros. Is there a way to relate llvm::value's that refer to macros.</div><div><br></div><div>Many Thanks.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 13, 2021 at 7:06 PM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">You could check where the macro is defined, I guess?<br>
If it's in a DIMacroFile i guess it's not a compiler builtin. It might<br>
still be from a system header, etc, if that matters to you - so then<br>
you'd have to filter by the DIMacroFile's 'file' attribute.<br>
<br>
On Tue, Jul 13, 2021 at 7:00 PM Bella V <<a href="mailto:bellavistaghome@gmail.com" target="_blank">bellavistaghome@gmail.com</a>> wrote:<br>
><br>
> Thanks David for the helpful information. Is there a way to filter the predefined macros such as __clang__, __GNUC__, etc.<br>
><br>
> I could not get the macros defined in my C code with the below code:<br>
> DIMacroNodeArray Macros = DICompUnit->getMacros();<br>
> for (auto *MN : Macros) {<br>
> if (auto *M = dyn_cast<DIMacro>(MN)) {<br>
> outs()<< M->getName();<br>
> }<br>
> }<br>
><br>
><br>
> On Tue, Jul 13, 2021 at 4:13 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
>><br>
>> Add -fdebug-macro<br>
>><br>
>> On Tue, Jul 13, 2021 at 4:05 PM Bella V via cfe-users<br>
>> <<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a>> wrote:<br>
>> ><br>
>> > Hello All,<br>
>> ><br>
>> > I'm trying to build a list of macros in a compilation unit using CU->getMacros().<br>
>> > I do not see the macros field in DICompileUnit output.<br>
>> > <a href="https://godbolt.org/z/b8cM1Yf7v" rel="noreferrer" target="_blank">https://godbolt.org/z/b8cM1Yf7v</a><br>
>> ><br>
>> > Please let me know what I'm missing.<br>
>> ><br>
>> > Many Thanks.<br>
>> ><br>
>> > _______________________________________________<br>
>> > cfe-users mailing list<br>
>> > <a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><br>
>> > <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users</a><br>
</blockquote></div>