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

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (125 lines) | stat: -rw-r--r-- 5,272 bytes parent folder | download | duplicates (10)
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
; 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 DWARF debug
; information generated by the Clang compiler does not include any
; references to the enumerators 'RED' and 'BLUE'. The DWARF generated
; by GCC, 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-dwarf-clang.o \
; RUN:                         %p/Inputs/pr-46466-dwarf-gcc.o 2>&1 | \
; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s

; ONE:      Logical View:
; ONE-NEXT: [000]           {File} 'pr-46466-dwarf-clang.o' -> elf64-x86-64
; ONE-EMPTY:
; ONE-NEXT: [001]             {CompileUnit} 'pr-46466.cpp'
; ONE-NEXT: [002]               {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [002]     8         {Variable} extern 'S' -> 'Struct'
; ONE-NEXT: [002]     1         {Struct} 'Struct'
; ONE-NEXT: [003]     5           {Member} public 'U' -> 'Union'
; ONE-EMPTY:
; ONE-NEXT: Logical View:
; ONE-NEXT: [000]           {File} 'pr-46466-dwarf-gcc.o' -> elf64-x86-64
; ONE-EMPTY:
; ONE-NEXT: [001]             {CompileUnit} 'pr-46466.cpp'
; ONE-NEXT: [002]               {Producer} 'GNU C++14 10.3.0 {{.*}}'
; ONE-NEXT: [002]     8         {Variable} extern 'S' -> 'Struct'
; ONE-NEXT: [002]     1         {Struct} 'Struct'
; ONE-NEXT: [003]     5           {Member} public 'U' -> 'Union'
; ONE-NEXT: [003]     2           {Union} 'Union'
; ONE-NEXT: [004]     3             {Enumeration} 'NestedEnum' -> 'unsigned 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-dwarf-clang.o' -> elf64-x86-64
; TWO-EMPTY:
; TWO-NEXT: [001]             {CompileUnit} 'pr-46466.cpp'
; TWO-EMPTY:
; TWO-NEXT: Logical View:
; TWO-NEXT: [000]           {File} 'pr-46466-dwarf-gcc.o' -> elf64-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' -> 'unsigned 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-dwarf-clang.o' -> elf64-x86-64
; THR-EMPTY:
; THR-NEXT: [001]           {CompileUnit} 'pr-46466.cpp'
; THR-EMPTY:
; THR-NEXT: -----------------------------
; THR-NEXT: Element      Total    Printed
; THR-NEXT: -----------------------------
; THR-NEXT: Scopes           4          0
; THR-NEXT: Symbols          0          0
; THR-NEXT: Types            0          0
; THR-NEXT: Lines            0          0
; THR-NEXT: -----------------------------
; THR-NEXT: Total            4          0
; THR-EMPTY:
; THR-NEXT: Logical View:
; THR-NEXT: [000]           {File} 'pr-46466-dwarf-gcc.o' -> elf64-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          0          0
; THR-NEXT: Types            2          2
; THR-NEXT: Lines            0          0
; THR-NEXT: -----------------------------
; THR-NEXT: Total            7          2