-
Notifications
You must be signed in to change notification settings - Fork 11.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DWARF] Does not generate nested enumerations. #45811
Comments
llvm-dwarf output - Clang0x00: DW_TAG_compile_unit 0x2a: DW_TAG_variable 0x3f: DW_TAG_structure_type 0x48: DW_TAG_member 0x54: DW_TAG_union_type llvm-dwarf output - GCC0x0b: DW_TAG_compile_unit 0x2d: DW_TAG_structure_type 0x39: DW_TAG_union_type 0x45: DW_TAG_enumeration_type 0x51: DW_TAG_enumerator 0x57: DW_TAG_enumerator 0x5f: DW_TAG_member |
|
This is the output from llvm-diva (Sony's tool under development). llvm-diva --print=scopes,symbols,types test.o --attribute=level,format DWARF Logical View: (Clang)Logical View: DWARF Logical View: (GCC)Logical View: CodeView Logical View: (Clang)Logical View: CodeView Logical View: (MSVC)Logical View: The logical views for the objects generated by GCC (DWARF), Clang (CodeView) and MSVC (CodeView) contains references to the enumerators 'BLUE' and 'RED'. |
|
A simpler example: struct Struct { Struct S; If you're interested in fixing this I'd suggest comparing/contrasting these two cases, and perhaps comparing/contrasting the CodeView case too (But I think the CV case works by emitting the nested enum because the outer struct is emitted - whereas I don't think we want to do that in DWARF (eg: "return Struct().BLUE;" should probably emit the enum even though the "Struct" type is not otherwise needed in the DWARF (& should probably be emitted as a declaration) & that probably doesn't produce struct or enum in CodeView - and having the global "Struct S;" should produce the Struct but no enum in DWARF (I'd bet this is GCC's behavior) if the enum is unreferenced (unlike in CodeView, where it's emitted regardless)) |
|
For your simpler example, with both variations:
The CodeView generated by MSVC and Clang, looks the same: 0x1009 | LF_STRUCTURE The nested enum is emitted as part of the enclosing scope 'Struct'. |
|
Changing the enum to be enum class: struct Struct { int test() { Only Clang (DWARF) emits the nested enum: DWARF Logical View: (Clang)[000] {File} 'test.o' -> elf64-x86-64 DWARF Logical View: (GCC)Logical View: CodeView Logical View: (Clang)Logical View: CodeView Logical View: (MSVC)[000] {File} 'test.o' -> COFF-i386 |
Yes, that'd be my expectation - I believe CodeView/MSVC/Clang-cl needs the full definition of the nested type (how it deals with a forward declaration of a nested type (eg: pimpl idiom), I don't know - be nice if we could use that representation for all nested enums on CV, because that's my philosophy for the DWARF output "imagine the nested types were always defined out of line") Confirming what I was saying here: "comparing/contrasting the CodeView case too (But I think the CV case works by emitting the nested enum because the outer struct is emitted - whereas I don't think we want to do that in DWARF"(In reply to Carlos Alberto Enciso from comment #5)
Sure - I'd probably classify that as a bug/missed opportunity for other compilers. |
Extended Description
For the given test:
//----------------------------------------------------------
struct Struct {
union Union {
enum NestedEnum { RED, BLUE };
};
Union U;
};
Struct S;
int test() {
return S.U.BLUE;
}
//----------------------------------------------------------
The DWARF generated does not include any references to the enumerators 'RED' and 'BLUE'.
DWARF generated by GCC, CodeView generated by Clang and MSVC, it does include such references.
The text was updated successfully, but these errors were encountered: