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