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-prefixes=CHECK,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
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-prefixes=CHECK,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-prefixes=CHECK,UNQUAL
17 
freefunc()18 void freefunc() { }
19 // CHECK-DAG: "freefunc"
20 
21 namespace N {
b()22   int b() { return 0; }
23 // CHECK-DAG: "b"
func()24   namespace { void func() { } }
25 // CHECK-DAG: "func"
26 }
27 
_c(void)28 void _c(void) {
29   N::func();
30 }
31 // CHECK-DAG: "_c"
32 
33 struct foo {
34   int operator+(int);
foofoo35   foo(){}
36 // CHECK-DAG: "foo"
37 
~foofoo38   ~foo(){}
39 // CHECK-DAG: "~foo"
40 
foofoo41   foo(int i){}
42 // CHECK-DAG: "foo"
43 
foofoo44   foo(char *q){}
45 // CHECK-DAG: "foo"
46 
static_methodfoo47   static foo* static_method() { return 0; }
48 // CHECK-DAG: "static_method"
49 
50 };
51 
use_foo()52 void use_foo() {
53   foo f1, f2(1), f3((char*)0);
54   foo::static_method();
55 }
56 
57 // CHECK-DAG: "operator+"
operator +(int a)58 int foo::operator+(int a) { return a; }
59 
60 // PR17371
61 struct OverloadedNewDelete {
62   // __cdecl
63   void *operator new(__SIZE_TYPE__);
64   void *operator new[](__SIZE_TYPE__);
65   void operator delete(void *);
66   void operator delete[](void *);
67   // __thiscall
68   int operator+(int);
69 };
70 
operator new(__SIZE_TYPE__ s)71 void *OverloadedNewDelete::operator new(__SIZE_TYPE__ s) { return 0; }
operator new[](__SIZE_TYPE__ s)72 void *OverloadedNewDelete::operator new[](__SIZE_TYPE__ s) { return 0; }
operator delete(void *)73 void OverloadedNewDelete::operator delete(void *) { }
operator delete[](void *)74 void OverloadedNewDelete::operator delete[](void *) { }
operator +(int x)75 int OverloadedNewDelete::operator+(int x) { return x; };
76 
77 // CHECK-DAG: "operator new"
78 // CHECK-DAG: "operator new[]"
79 // CHECK-DAG: "operator delete"
80 // CHECK-DAG: "operator delete[]"
81 // CHECK-DAG: "operator+"
82 
83 template <typename T, void (*)(void)>
fn_tmpl()84 void fn_tmpl() {}
85 
86 template void fn_tmpl<int, freefunc>();
87 // CHECK-DAG: "fn_tmpl<int,&freefunc>"
88 
89 template <typename T, void (*)(void)>
fn_tmpl_typecheck()90 void fn_tmpl_typecheck() {}
91 
92 template void fn_tmpl_typecheck<int, &freefunc>();
93 // CHECK-DAG: "fn_tmpl_typecheck<int,&freefunc>"
94 
95 template <typename A, typename B, typename C> struct ClassTemplate { A a; B b; C c; };
96 ClassTemplate<char, short, ClassTemplate<int, int, int> > f;
97 // This will only show up in normal debug builds.  The space in `> >` is
98 // important for compatibility with Windows debuggers, so it should always be
99 // there when generating CodeView.
100 // UNQUAL-DAG: "ClassTemplate<char,short,ClassTemplate<int,int,int> >"
101