1 /* Compile with:
2 for FILE in `seq 3`; do
3 clang -g -c odr-member-functions.cpp -DFILE$FILE -o odr-member-functions/$FILE.o
4 done
5 */
6
7 // RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs/odr-member-functions -y %p/dummy-debug-map.map -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s
8
9 struct S {
fooS10 __attribute__((always_inline)) void foo() { bar(); }
fooS11 __attribute__((always_inline)) void foo(int i) { if (i) bar(); }
12 void bar();
13
bazS14 template<typename T> void baz(T t) {}
15 };
16
17 #ifdef FILE1
foo()18 void foo() {
19 S s;
20 }
21
22 // CHECK: TAG_compile_unit
23 // CHECK-NOT: {{DW_TAG|NULL}}
24 // CHECK: AT_name{{.*}}"odr-member-functions.cpp"
25
26 // CHECK: 0x[[S:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type
27 // CHECK-NOT: {{DW_TAG|NULL}}
28 // CHECK: DW_AT_name{{.*}}"S"
29 // CHECK-NOT: NULL
30 // CHECK: 0x[[FOO:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
31 // CHECK-NEXT: DW_AT_MIPS_linkage_name{{.*}}"_ZN1S3fooEv"
32 // CHECK: NULL
33 // CHECK: 0x[[FOOI:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
34 // CHECK-NEXT: DW_AT_MIPS_linkage_name{{.*}}"_ZN1S3fooEi"
35
36 #elif defined(FILE2)
foo()37 void foo() {
38 S s;
39 // Check that the overloaded member functions are resolved correctly
40 s.foo();
41 s.foo(1);
42 }
43
44 // CHECK: TAG_compile_unit
45 // CHECK-NOT: DW_TAG
46 // CHECK: AT_name{{.*}}"odr-member-functions.cpp"
47
48 // Normal member functions should be desribed by the type in the first
49 // CU, thus we should be able to reuse its definition and avoid
50 // reemiting it.
51 // CHECK-NOT: DW_TAG_structure_type
52
53 // CHECK: 0x[[FOO_SUB:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
54 // CHECK-NEXT: DW_AT_specification{{.*}}[[FOO]]
55 // CHECK-NOT: DW_TAG_structure_type
56 // CHECK: 0x[[FOOI_SUB:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
57 // CHECK-NEXT: DW_AT_specification{{.*}}[[FOOI]]
58 // CHECK-NOT: DW_TAG_structure_type
59
60 // CHECK: DW_TAG_variable
61 // CHECK-NOT: DW_TAG
62 // CHECK: DW_AT_name {{.*}}"s"
63 // CHECK-NOT: DW_TAG
64 // CHECK: DW_AT_type {{.*}}[[S]])
65 // CHECK: DW_TAG_inlined_subroutine
66 // CHECK-NEXT: DW_AT_abstract_origin{{.*}}[[FOO_SUB]]
67 // CHECK-NOT: DW_TAG
68 // CHECK: DW_AT_call_line{{.*}}40
69 // CHECK: DW_TAG_inlined_subroutine
70 // CHECK-NEXT: DW_AT_abstract_origin{{.*}}[[FOOI_SUB]]
71 // CHECK-NOT: DW_TAG
72 // CHECK: DW_AT_call_line{{.*}}41
73
74 #elif defined(FILE3)
foo()75 void foo() {
76 S s;
77 s.baz<int>(42);
78 }
79
80 // CHECK: TAG_compile_unit
81 // CHECK-NOT: DW_TAG
82 // CHECK: AT_name{{.*}}"odr-member-functions.cpp"
83
84 // Template or other implicit members will be included in the type
85 // only if they are generated. Thus actually creating a new type.
86 // CHECK: DW_TAG_structure_type
87
88 // Skip 'normal' member functions
89 // CHECK: DW_TAG_subprogram
90 // CHECK: DW_TAG_subprogram
91 // CHECK: DW_TAG_subprogram
92
93 // This is the 'baz' member
94 // CHECK: 0x[[BAZ:[0-9a-f]*]]: DW_TAG_subprogram
95 // CHECK-NOT: DW_TAG
96 // CHECK: DW_AT_MIPS_linkage_name {{.*}}"_ZN1S3bazIiEEvT_"
97 // CHECK-NOT: DW_TAG
98 // CHECK: DW_AT_name {{.*}}"baz<int>"
99
100 // Skip foo3
101 // CHECK: DW_TAG_subprogram
102
103 // baz instanciation:
104 // CHECK: DW_TAG_subprogram
105 // CHECK-NOT: DW_TAG
106 // CHECK: DW_AT_specification {{.*}}[[BAZ]] "_ZN1S3bazIiEEvT_"
107 #else
108 #error "You must define which file you generate"
109 #endif
110