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