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 DWARF debug
24; information generated by the Clang compiler does not include any
25; references to the enumerators 'RED' and 'BLUE'. The DWARF generated
26; by GCC, 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-dwarf-clang.o \
32; RUN:                         %p/Inputs/pr-46466-dwarf-gcc.o 2>&1 | \
33; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s
34
35; ONE:      Logical View:
36; ONE-NEXT: [000]           {File} 'pr-46466-dwarf-clang.o' -> elf64-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]     8         {Variable} extern 'S' -> 'Struct'
41; ONE-NEXT: [002]     1         {Struct} 'Struct'
42; ONE-NEXT: [003]     5           {Member} public 'U' -> 'Union'
43; ONE-EMPTY:
44; ONE-NEXT: Logical View:
45; ONE-NEXT: [000]           {File} 'pr-46466-dwarf-gcc.o' -> elf64-x86-64
46; ONE-EMPTY:
47; ONE-NEXT: [001]             {CompileUnit} 'pr-46466.cpp'
48; ONE-NEXT: [002]               {Producer} 'GNU C++14 10.3.0 {{.*}}'
49; ONE-NEXT: [002]     8         {Variable} extern 'S' -> 'Struct'
50; ONE-NEXT: [002]     1         {Struct} 'Struct'
51; ONE-NEXT: [003]     5           {Member} public 'U' -> 'Union'
52; ONE-NEXT: [003]     2           {Union} 'Union'
53; ONE-NEXT: [004]     3             {Enumeration} 'NestedEnum' -> 'unsigned int'
54; ONE-NEXT: [005]                     {Enumerator} 'BLUE' = '0x1'
55; ONE-NEXT: [005]                     {Enumerator} 'RED' = '0x0'
56
57; Using the selection facilities, we can produce a logical view
58; showing just the logical types that are 'Enumerator' and its
59; parents. The logical view is sorted by the types name.
60
61; RUN: llvm-debuginfo-analyzer --attribute=level,format \
62; RUN:                         --output-sort=name \
63; RUN:                         --select-types=Enumerator \
64; RUN:                         --report=parents \
65; RUN:                         --print=types \
66; RUN:                         %p/Inputs/pr-46466-*.o 2>&1 | \
67; RUN: FileCheck --strict-whitespace -check-prefix=TWO %s
68
69; TWO:      Logical View:
70; TWO-NEXT: [000]           {File} 'pr-46466-dwarf-clang.o' -> elf64-x86-64
71; TWO-EMPTY:
72; TWO-NEXT: [001]             {CompileUnit} 'pr-46466.cpp'
73; TWO-EMPTY:
74; TWO-NEXT: Logical View:
75; TWO-NEXT: [000]           {File} 'pr-46466-dwarf-gcc.o' -> elf64-x86-64
76; TWO-EMPTY:
77; TWO-NEXT: [001]             {CompileUnit} 'pr-46466.cpp'
78; TWO-NEXT: [002]     1         {Struct} 'Struct'
79; TWO-NEXT: [003]     2           {Union} 'Union'
80; TWO-NEXT: [004]     3             {Enumeration} 'NestedEnum' -> 'unsigned int'
81; TWO-NEXT: [005]                     {Enumerator} 'BLUE' = '0x1'
82; TWO-NEXT: [005]                     {Enumerator} 'RED' = '0x0'
83
84; Using the selection facilities, we can produce a simple tabular output
85; including a summary for the logical types that are 'Enumerator'. The
86; logical view is sorted by the types name.
87
88; RUN: llvm-debuginfo-analyzer --attribute=level,format \
89; RUN:                         --output-sort=name \
90; RUN:                         --select-types=Enumerator \
91; RUN:                         --print=types,summary \
92; RUN:                         %p/Inputs/pr-46466-*.o 2>&1 | \
93; RUN: FileCheck --strict-whitespace -check-prefix=THR %s
94
95; THR:      Logical View:
96; THR-NEXT: [000]           {File} 'pr-46466-dwarf-clang.o' -> elf64-x86-64
97; THR-EMPTY:
98; THR-NEXT: [001]           {CompileUnit} 'pr-46466.cpp'
99; THR-EMPTY:
100; THR-NEXT: -----------------------------
101; THR-NEXT: Element      Total    Printed
102; THR-NEXT: -----------------------------
103; THR-NEXT: Scopes           4          0
104; THR-NEXT: Symbols          0          0
105; THR-NEXT: Types            0          0
106; THR-NEXT: Lines            0          0
107; THR-NEXT: -----------------------------
108; THR-NEXT: Total            4          0
109; THR-EMPTY:
110; THR-NEXT: Logical View:
111; THR-NEXT: [000]           {File} 'pr-46466-dwarf-gcc.o' -> elf64-x86-64
112; THR-EMPTY:
113; THR-NEXT: [001]           {CompileUnit} 'pr-46466.cpp'
114; THR-NEXT: [005]           {Enumerator} 'BLUE' = '0x1'
115; THR-NEXT: [005]           {Enumerator} 'RED' = '0x0'
116; THR-EMPTY:
117; THR-NEXT: -----------------------------
118; THR-NEXT: Element      Total    Printed
119; THR-NEXT: -----------------------------
120; THR-NEXT: Scopes           5          0
121; THR-NEXT: Symbols          0          0
122; THR-NEXT: Types            2          2
123; THR-NEXT: Lines            0          0
124; THR-NEXT: -----------------------------
125; THR-NEXT: Total            7          2
126