blob: afca2ac96a2a648e967b0fc545fc043b874b2006 [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
David Blaikief2053af2013-08-28 23:06:52 +000019// CHECK: [[C:![0-9]*]] = {{.*}}, metadata [[C_MEM:![0-9]*]], i32 0, metadata [[C]], null, null} ; [ DW_TAG_structure_type ] [MyClass]
20// CHECK: [[C_MEM]] = metadata !{metadata [[C_VPTR:![0-9]*]], metadata [[C_ADD:![0-9]*]], metadata [[C_FUNC:![0-9]*]], metadata [[C_CTOR:![0-9]*]]}
21// CHECK: [[C_VPTR]] = {{.*}} ; [ DW_TAG_member ] [_vptr$MyClass]
22// CHECK: [[C_ADD]] = {{.*}} ; [ DW_TAG_subprogram ] [line 4] [add<2>]
23// CHECK: [[C_FUNC]] = {{.*}} ; [ DW_TAG_subprogram ] [line 7] [func]
24// CHECK: [[C_CTOR]] = {{.*}} ; [ DW_TAG_subprogram ] [line 0] [MyClass]
David Blaikied2785892013-08-18 17:36:19 +000025
26template<typename T>
27struct outer {
28 struct inner {
29 int i;
30 };
31};
32
33struct foo {
34 void func(outer<foo>::inner);
35};
36
37inline void func() {
38 // require 'foo' to be complete before the emission of 'inner' so that, when
39 // constructing the context chain for 'x' we emit the full definition of
40 // 'foo', which requires the definition of 'inner' again
41 foo f;
42}
43
44outer<foo>::inner x;
45
46// CHECK: metadata [[OUTER_FOO_INNER:![0-9]*]], i32 {{[0-9]*}}, i32 {{[0-9]*}}, %"struct.outer<foo>::inner"* @x, {{.*}} ; [ DW_TAG_variable ] [x]
47// CHECK: [[OUTER_FOO_INNER]] = {{.*}} ; [ DW_TAG_structure_type ] [inner]
Manman Renc4ca9b02013-08-26 22:40:31 +000048// CHECK: [[FOO_MEM:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_structure_type ] [foo]
David Blaikied2785892013-08-18 17:36:19 +000049// CHECK: [[FOO_MEM]] = metadata !{metadata [[FOO_FUNC:![0-9]*]]}
50// CHECK: [[FOO_FUNC]] = {{.*}}, metadata !"_ZN3foo4funcEN5outerIS_E5innerE", i32 {{[0-9]*}}, metadata [[FOO_FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [func]
Manman Ren4ae7ea62013-08-26 23:19:37 +000051// CHECK: [[FOO_FUNC_TYPE]] = {{.*}}, metadata [[FOO_FUNC_PARAMS:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
David Blaikied2785892013-08-18 17:36:19 +000052// CHECK: [[FOO_FUNC_PARAMS]] = metadata !{null, metadata !{{[0-9]*}}, metadata [[OUTER_FOO_INNER]]}