blob: 0e702ac8f82eb087a99508d513895f9ff95e5ae5 [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 }
Eric Christopher947bb5a2012-03-13 23:40:48 +00007};
8
David Blaikiefd07c602013-08-09 17:20:05 +00009int add2(int x) {
10 return MyClass().add<2>(x);
11}
Eric Christopher947bb5a2012-03-13 23:40:48 +000012
David Blaikiefd07c602013-08-09 17:20:05 +000013inline int add3(int x) {
14 return MyClass().add<3>(x); // even though add<3> is ODR used, don't emit it since we don't codegen it
15}
16
17// CHECK: metadata [[C_MEM:![0-9]*]], i32 0, null, null} ; [ DW_TAG_structure_type ] [MyClass]
18// CHECK: [[C_MEM]] = metadata !{metadata [[C_TEMP:![0-9]*]]}
19// CHECK: [[C_TEMP]] = {{.*}} ; [ DW_TAG_subprogram ] [line 4] [add<2>]
David Blaikied2785892013-08-18 17:36:19 +000020
21template<typename T>
22struct outer {
23 struct inner {
24 int i;
25 };
26};
27
28struct foo {
29 void func(outer<foo>::inner);
30};
31
32inline void func() {
33 // require 'foo' to be complete before the emission of 'inner' so that, when
34 // constructing the context chain for 'x' we emit the full definition of
35 // 'foo', which requires the definition of 'inner' again
36 foo f;
37}
38
39outer<foo>::inner x;
40
41// CHECK: metadata [[OUTER_FOO_INNER:![0-9]*]], i32 {{[0-9]*}}, i32 {{[0-9]*}}, %"struct.outer<foo>::inner"* @x, {{.*}} ; [ DW_TAG_variable ] [x]
42// CHECK: [[OUTER_FOO_INNER]] = {{.*}} ; [ DW_TAG_structure_type ] [inner]
43// CHECK: [[FOO_MEM:![0-9]*]], i32 0, null, null} ; [ DW_TAG_structure_type ] [foo]
44// CHECK: [[FOO_MEM]] = metadata !{metadata [[FOO_FUNC:![0-9]*]]}
45// CHECK: [[FOO_FUNC]] = {{.*}}, metadata !"_ZN3foo4funcEN5outerIS_E5innerE", i32 {{[0-9]*}}, metadata [[FOO_FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [func]
46// CHECK: [[FOO_FUNC_TYPE]] = {{.*}}, metadata [[FOO_FUNC_PARAMS:![0-9]*]], i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
47// CHECK: [[FOO_FUNC_PARAMS]] = metadata !{null, metadata !{{[0-9]*}}, metadata [[OUTER_FOO_INNER]]}