1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -g %s -o - | FileCheck %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple i686-pc-windows-msvc -emit-llvm -g %s -o - | FileCheck %s --check-prefix=MSVC
3*0a6a1f1dSLionel Sambuc
4f4a2713aSLionel Sambuc template<typename T> struct Identity {
5f4a2713aSLionel Sambuc typedef T Type;
6f4a2713aSLionel Sambuc };
7f4a2713aSLionel Sambuc
f(Identity<int>::Type a)8f4a2713aSLionel Sambuc void f(Identity<int>::Type a) {}
f(Identity<int> a)9f4a2713aSLionel Sambuc void f(Identity<int> a) {}
f(int & a)10f4a2713aSLionel Sambuc void f(int& a) { }
11f4a2713aSLionel Sambuc
12f4a2713aSLionel Sambuc template<typename T> struct A {
13f4a2713aSLionel Sambuc A<T> *next;
14f4a2713aSLionel Sambuc };
f(A<int>)15f4a2713aSLionel Sambuc void f(A<int>) { }
16f4a2713aSLionel Sambuc
17f4a2713aSLionel Sambuc struct B { };
18f4a2713aSLionel Sambuc
f()19f4a2713aSLionel Sambuc void f() {
20f4a2713aSLionel Sambuc int B::*a = 0;
21f4a2713aSLionel Sambuc void (B::*b)() = 0;
22f4a2713aSLionel Sambuc }
23f4a2713aSLionel Sambuc
24f4a2713aSLionel Sambuc namespace EmptyNameCrash {
25f4a2713aSLionel Sambuc struct A { A(); };
26f4a2713aSLionel Sambuc typedef struct { A x; } B;
27f4a2713aSLionel Sambuc B x;
28f4a2713aSLionel Sambuc }
29f4a2713aSLionel Sambuc
30f4a2713aSLionel Sambuc // PR4890
31f4a2713aSLionel Sambuc namespace PR4890 {
32f4a2713aSLionel Sambuc struct X {
33f4a2713aSLionel Sambuc ~X();
34f4a2713aSLionel Sambuc };
35f4a2713aSLionel Sambuc
~X()36f4a2713aSLionel Sambuc X::~X() { }
37f4a2713aSLionel Sambuc }
38f4a2713aSLionel Sambuc
39f4a2713aSLionel Sambuc namespace VirtualDtor {
40f4a2713aSLionel Sambuc struct Y {
41f4a2713aSLionel Sambuc virtual ~Y();
42f4a2713aSLionel Sambuc };
43f4a2713aSLionel Sambuc
~Y()44f4a2713aSLionel Sambuc Y::~Y() { }
45f4a2713aSLionel Sambuc }
46f4a2713aSLionel Sambuc
47f4a2713aSLionel Sambuc namespace VirtualBase {
48*0a6a1f1dSLionel Sambuc struct A { int a; };
49*0a6a1f1dSLionel Sambuc struct B : virtual A { int b; };
50f4a2713aSLionel Sambuc
f()51f4a2713aSLionel Sambuc void f() {
52f4a2713aSLionel Sambuc B b;
53f4a2713aSLionel Sambuc }
54f4a2713aSLionel Sambuc }
55f4a2713aSLionel Sambuc
56*0a6a1f1dSLionel Sambuc // MSVC: [[VBASE_B:![0-9]+]] = distinct !{!"0x13\00B\00{{[0-9]+}}\0096\0032\000\000\000", {{.*}}, null, [[VBASE_B_DEF:![0-9]+]], {{.*}}} ; [ DW_TAG_structure_type ] [B] [line 49, size 96, align 32, offset 0] [def] [from ]
57*0a6a1f1dSLionel Sambuc // MSVC: [[VBASE_B_DEF]] = !{[[VBASE_A_IN_B:![0-9]+]],
58*0a6a1f1dSLionel Sambuc //
59*0a6a1f1dSLionel Sambuc // Look for the vbtable offset of A, which should be 4.
60*0a6a1f1dSLionel Sambuc // MSVC: [[VBASE_A_IN_B]] = !{!"0x1c\00\000\000\000\004\0032", null, [[VBASE_B]], !{{[0-9]*}}} ; [ DW_TAG_inheritance ] [line 0, size 0, align 0, offset 4] [from A]
61f4a2713aSLionel Sambuc
62*0a6a1f1dSLionel Sambuc // CHECK: !"0x13\00B\00{{[0-9]+}}\00128\0064\000\000\000", {{.*}}, null, [[VBASE_B_DEF:![0-9]+]], {{.*}}} ; [ DW_TAG_structure_type ] [B] [line 49, size 128, align 64, offset 0] [def] [from ]
63*0a6a1f1dSLionel Sambuc // CHECK: [[VBASE_B_DEF]] = !{[[VBASE_A_IN_B:![0-9]+]],
64*0a6a1f1dSLionel Sambuc //
65*0a6a1f1dSLionel Sambuc // Look for the vtable offset offset, which should be -24.
66*0a6a1f1dSLionel Sambuc // CHECK: [[VBASE_A_IN_B]] = !{!"0x1c\00\000\000\000\0024\0032", null, !"_ZTSN11VirtualBase1BE", !"_ZTSN11VirtualBase1AE"} ; [ DW_TAG_inheritance ] [line 0, size 0, align 0, offset 24] [from _ZTSN11VirtualBase1AE]
67f4a2713aSLionel Sambuc namespace b5249287 {
68f4a2713aSLionel Sambuc template <typename T> class A {
69f4a2713aSLionel Sambuc struct B;
70f4a2713aSLionel Sambuc };
71f4a2713aSLionel Sambuc
72f4a2713aSLionel Sambuc class Cls {
73f4a2713aSLionel Sambuc template <typename T> friend class A<T>::B;
74f4a2713aSLionel Sambuc };
75f4a2713aSLionel Sambuc
76f4a2713aSLionel Sambuc Cls obj;
77f4a2713aSLionel Sambuc }
78f4a2713aSLionel Sambuc
79f4a2713aSLionel Sambuc namespace pr14763 {
80f4a2713aSLionel Sambuc struct foo {
81f4a2713aSLionel Sambuc foo(const foo&);
82f4a2713aSLionel Sambuc };
83f4a2713aSLionel Sambuc
func(foo f)84f4a2713aSLionel Sambuc foo func(foo f) {
85f4a2713aSLionel Sambuc return f; // reference 'f' for now because otherwise we hit another bug
86f4a2713aSLionel Sambuc }
87f4a2713aSLionel Sambuc
88*0a6a1f1dSLionel Sambuc // CHECK: !"0x13\00{{.*}}", !{{[0-9]*}}, [[PR14763:![0-9]*]], {{.*}}, !"[[FOO:.*]]"} ; [ DW_TAG_structure_type ] [foo]
89f4a2713aSLionel Sambuc // CHECK: [[PR14763]] = {{.*}} ; [ DW_TAG_namespace ] [pr14763]
90f4a2713aSLionel Sambuc // CHECK: [[INCTYPE:![0-9]*]] = {{.*}} ; [ DW_TAG_structure_type ] [incomplete]{{.*}} [decl]
91*0a6a1f1dSLionel Sambuc // CHECK: [[A_MEM:![0-9]*]], null, null, !"_ZTSN7pr162141aE"} ; [ DW_TAG_structure_type ] [a]
92*0a6a1f1dSLionel Sambuc // CHECK: [[A_MEM]] = !{[[A_I:![0-9]*]]}
93f4a2713aSLionel Sambuc // CHECK: [[A_I]] = {{.*}} ; [ DW_TAG_member ] [i] {{.*}} [from int]
94f4a2713aSLionel Sambuc // CHECK: ; [ DW_TAG_structure_type ] [b] {{.*}}[decl]
95f4a2713aSLionel Sambuc
96*0a6a1f1dSLionel Sambuc // CHECK: [[FUNC:![0-9]*]] = !{!"0x2e\00func\00func\00_ZN7pr147634funcENS_3fooE\00{{.*}}"{{, [^,]+, [^,]+}}, [[FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]
97f4a2713aSLionel Sambuc }
98f4a2713aSLionel Sambuc
foo()99*0a6a1f1dSLionel Sambuc void foo() {
100*0a6a1f1dSLionel Sambuc const wchar_t c = L'x';
101*0a6a1f1dSLionel Sambuc wchar_t d = c;
102*0a6a1f1dSLionel Sambuc }
103*0a6a1f1dSLionel Sambuc
104*0a6a1f1dSLionel Sambuc // CHECK-NOT: ; [ DW_TAG_variable ] [c]
105*0a6a1f1dSLionel Sambuc
106f4a2713aSLionel Sambuc namespace pr9608 { // also pr9600
107f4a2713aSLionel Sambuc struct incomplete;
108f4a2713aSLionel Sambuc incomplete (*x)[3];
109*0a6a1f1dSLionel Sambuc // CHECK: [[INCARRAYPTR:![0-9]*]], [3 x i8]** @_ZN6pr96081xE, null} ; [ DW_TAG_variable ] [x]
110*0a6a1f1dSLionel Sambuc // CHECK: [[INCARRAYPTR]] = {{.*}}[[INCARRAY:![0-9]*]]} ; [ DW_TAG_pointer_type ]
111*0a6a1f1dSLionel Sambuc // CHECK: [[INCARRAY]] = !{!"0x1\00\000\000\000\000\000\000", null, null, !"_ZTSN6pr960810incompleteE", {{![0-9]+}}, null, null, null} ; [ DW_TAG_array_type ] [line 0, size 0, align 0, offset 0] [from _ZTSN6pr960810incompleteE]
112f4a2713aSLionel Sambuc }
113f4a2713aSLionel Sambuc
114*0a6a1f1dSLionel Sambuc // For some reason function arguments ended up down here
115*0a6a1f1dSLionel Sambuc // CHECK: = !{!"0x101\00f\00{{.*}}\008192", [[FUNC]], {{![0-9]+}}, !"[[FOO]]"} ; [ DW_TAG_arg_variable ] [f]
116*0a6a1f1dSLionel Sambuc
117*0a6a1f1dSLionel Sambuc // CHECK: ; [ DW_TAG_auto_variable ] [c]
118f4a2713aSLionel Sambuc
119f4a2713aSLionel Sambuc namespace pr16214 {
120f4a2713aSLionel Sambuc struct a {
121f4a2713aSLionel Sambuc int i;
122f4a2713aSLionel Sambuc };
123f4a2713aSLionel Sambuc
124f4a2713aSLionel Sambuc typedef a at;
125f4a2713aSLionel Sambuc
126f4a2713aSLionel Sambuc struct b {
127f4a2713aSLionel Sambuc };
128f4a2713aSLionel Sambuc
129f4a2713aSLionel Sambuc typedef b bt;
130f4a2713aSLionel Sambuc
func()131f4a2713aSLionel Sambuc void func() {
132f4a2713aSLionel Sambuc at a_inst;
133f4a2713aSLionel Sambuc bt *b_ptr_inst;
134f4a2713aSLionel Sambuc const bt *b_cnst_ptr_inst;
135f4a2713aSLionel Sambuc }
136f4a2713aSLionel Sambuc
137f4a2713aSLionel Sambuc }
138