1*e7950fceSCarlos Alberto Enciso; REQUIRES: x86-registered-target 2*e7950fceSCarlos Alberto Enciso 3*e7950fceSCarlos Alberto Enciso; Test case 4 - Missing nested enumerations. 4*e7950fceSCarlos Alberto Enciso 5*e7950fceSCarlos Alberto Enciso; pr-46466.cpp 6*e7950fceSCarlos Alberto Enciso; 1 struct Struct { 7*e7950fceSCarlos Alberto Enciso; 2 union Union { 8*e7950fceSCarlos Alberto Enciso; 3 enum NestedEnum { RED, BLUE }; 9*e7950fceSCarlos Alberto Enciso; 4 }; 10*e7950fceSCarlos Alberto Enciso; 5 Union U; 11*e7950fceSCarlos Alberto Enciso; 6 }; 12*e7950fceSCarlos Alberto Enciso; 7 13*e7950fceSCarlos Alberto Enciso; 8 Struct S; 14*e7950fceSCarlos Alberto Enciso; 9 int test() { 15*e7950fceSCarlos Alberto Enciso; 10 return S.U.BLUE; 16*e7950fceSCarlos Alberto Enciso; 11 } 17*e7950fceSCarlos Alberto Enciso 18*e7950fceSCarlos Alberto Enciso; The above test is used to illustrate a scope issue found in the Clang 19*e7950fceSCarlos Alberto Enciso; compiler. 20*e7950fceSCarlos Alberto Enciso; PR46466: https://bugs.llvm.org/show_bug.cgi?id=46466 21*e7950fceSCarlos Alberto Enciso; PR45811: https://github.com/llvm/llvm-project/issues/45811 22*e7950fceSCarlos Alberto Enciso 23*e7950fceSCarlos Alberto Enciso; In the following logical views, we can see that the CodeView debug 24*e7950fceSCarlos Alberto Enciso; information generated by the Clang compiler does not include any 25*e7950fceSCarlos Alberto Enciso; references to the enumerators 'RED' and 'BLUE'. The CodeView generated 26*e7950fceSCarlos Alberto Enciso; by GCC and MSVC, does include such references. 27*e7950fceSCarlos Alberto Enciso 28*e7950fceSCarlos Alberto Enciso; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \ 29*e7950fceSCarlos Alberto Enciso; RUN: --output-sort=name \ 30*e7950fceSCarlos Alberto Enciso; RUN: --print=symbols,types \ 31*e7950fceSCarlos Alberto Enciso; RUN: %p/Inputs/pr-46466-codeview-clang.o \ 32*e7950fceSCarlos Alberto Enciso; RUN: %p/Inputs/pr-46466-codeview-msvc.o 2>&1 | \ 33*e7950fceSCarlos Alberto Enciso; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s 34*e7950fceSCarlos Alberto Enciso 35*e7950fceSCarlos Alberto Enciso; ONE: Logical View: 36*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [000] {File} 'pr-46466-codeview-clang.o' -> COFF-x86-64 37*e7950fceSCarlos Alberto Enciso; ONE-EMPTY: 38*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [001] {CompileUnit} 'pr-46466.cpp' 39*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}' 40*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [002] {Variable} extern 'S' -> 'Struct' 41*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [002] 1 {Struct} 'Struct' 42*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [003] {Member} public 'U' -> 'Union' 43*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [003] 2 {Union} 'Union' 44*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [004] 3 {Enumeration} 'NestedEnum' -> 'int' 45*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [005] {Enumerator} 'BLUE' = '0x1' 46*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [005] {Enumerator} 'RED' = '0x0' 47*e7950fceSCarlos Alberto Enciso; ONE-EMPTY: 48*e7950fceSCarlos Alberto Enciso; ONE-NEXT: Logical View: 49*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [000] {File} 'pr-46466-codeview-msvc.o' -> COFF-x86-64 50*e7950fceSCarlos Alberto Enciso; ONE-EMPTY: 51*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [001] {CompileUnit} 'pr-46466.cpp' 52*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [002] {Producer} 'Microsoft (R) Optimizing Compiler' 53*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [002] {Variable} extern 'S' -> 'Struct' 54*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [002] 1 {Struct} 'Struct' 55*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [003] {Member} public 'U' -> 'Union' 56*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [003] 2 {Union} 'Union' 57*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [004] 3 {Enumeration} 'NestedEnum' -> 'int' 58*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [005] {Enumerator} 'BLUE' = '0x1' 59*e7950fceSCarlos Alberto Enciso; ONE-NEXT: [005] {Enumerator} 'RED' = '0x0' 60*e7950fceSCarlos Alberto Enciso 61*e7950fceSCarlos Alberto Enciso; Using the selection facilities, we can produce a logical view 62*e7950fceSCarlos Alberto Enciso; showing just the logical types that are 'Enumerator' and its 63*e7950fceSCarlos Alberto Enciso; parents. The logical view is sorted by the types name. 64*e7950fceSCarlos Alberto Enciso 65*e7950fceSCarlos Alberto Enciso; RUN: llvm-debuginfo-analyzer --attribute=level,format \ 66*e7950fceSCarlos Alberto Enciso; RUN: --output-sort=name \ 67*e7950fceSCarlos Alberto Enciso; RUN: --select-types=Enumerator \ 68*e7950fceSCarlos Alberto Enciso; RUN: --report=parents \ 69*e7950fceSCarlos Alberto Enciso; RUN: --print=types \ 70*e7950fceSCarlos Alberto Enciso; RUN: %p/Inputs/pr-46466-*.o 2>&1 | \ 71*e7950fceSCarlos Alberto Enciso; RUN: FileCheck --strict-whitespace -check-prefix=TWO %s 72*e7950fceSCarlos Alberto Enciso 73*e7950fceSCarlos Alberto Enciso; TWO: Logical View: 74*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [000] {File} 'pr-46466-codeview-clang.o' -> COFF-x86-64 75*e7950fceSCarlos Alberto Enciso; TWO-EMPTY: 76*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [001] {CompileUnit} 'pr-46466.cpp' 77*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [002] 1 {Struct} 'Struct' 78*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [003] 2 {Union} 'Union' 79*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [004] 3 {Enumeration} 'NestedEnum' -> 'int' 80*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [005] {Enumerator} 'BLUE' = '0x1' 81*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [005] {Enumerator} 'RED' = '0x0' 82*e7950fceSCarlos Alberto Enciso; TWO-EMPTY: 83*e7950fceSCarlos Alberto Enciso; TWO-NEXT: Logical View: 84*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [000] {File} 'pr-46466-codeview-msvc.o' -> COFF-x86-64 85*e7950fceSCarlos Alberto Enciso; TWO-EMPTY: 86*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [001] {CompileUnit} 'pr-46466.cpp' 87*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [002] 1 {Struct} 'Struct' 88*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [003] 2 {Union} 'Union' 89*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [004] 3 {Enumeration} 'NestedEnum' -> 'int' 90*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [005] {Enumerator} 'BLUE' = '0x1' 91*e7950fceSCarlos Alberto Enciso; TWO-NEXT: [005] {Enumerator} 'RED' = '0x0' 92*e7950fceSCarlos Alberto Enciso 93*e7950fceSCarlos Alberto Enciso; Using the selection facilities, we can produce a simple tabular output 94*e7950fceSCarlos Alberto Enciso; including a summary for the logical types that are 'Enumerator'. The 95*e7950fceSCarlos Alberto Enciso; logical view is sorted by the types name. 96*e7950fceSCarlos Alberto Enciso 97*e7950fceSCarlos Alberto Enciso; RUN: llvm-debuginfo-analyzer --attribute=level,format \ 98*e7950fceSCarlos Alberto Enciso; RUN: --output-sort=name \ 99*e7950fceSCarlos Alberto Enciso; RUN: --select-types=Enumerator \ 100*e7950fceSCarlos Alberto Enciso; RUN: --print=types,summary \ 101*e7950fceSCarlos Alberto Enciso; RUN: %p/Inputs/pr-46466-*.o 2>&1 | \ 102*e7950fceSCarlos Alberto Enciso; RUN: FileCheck --strict-whitespace -check-prefix=THR %s 103*e7950fceSCarlos Alberto Enciso 104*e7950fceSCarlos Alberto Enciso; THR: Logical View: 105*e7950fceSCarlos Alberto Enciso; THR-NEXT: [000] {File} 'pr-46466-codeview-clang.o' -> COFF-x86-64 106*e7950fceSCarlos Alberto Enciso; THR-EMPTY: 107*e7950fceSCarlos Alberto Enciso; THR-NEXT: [001] {CompileUnit} 'pr-46466.cpp' 108*e7950fceSCarlos Alberto Enciso; THR-NEXT: [005] {Enumerator} 'BLUE' = '0x1' 109*e7950fceSCarlos Alberto Enciso; THR-NEXT: [005] {Enumerator} 'RED' = '0x0' 110*e7950fceSCarlos Alberto Enciso; THR-EMPTY: 111*e7950fceSCarlos Alberto Enciso; THR-NEXT: ----------------------------- 112*e7950fceSCarlos Alberto Enciso; THR-NEXT: Element Total Printed 113*e7950fceSCarlos Alberto Enciso; THR-NEXT: ----------------------------- 114*e7950fceSCarlos Alberto Enciso; THR-NEXT: Scopes 5 0 115*e7950fceSCarlos Alberto Enciso; THR-NEXT: Symbols 2 0 116*e7950fceSCarlos Alberto Enciso; THR-NEXT: Types 6 2 117*e7950fceSCarlos Alberto Enciso; THR-NEXT: Lines 0 0 118*e7950fceSCarlos Alberto Enciso; THR-NEXT: ----------------------------- 119*e7950fceSCarlos Alberto Enciso; THR-NEXT: Total 13 2 120*e7950fceSCarlos Alberto Enciso; THR-EMPTY: 121*e7950fceSCarlos Alberto Enciso; THR-NEXT: Logical View: 122*e7950fceSCarlos Alberto Enciso; THR-NEXT: [000] {File} 'pr-46466-codeview-msvc.o' -> COFF-x86-64 123*e7950fceSCarlos Alberto Enciso; THR-EMPTY: 124*e7950fceSCarlos Alberto Enciso; THR-NEXT: [001] {CompileUnit} 'pr-46466.cpp' 125*e7950fceSCarlos Alberto Enciso; THR-NEXT: [005] {Enumerator} 'BLUE' = '0x1' 126*e7950fceSCarlos Alberto Enciso; THR-NEXT: [005] {Enumerator} 'RED' = '0x0' 127*e7950fceSCarlos Alberto Enciso; THR-EMPTY: 128*e7950fceSCarlos Alberto Enciso; THR-NEXT: ----------------------------- 129*e7950fceSCarlos Alberto Enciso; THR-NEXT: Element Total Printed 130*e7950fceSCarlos Alberto Enciso; THR-NEXT: ----------------------------- 131*e7950fceSCarlos Alberto Enciso; THR-NEXT: Scopes 5 0 132*e7950fceSCarlos Alberto Enciso; THR-NEXT: Symbols 2 0 133*e7950fceSCarlos Alberto Enciso; THR-NEXT: Types 7 2 134*e7950fceSCarlos Alberto Enciso; THR-NEXT: Lines 0 0 135*e7950fceSCarlos Alberto Enciso; THR-NEXT: ----------------------------- 136*e7950fceSCarlos Alberto Enciso; THR-NEXT: Total 14 2 137