1 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
2 // RUN: -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
3 // RUN: grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
4 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
5 // RUN: %clang_cc1 -fblocks -debug-info-kind=line-tables-only -gcodeview -emit-llvm %s \
6 // RUN: -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
7 // RUN: grep 'DISubprogram' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
8 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=QUAL
9 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
10 // RUN: -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++11 | \
11 // RUN: grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
12 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
13 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
14 // RUN: -o - -triple=x86_64-pc-win32 -Wno-new-returns-null | \
15 // RUN: grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
16 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
17
freefunc()18 void freefunc() { }
19 // CHECK-DAG: "freefunc"
20
21 namespace N {
b()22 int b() { return 0; }
23 // UNQUAL-DAG: "b"
24 // QUAL-DAG: "N::b"
func()25 namespace { void func() { } }
26 // UNQUAL-DAG: "func"
27 // QUAL-DAG: "N::`anonymous namespace'::func"
28 }
29
_c(void)30 void _c(void) {
31 N::func();
32 }
33 // CHECK-DAG: "_c"
34
35 struct foo {
36 int operator+(int);
foofoo37 foo(){}
38 // UNQUAL-DAG: "foo"
39 // QUAL-DAG: "foo::foo"
40
~foofoo41 ~foo(){}
42 // UNQUAL-DAG: "~foo"
43 // QUAL-DAG: "foo::~foo"
44
foofoo45 foo(int i){}
46 // UNQUAL-DAG: "foo"
47 // QUAL-DAG: "foo::foo"
48
foofoo49 foo(char *q){}
50 // UNQUAL-DAG: "foo"
51 // QUAL-DAG: "foo::foo"
52
static_methodfoo53 static foo* static_method() { return 0; }
54 // UNQUAL-DAG: "static_method"
55 // QUAL-DAG: "foo::static_method"
56
57 };
58
use_foo()59 void use_foo() {
60 foo f1, f2(1), f3((char*)0);
61 foo::static_method();
62 }
63
64 // UNQUAL-DAG: "operator+"
65 // QUAL-DAG: "foo::operator+"
operator +(int a)66 int foo::operator+(int a) { return a; }
67
68 // PR17371
69 struct OverloadedNewDelete {
70 // __cdecl
71 void *operator new(__SIZE_TYPE__);
72 void *operator new[](__SIZE_TYPE__);
73 void operator delete(void *);
74 void operator delete[](void *);
75 // __thiscall
76 int operator+(int);
77 };
78
operator new(__SIZE_TYPE__ s)79 void *OverloadedNewDelete::operator new(__SIZE_TYPE__ s) { return 0; }
operator new[](__SIZE_TYPE__ s)80 void *OverloadedNewDelete::operator new[](__SIZE_TYPE__ s) { return 0; }
operator delete(void *)81 void OverloadedNewDelete::operator delete(void *) { }
operator delete[](void *)82 void OverloadedNewDelete::operator delete[](void *) { }
operator +(int x)83 int OverloadedNewDelete::operator+(int x) { return x; };
84
85 // UNQUAL-DAG: "operator new"
86 // UNQUAL-DAG: "operator new[]"
87 // UNQUAL-DAG: "operator delete"
88 // UNQUAL-DAG: "operator delete[]"
89 // UNQUAL-DAG: "operator+"
90 // QUAL-DAG: "OverloadedNewDelete::operator new"
91 // QUAL-DAG: "OverloadedNewDelete::operator new[]"
92 // QUAL-DAG: "OverloadedNewDelete::operator delete"
93 // QUAL-DAG: "OverloadedNewDelete::operator delete[]"
94 // QUAL-DAG: "OverloadedNewDelete::operator+"
95
96
97 template <typename T, void (*)(void)>
fn_tmpl()98 void fn_tmpl() {}
99
100 template void fn_tmpl<int, freefunc>();
101 // CHECK-DAG: "fn_tmpl<int,&freefunc>"
102
103 template <typename A, typename B, typename C> struct ClassTemplate { A a; B b; C c; };
104 ClassTemplate<char, short, ClassTemplate<int, int, int> > f;
105 // This will only show up in normal debug builds. The space in `> >` is
106 // important for compatibility with Windows debuggers, so it should always be
107 // there when generating CodeView.
108 // UNQUAL-DAG: "ClassTemplate<char,short,ClassTemplate<int,int,int> >"
109