blob: 38019a9357487bdf72a485516aada6ce724316ab [file] [log] [blame]
Eric Christopher947bb5a2012-03-13 23:40:48 +00001// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
2
David Blaikiefd07c602013-08-09 17:20:05 +00003struct MyClass {
4 template <int i> int add(int j) {
5 return i + j;
6 }
David Blaikief2053af2013-08-28 23:06:52 +00007 virtual void func() {
8 }
Eric Christopher947bb5a2012-03-13 23:40:48 +00009};
10
David Blaikiefd07c602013-08-09 17:20:05 +000011int add2(int x) {
12 return MyClass().add<2>(x);
13}
Eric Christopher947bb5a2012-03-13 23:40:48 +000014
David Blaikiefd07c602013-08-09 17:20:05 +000015inline int add3(int x) {
16 return MyClass().add<3>(x); // even though add<3> is ODR used, don't emit it since we don't codegen it
17}
18
Manman Rene0064d82013-08-29 23:19:58 +000019// CHECK: [[FOO_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTS3foo"} ; [ DW_TAG_structure_type ] [foo]
20// CHECK: [[FOO_MEM]] = metadata !{metadata [[FOO_FUNC:![0-9]*]]}
21// CHECK: [[FOO_FUNC]] = {{.*}}, metadata !"_ZN3foo4funcEN5outerIS_E5innerE", i32 {{[0-9]*}}, metadata [[FOO_FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [func]
22// CHECK: [[FOO_FUNC_TYPE]] = {{.*}}, metadata [[FOO_FUNC_PARAMS:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
23// CHECK: [[FOO_FUNC_PARAMS]] = metadata !{null, metadata !{{[0-9]*}}, metadata [[OUTER_FOO_INNER:![0-9]*]]}
24// CHECK: [[OUTER_FOO_INNER]] = {{.*}} ; [ DW_TAG_structure_type ] [inner]
25
26// CHECK: [[C:![0-9]*]] = {{.*}}, metadata [[C_MEM:![0-9]*]], i32 0, metadata [[C]], null, metadata !"_ZTS7MyClass"} ; [ DW_TAG_structure_type ] [MyClass]
David Blaikief2053af2013-08-28 23:06:52 +000027// CHECK: [[C_MEM]] = metadata !{metadata [[C_VPTR:![0-9]*]], metadata [[C_ADD:![0-9]*]], metadata [[C_FUNC:![0-9]*]], metadata [[C_CTOR:![0-9]*]]}
28// CHECK: [[C_VPTR]] = {{.*}} ; [ DW_TAG_member ] [_vptr$MyClass]
Manman Rene0064d82013-08-29 23:19:58 +000029
David Blaikief2053af2013-08-28 23:06:52 +000030// CHECK: [[C_ADD]] = {{.*}} ; [ DW_TAG_subprogram ] [line 4] [add<2>]
31// CHECK: [[C_FUNC]] = {{.*}} ; [ DW_TAG_subprogram ] [line 7] [func]
32// CHECK: [[C_CTOR]] = {{.*}} ; [ DW_TAG_subprogram ] [line 0] [MyClass]
David Blaikied2785892013-08-18 17:36:19 +000033
34template<typename T>
35struct outer {
36 struct inner {
37 int i;
38 };
39};
40
41struct foo {
42 void func(outer<foo>::inner);
43};
44
45inline void func() {
46 // require 'foo' to be complete before the emission of 'inner' so that, when
47 // constructing the context chain for 'x' we emit the full definition of
48 // 'foo', which requires the definition of 'inner' again
49 foo f;
50}
51
52outer<foo>::inner x;
53
Manman Rene0064d82013-08-29 23:19:58 +000054// CHECK: metadata [[OUTER_FOO_INNER]], i32 {{[0-9]*}}, i32 {{[0-9]*}}, %"struct.outer<foo>::inner"* @x, {{.*}} ; [ DW_TAG_variable ] [x]