; REQUIRES: x86-registered-target ; Test case 4 - Missing nested enumerations. ; pr-46466.cpp ; 1 struct Struct { ; 2 union Union { ; 3 enum NestedEnum { RED, BLUE }; ; 4 }; ; 5 Union U; ; 6 }; ; 7 ; 8 Struct S; ; 9 int test() { ; 10 return S.U.BLUE; ; 11 } ; The above test is used to illustrate a scope issue found in the Clang ; compiler. ; PR46466: https://bugs.llvm.org/show_bug.cgi?id=46466 ; PR45811: https://github.com/llvm/llvm-project/issues/45811 ; In the following logical views, we can see that the CodeView debug ; information generated by the Clang compiler does not include any ; references to the enumerators 'RED' and 'BLUE'. The CodeView generated ; by GCC and MSVC, does include such references. ; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \ ; RUN: --output-sort=name \ ; RUN: --print=symbols,types \ ; RUN: %p/Inputs/pr-46466-codeview-clang.o \ ; RUN: %p/Inputs/pr-46466-codeview-msvc.o 2>&1 | \ ; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s ; ONE: Logical View: ; ONE-NEXT: [000] {File} 'pr-46466-codeview-clang.o' -> COFF-x86-64 ; ONE-EMPTY: ; ONE-NEXT: [001] {CompileUnit} 'pr-46466.cpp' ; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}' ; ONE-NEXT: [002] {Variable} extern 'S' -> 'Struct' ; ONE-NEXT: [002] 1 {Struct} 'Struct' ; ONE-NEXT: [003] {Member} public 'U' -> 'Union' ; ONE-NEXT: [003] 2 {Union} 'Union' ; ONE-NEXT: [004] 3 {Enumeration} 'NestedEnum' -> 'int' ; ONE-NEXT: [005] {Enumerator} 'BLUE' = '0x1' ; ONE-NEXT: [005] {Enumerator} 'RED' = '0x0' ; ONE-EMPTY: ; ONE-NEXT: Logical View: ; ONE-NEXT: [000] {File} 'pr-46466-codeview-msvc.o' -> COFF-x86-64 ; ONE-EMPTY: ; ONE-NEXT: [001] {CompileUnit} 'pr-46466.cpp' ; ONE-NEXT: [002] {Producer} 'Microsoft (R) Optimizing Compiler' ; ONE-NEXT: [002] {Variable} extern 'S' -> 'Struct' ; ONE-NEXT: [002] 1 {Struct} 'Struct' ; ONE-NEXT: [003] {Member} public 'U' -> 'Union' ; ONE-NEXT: [003] 2 {Union} 'Union' ; ONE-NEXT: [004] 3 {Enumeration} 'NestedEnum' -> 'int' ; ONE-NEXT: [005] {Enumerator} 'BLUE' = '0x1' ; ONE-NEXT: [005] {Enumerator} 'RED' = '0x0' ; Using the selection facilities, we can produce a logical view ; showing just the logical types that are 'Enumerator' and its ; parents. The logical view is sorted by the types name. ; RUN: llvm-debuginfo-analyzer --attribute=level,format \ ; RUN: --output-sort=name \ ; RUN: --select-types=Enumerator \ ; RUN: --report=parents \ ; RUN: --print=types \ ; RUN: %p/Inputs/pr-46466-*.o 2>&1 | \ ; RUN: FileCheck --strict-whitespace -check-prefix=TWO %s ; TWO: Logical View: ; TWO-NEXT: [000] {File} 'pr-46466-codeview-clang.o' -> COFF-x86-64 ; TWO-EMPTY: ; TWO-NEXT: [001] {CompileUnit} 'pr-46466.cpp' ; TWO-NEXT: [002] 1 {Struct} 'Struct' ; TWO-NEXT: [003] 2 {Union} 'Union' ; TWO-NEXT: [004] 3 {Enumeration} 'NestedEnum' -> 'int' ; TWO-NEXT: [005] {Enumerator} 'BLUE' = '0x1' ; TWO-NEXT: [005] {Enumerator} 'RED' = '0x0' ; TWO-EMPTY: ; TWO-NEXT: Logical View: ; TWO-NEXT: [000] {File} 'pr-46466-codeview-msvc.o' -> COFF-x86-64 ; TWO-EMPTY: ; TWO-NEXT: [001] {CompileUnit} 'pr-46466.cpp' ; TWO-NEXT: [002] 1 {Struct} 'Struct' ; TWO-NEXT: [003] 2 {Union} 'Union' ; TWO-NEXT: [004] 3 {Enumeration} 'NestedEnum' -> 'int' ; TWO-NEXT: [005] {Enumerator} 'BLUE' = '0x1' ; TWO-NEXT: [005] {Enumerator} 'RED' = '0x0' ; Using the selection facilities, we can produce a simple tabular output ; including a summary for the logical types that are 'Enumerator'. The ; logical view is sorted by the types name. ; RUN: llvm-debuginfo-analyzer --attribute=level,format \ ; RUN: --output-sort=name \ ; RUN: --select-types=Enumerator \ ; RUN: --print=types,summary \ ; RUN: %p/Inputs/pr-46466-*.o 2>&1 | \ ; RUN: FileCheck --strict-whitespace -check-prefix=THR %s ; THR: Logical View: ; THR-NEXT: [000] {File} 'pr-46466-codeview-clang.o' -> COFF-x86-64 ; THR-EMPTY: ; THR-NEXT: [001] {CompileUnit} 'pr-46466.cpp' ; THR-NEXT: [005] {Enumerator} 'BLUE' = '0x1' ; THR-NEXT: [005] {Enumerator} 'RED' = '0x0' ; THR-EMPTY: ; THR-NEXT: ----------------------------- ; THR-NEXT: Element Total Printed ; THR-NEXT: ----------------------------- ; THR-NEXT: Scopes 5 0 ; THR-NEXT: Symbols 2 0 ; THR-NEXT: Types 6 2 ; THR-NEXT: Lines 0 0 ; THR-NEXT: ----------------------------- ; THR-NEXT: Total 13 2 ; THR-EMPTY: ; THR-NEXT: Logical View: ; THR-NEXT: [000] {File} 'pr-46466-codeview-msvc.o' -> COFF-x86-64 ; THR-EMPTY: ; THR-NEXT: [001] {CompileUnit} 'pr-46466.cpp' ; THR-NEXT: [005] {Enumerator} 'BLUE' = '0x1' ; THR-NEXT: [005] {Enumerator} 'RED' = '0x0' ; THR-EMPTY: ; THR-NEXT: ----------------------------- ; THR-NEXT: Element Total Printed ; THR-NEXT: ----------------------------- ; THR-NEXT: Scopes 5 0 ; THR-NEXT: Symbols 2 0 ; THR-NEXT: Types 7 2 ; THR-NEXT: Lines 0 0 ; THR-NEXT: ----------------------------- ; THR-NEXT: Total 14 2