[cfe-users] No macros in DI metadata

2021-07-13 Thread Bella V via cfe-users
Hello All,

I'm trying to build a list of macros in a compilation unit using CU->
getMacros

().
I do not see the macros field in DICompileUnit output.
*https://godbolt.org/z/b8cM1Yf7v *

Please let me know what I'm missing.

Many Thanks.
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] No macros in DI metadata

2021-07-13 Thread David Blaikie via cfe-users
Add -fdebug-macro

On Tue, Jul 13, 2021 at 4:05 PM Bella V via cfe-users
 wrote:
>
> Hello All,
>
> I'm trying to build a list of macros in a compilation unit using 
> CU->getMacros().
> I do not see the macros field in DICompileUnit output.
> https://godbolt.org/z/b8cM1Yf7v
>
> Please let me know what I'm missing.
>
> Many Thanks.
>
> ___
> cfe-users mailing list
> cfe-users@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] No macros in DI metadata

2021-07-13 Thread Bella V via cfe-users
Thanks David for the helpful information. Is there a way to filter the
predefined macros such as __clang__, __GNUC__, etc.

I could not get the macros defined in my C code with the below code:
DIMacroNodeArray Macros = DICompUnit->getMacros();
for (auto *MN : Macros) {
if (auto *M = dyn_cast(MN)) {
outs()<< M->getName();
}
}


On Tue, Jul 13, 2021 at 4:13 PM David Blaikie  wrote:

> Add -fdebug-macro
>
> On Tue, Jul 13, 2021 at 4:05 PM Bella V via cfe-users
>  wrote:
> >
> > Hello All,
> >
> > I'm trying to build a list of macros in a compilation unit using
> CU->getMacros().
> > I do not see the macros field in DICompileUnit output.
> > https://godbolt.org/z/b8cM1Yf7v
> >
> > Please let me know what I'm missing.
> >
> > Many Thanks.
> >
> > ___
> > cfe-users mailing list
> > cfe-users@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] No macros in DI metadata

2021-07-13 Thread David Blaikie via cfe-users
You could check where the macro is defined, I guess?
If it's in a DIMacroFile i guess it's not a compiler builtin. It might
still be from a system header, etc, if that matters to you - so then
you'd have to filter by the DIMacroFile's 'file' attribute.

On Tue, Jul 13, 2021 at 7:00 PM Bella V  wrote:
>
> Thanks David for the helpful information. Is there a way to filter the 
> predefined macros such as __clang__, __GNUC__, etc.
>
> I could not get the macros defined in my C code with the below code:
> DIMacroNodeArray Macros = DICompUnit->getMacros();
> for (auto *MN : Macros) {
> if (auto *M = dyn_cast(MN)) {
> outs()<< M->getName();
> }
> }
>
>
> On Tue, Jul 13, 2021 at 4:13 PM David Blaikie  wrote:
>>
>> Add -fdebug-macro
>>
>> On Tue, Jul 13, 2021 at 4:05 PM Bella V via cfe-users
>>  wrote:
>> >
>> > Hello All,
>> >
>> > I'm trying to build a list of macros in a compilation unit using 
>> > CU->getMacros().
>> > I do not see the macros field in DICompileUnit output.
>> > https://godbolt.org/z/b8cM1Yf7v
>> >
>> > Please let me know what I'm missing.
>> >
>> > Many Thanks.
>> >
>> > ___
>> > cfe-users mailing list
>> > cfe-users@lists.llvm.org
>> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users