Eric Christopher | 947bb5a | 2012-03-13 23:40:48 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s |
| 2 | |
David Blaikie | fd07c60 | 2013-08-09 17:20:05 +0000 | [diff] [blame] | 3 | struct MyClass { |
| 4 | template <int i> int add(int j) { |
| 5 | return i + j; |
| 6 | } |
Eric Christopher | 947bb5a | 2012-03-13 23:40:48 +0000 | [diff] [blame] | 7 | }; |
| 8 | |
David Blaikie | fd07c60 | 2013-08-09 17:20:05 +0000 | [diff] [blame] | 9 | int add2(int x) { |
| 10 | return MyClass().add<2>(x); |
| 11 | } |
Eric Christopher | 947bb5a | 2012-03-13 23:40:48 +0000 | [diff] [blame] | 12 | |
David Blaikie | fd07c60 | 2013-08-09 17:20:05 +0000 | [diff] [blame] | 13 | inline 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 Blaikie | d278589 | 2013-08-18 17:36:19 +0000 | [diff] [blame^] | 20 | |
| 21 | template<typename T> |
| 22 | struct outer { |
| 23 | struct inner { |
| 24 | int i; |
| 25 | }; |
| 26 | }; |
| 27 | |
| 28 | struct foo { |
| 29 | void func(outer<foo>::inner); |
| 30 | }; |
| 31 | |
| 32 | inline 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 | |
| 39 | outer<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]]} |