File: odr-member-functions.cpp

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (192 lines) | stat: -rw-r--r-- 5,917 bytes parent folder | download | duplicates (11)
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/* Compile with:
   for FILE in `seq 3`; do
     clang -g -c  odr-member-functions.cpp -DFILE$FILE -o
   odr-member-functions/$FILE.o done
 */

// RUN: dsymutil --linker=parallel -f \
// RUN: -oso-prepend-path=%p/../../Inputs/odr-member-functions \
// RUN: -y %p/../dummy-debug-map.map -o %t1.out
// RUN: llvm-dwarfdump -debug-info %t1.out | FileCheck %s

struct S {
  __attribute__((always_inline)) void foo() { bar(); }
  __attribute__((always_inline)) void foo(int i) {
    if (i)
      bar();
  }
  void bar();

  template <typename T> void baz(T t) {}
};

#ifdef FILE1
void foo() { S s; }

// First chack that types are moved into the type table unit.

// CHECK: TAG_compile_unit
// CHECK: AT_name{{.*}}"__artificial_type_unit"

// CHECK: 0x[[INT_BASE:[0-9a-f]*]]: DW_TAG_base_type
// CHECK-NEXT: DW_AT_name{{.*}}"int"

// CHECK: 0x[[PTR_S:[0-9a-f]*]]:{{.*}}DW_TAG_pointer_type
// CHECK-NEXT: DW_AT_type{{.*}}0x[[STRUCT_S:[0-9a-f]*]] "S")

// CHECK: 0x[[STRUCT_S]]:{{.*}}DW_TAG_structure_type
// CHECK-NEXT: DW_AT_name{{.*}}"S"

// CHECK: DW_TAG_subprogram
// CHECK: DW_AT_MIPS_linkage_name{{.*}}"_ZN1S3barEv"
// CHECK: DW_AT_name{{.*}}"bar"

// CHECK: DW_TAG_formal_parameter
// CHECK-NEXT: DW_AT_type{{.*}}0x[[PTR_S]] "S *"

// CHECK: 0x[[BAZ_SUBPROGRAM:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
// CHECK: DW_AT_MIPS_linkage_name{{.*}}"_ZN1S3bazIiEEvT_"
// CHECK: DW_AT_name{{.*}}"baz<int>"

// CHECK: DW_TAG_formal_parameter
// CHECK-NEXT: DW_AT_type{{.*}}0x[[PTR_S]] "S *"

// CHECK: DW_TAG_formal_parameter
// CHECK-NEXT: DW_AT_type{{.*}}0x[[INT_BASE]] "int"

// CHECK: DW_TAG_template_type_parameter
// CHECK-NEXT: DW_AT_type{{.*}}0x[[INT_BASE]] "int"
// CHECK-NEXT: DW_AT_name{{.*}}"T"

// CHECK: 0x[[FOO_Ei:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
// CHECK: DW_AT_MIPS_linkage_name{{.*}}"_ZN1S3fooEi"
// CHECK: DW_AT_name{{.*}}"foo"

// CHECK: DW_TAG_formal_parameter
// CHECK-NEXT: DW_AT_type{{.*}}0x[[PTR_S]] "S *"

// CHECK: DW_TAG_formal_parameter
// CHECK-NEXT: DW_AT_type{{.*}}0x[[INT_BASE]] "int"

// CHECK: 0x[[FOO_Ev:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
// CHECK: DW_AT_MIPS_linkage_name{{.*}}"_ZN1S3fooEv"
// CHECK: DW_AT_name{{.*}}"foo"

// CHECK: DW_TAG_formal_parameter
// CHECK-NEXT: DW_AT_type{{.*}}0x[[PTR_S]] "S *"

// For the second unit check that it references structure "S"

// CHECK: TAG_compile_unit
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_name{{.*}}"odr-member-functions.cpp"

// CHECK: DW_TAG_subprogram
// CHECK: DW_AT_MIPS_linkage_name{{.*}}"_Z3foov"
// CHECK-NEXT: AT_name{{.*}}"foo"

// CHECK: DW_TAG_variable
// CHECK: DW_AT_name{{.*}}"s"
// CHECK: DW_AT_type{{.*}}(0x00000000[[STRUCT_S]] "S"

#elif defined(FILE2)
void foo() {
  S s;
  // Check that the overloaded member functions are resolved correctly
  s.foo();
  s.foo(1);
}

// For the third unit check that it references member functions of structure S.
// CHECK: TAG_compile_unit
// CHECK-NOT: DW_TAG
// CHECK: AT_name{{.*}}"odr-member-functions.cpp"

// CHECK: 0x[[ABASE_FOO_Ev:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
// CHECK-NEXT: DW_AT_specification {{.*}}(0x00000000[[FOO_Ev]] "_ZN1S3fooEv"
// CHECK-NEXT: DW_AT_inline    (DW_INL_inlined)
// CHECK-NEXT: DW_AT_object_pointer {{.*}}(0x[[ABASE_FOO_Ev_PARAM1:[0-9a-f]*]]

