File: 04-coff-missing-nested-enumerators.test

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (136 lines) | stat: -rw-r--r-- 5,968 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
; 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