// CHECK: 0x[[ABASE_FOO_Ev_PARAM1]]:{{.*}}DW_TAG_formal_parameter
// CHECK-NEXT: DW_AT_name{{.*}}"this"
// CHECK-NEXT: DW_AT_type{{.*}}(0x00000000[[PTR_S]] "S *"

// CHECK: 0x[[ABASE_FOO_Ei:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
// CHECK-NEXT: DW_AT_specification {{.*}}(0x00000000[[FOO_Ei]] "_ZN1S3fooEi"
// CHECK-NEXT: DW_AT_inline    (DW_INL_inlined)
// CHECK-NEXT: DW_AT_object_pointer {{.*}}(0x[[ABASE_FOO_Ei_PARAM1:[0-9a-f]*]]

// CHECK: 0x[[ABASE_FOO_Ei_PARAM1]]:{{.*}}DW_TAG_formal_parameter
// CHECK-NEXT: DW_AT_name{{.*}}"this"
// CHECK-NEXT: DW_AT_type{{.*}}(0x00000000[[PTR_S]] "S *"

// CHECK: 0x[[ABASE_FOO_Ei_PARAM2:[0-9a-f]*]]:{{.*}}DW_TAG_formal_parameter
// CHECK-NEXT: DW_AT_name{{.*}}"i"
// CHECK: DW_AT_type    (0x00000000[[INT_BASE]] "int"

// CHECK: DW_TAG_subprogram
// CHECK: DW_AT_MIPS_linkage_name{{.*}}"_Z3foov"
// CHECK: DW_AT_name{{.*}}"foo"

// CHECK: DW_TAG_variable
// CHECK: DW_AT_name{{.*}}"s"
// CHECK: DW_AT_type{{.*}}(0x00000000[[STRUCT_S]] "S"

// CHECK: DW_TAG_inlined_subroutine
// CHECK: DW_AT_abstract_origin{{.*}}(0x[[ABASE_FOO_Ev]] "_ZN1S3fooEv"
// CHECK: DW_AT_low_pc
// CHECK: DW_AT_high_pc

// CHECK: DW_TAG_formal_parameter
// CHECK: DW_AT_abstract_origin{{.*}}(0x[[ABASE_FOO_Ev_PARAM1]] "this"

// CHECK: DW_TAG_inlined_subroutine
// CHECK: DW_AT_abstract_origin{{.*}}(0x[[ABASE_FOO_Ei]] "_ZN1S3fooEi"
// CHECK: DW_AT_low_pc
// CHECK: DW_AT_high_pc

// CHECK: DW_TAG_formal_parameter
// CHECK: DW_AT_abstract_origin{{.*}}(0x[[ABASE_FOO_Ei_PARAM1]] "this"

// CHECK: DW_TAG_formal_parameter
// CHECK: DW_AT_abstract_origin{{.*}}(0x[[ABASE_FOO_Ei_PARAM2]] "i"

#elif defined(FILE3)
void foo() {
  S s;
  s.baz<int>(42);
}

// For the fourth unit check that it references member functions of structure S.

// CHECK: TAG_compile_unit
// CHECK-NOT: DW_TAG
// CHECK: AT_name{{.*}}"odr-member-functions.cpp"

// CHECK: DW_TAG_subprogram
// CHECK: DW_AT_MIPS_linkage_name{{.*}}"_Z3foov"
// CHECK: DW_AT_name{{.*}}"foo"

// CHECK: DW_TAG_variable
// CHECK: DW_AT_name{{.*}}"s"
// CHECK: DW_AT_type{{.*}}(0x00000000[[STRUCT_S]] "S"

// CHECK: DW_TAG_subprogram
// CHECK: DW_AT_object_pointer{{.*}}(0x[[INST_PARAM2:[0-9a-f]*]]
// CHECK: DW_AT_specification{{.*}}(0x00000000[[BAZ_SUBPROGRAM]] "_ZN1S3bazIiEEvT_"

// CHECK: 0x[[INST_PARAM2]]:{{.*}}DW_TAG_formal_parameter
// CHECK: DW_AT_name{{.*}}"this"
// CHECK: DW_AT_type{{.*}}(0x00000000[[PTR_S]] "S *"

// CHECK: DW_TAG_formal_parameter
// CHECK: DW_AT_name{{.*}}"t"
// CHECK: DW_AT_type{{.*}}(0x00000000[[INT_BASE]] "int"

// CHECK: DW_TAG_template_type_parameter
// CHECK: DW_AT_type{{.*}}(0x00000000[[INT_BASE]] "int"
// CHECK: DW_AT_name{{.*}}"T"

#else
#error "You must define which file you generate"
#endif