David Majnemer | 87b1f6d | 2013-08-24 08:21:10 +0000 | [diff] [blame] | 1 | // RUN: %clang -S -emit-llvm -fms-extensions -target x86_64-unknown_unknown -g %s -o - -std=c++11 | FileCheck %s |
Devang Patel | fa275df | 2011-02-02 21:38:49 +0000 | [diff] [blame] | 2 | |
David Blaikie | 776a364 | 2013-05-10 22:53:25 +0000 | [diff] [blame] | 3 | // CHECK: [[EMPTY:![0-9]*]] = metadata !{i32 0} |
| 4 | |
David Blaikie | 776a364 | 2013-05-10 22:53:25 +0000 | [diff] [blame] | 5 | |
David Blaikie | f1e08ac | 2013-05-09 22:43:45 +0000 | [diff] [blame] | 6 | // CHECK: [[INT:![0-9]*]] = {{.*}} ; [ DW_TAG_base_type ] [int] |
David Blaikie | 8058833 | 2013-08-01 20:31:40 +0000 | [diff] [blame] | 7 | // CHECK: metadata [[TCNESTED:![0-9]*]], i32 0, i32 1, %"struct.TC<unsigned int, 2, &glb, &foo::e, &foo::f, &func, tmpl_impl, 1, 2, 3>::nested"* @tci, null} ; [ DW_TAG_variable ] [tci] |
| 8 | // CHECK: [[TCNESTED]] = metadata !{i32 {{[0-9]*}}, metadata !{{[0-9]*}}, metadata [[TC:![0-9]*]], {{.*}} ; [ DW_TAG_structure_type ] [nested] |
| 9 | // CHECK: [[TC]] = {{.*}}, metadata [[TCARGS:![0-9]*]]} ; [ DW_TAG_structure_type ] [TC<unsigned int, 2, &glb, &foo::e, &foo::f, &func, tmpl_impl, 1, 2, 3>] |
David Blaikie | 35178dc | 2013-06-22 18:59:18 +0000 | [diff] [blame] | 10 | // CHECK: [[TCARGS]] = metadata !{metadata [[TCARG1:![0-9]*]], metadata [[TCARG2:![0-9]*]], metadata [[TCARG3:![0-9]*]], metadata [[TCARG4:![0-9]*]], metadata [[TCARG5:![0-9]*]], metadata [[TCARG6:![0-9]*]], metadata [[TCARG7:![0-9]*]], metadata [[TCARG8:![0-9]*]]} |
David Blaikie | 0cd9ede | 2013-05-09 21:32:04 +0000 | [diff] [blame] | 11 | // |
| 12 | // We seem to be missing file/line/col info on template value parameters - |
David Blaikie | 9dfd243 | 2013-05-10 21:53:14 +0000 | [diff] [blame] | 13 | // metadata supports it but it's not populated. GCC doesn't emit it either, |
| 14 | // perhaps we should just drop it from the metadata. |
David Blaikie | 0cd9ede | 2013-05-09 21:32:04 +0000 | [diff] [blame] | 15 | // |
David Blaikie | 9dfd243 | 2013-05-10 21:53:14 +0000 | [diff] [blame] | 16 | // CHECK: [[TCARG1]] = {{.*}}metadata !"T", metadata [[UINT:![0-9]*]], {{.*}} ; [ DW_TAG_template_type_parameter ] |
| 17 | // CHECK: [[UINT:![0-9]*]] = {{.*}} ; [ DW_TAG_base_type ] [unsigned int] |
| 18 | // CHECK: [[TCARG2]] = {{.*}}metadata !"", metadata [[UINT:![0-9]*]], i32 2, {{.*}} ; [ DW_TAG_template_value_parameter ] |
| 19 | // CHECK: [[TCARG3]] = {{.*}}metadata !"x", metadata [[INTPTR:![0-9]*]], i32* @glb, {{.*}} ; [ DW_TAG_template_value_parameter ] |
| 20 | // CHECK: [[INTPTR]] = {{.*}}, metadata [[INT]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int] |
| 21 | // CHECK: [[TCARG4]] = {{.*}}metadata !"a", metadata [[MEMINTPTR:![0-9]*]], i64 8, {{.*}} ; [ DW_TAG_template_value_parameter ] |
| 22 | // CHECK: [[MEMINTPTR]] = {{.*}}, metadata [[FOO:![0-9]*]]} ; [ DW_TAG_ptr_to_member_type ] {{.*}}[from int] |
| 23 | // |
| 24 | // We could just emit a declaration of 'foo' here, rather than the entire |
| 25 | // definition (same goes for any time we emit a member (function or data) |
| 26 | // pointer type) |
| 27 | // CHECK: [[FOO]] = {{.*}} ; [ DW_TAG_structure_type ] [foo] |
| 28 | // CHECK: metadata !"f", metadata !"_ZN3foo1fEv", i32 {{[0-9]*}}, metadata [[FTYPE:![0-9]*]], |
| 29 | // CHECK: [[FTYPE:![0-9]*]] = {{.*}}, metadata [[FARGS:![0-9]*]], i32 0, i32 0} ; [ DW_TAG_subroutine_type ] |
| 30 | // CHECK: [[FARGS]] = metadata !{null, metadata [[FARG1:![0-9]*]]} |
| 31 | // CHECK: [[FARG1]] = {{.*}} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from foo] |
| 32 | // |
| 33 | // Currently Clang emits the pointer-to-member-function value, but LLVM doesn't |
| 34 | // use it (GCC doesn't emit a value for pointers to member functions either - so |
| 35 | // it's not clear what, if any, format would be acceptable to GDB) |
| 36 | // |
| 37 | // CHECK: [[TCARG5]] = {{.*}}metadata !"b", metadata [[MEMFUNPTR:![0-9]*]], { i64, i64 } { i64 ptrtoint (void (%struct.foo*)* @_ZN3foo1fEv to i64), i64 0 }, {{.*}} ; [ DW_TAG_template_value_parameter ] |
| 38 | // CHECK: [[MEMFUNPTR]] = {{.*}}, metadata [[FTYPE]], metadata [[FOO]]} ; [ DW_TAG_ptr_to_member_type ] |
David Blaikie | f8aa155 | 2013-05-13 06:57:50 +0000 | [diff] [blame] | 39 | // CHECK: [[TCARG6]] = {{.*}}metadata !"f", metadata [[FUNPTR:![0-9]*]], void ()* @_Z4funcv, {{.*}} ; [ DW_TAG_template_value_parameter ] |
David Blaikie | 35178dc | 2013-06-22 18:59:18 +0000 | [diff] [blame] | 40 | // CHECK: [[FUNPTR]] = {{.*}}, metadata [[FUNTYPE:![0-9]*]]} ; [ DW_TAG_pointer_type ] |
| 41 | // CHECK: [[FUNTYPE]] = {{.*}}, metadata [[FUNARGS:![0-9]*]], i32 0, i32 0} ; [ DW_TAG_subroutine_type ] |
| 42 | // CHECK: [[FUNARGS]] = metadata !{null} |
| 43 | // CHECK: [[TCARG7]] = {{.*}}metadata !"tmpl", null, metadata !"tmpl_impl", {{.*}} ; [ DW_TAG_GNU_template_template_param ] |
| 44 | // CHECK: [[TCARG8]] = {{.*}}metadata !"Is", null, metadata [[TCARG8_VALS:![0-9]*]], {{.*}} ; [ DW_TAG_GNU_template_parameter_pack ] |
| 45 | // CHECK: [[TCARG8_VALS]] = metadata !{metadata [[TCARG8_1:![0-9]*]], metadata [[TCARG8_2:![0-9]*]], metadata [[TCARG8_3:![0-9]*]]} |
| 46 | // CHECK: [[TCARG8_1]] = {{.*}}metadata !"", metadata [[INT]], i32 1, {{.*}} ; [ DW_TAG_template_value_parameter ] |
| 47 | // CHECK: [[TCARG8_2]] = {{.*}}metadata !"", metadata [[INT]], i32 2, {{.*}} ; [ DW_TAG_template_value_parameter ] |
| 48 | // CHECK: [[TCARG8_3]] = {{.*}}metadata !"", metadata [[INT]], i32 3, {{.*}} ; [ DW_TAG_template_value_parameter ] |
Devang Patel | fa275df | 2011-02-02 21:38:49 +0000 | [diff] [blame] | 49 | |
David Blaikie | 9dfd243 | 2013-05-10 21:53:14 +0000 | [diff] [blame] | 50 | |
David Blaikie | 8058833 | 2013-08-01 20:31:40 +0000 | [diff] [blame] | 51 | // CHECK: metadata [[TCNT:![0-9]*]], i32 0, i32 1, %struct.TC* @tcn, null} ; [ DW_TAG_variable ] [tcn] |
| 52 | // CHECK: [[TCNT:![0-9]*]] = {{.*}}, metadata [[TCNARGS:![0-9]*]]} ; [ DW_TAG_structure_type ] [TC<int, -3, nullptr, nullptr, nullptr, nullptr, tmpl_impl>] |
David Blaikie | 35178dc | 2013-06-22 18:59:18 +0000 | [diff] [blame] | 53 | // CHECK: [[TCNARGS]] = metadata !{metadata [[TCNARG1:![0-9]*]], metadata [[TCNARG2:![0-9]*]], metadata [[TCNARG3:![0-9]*]], metadata [[TCNARG4:![0-9]*]], metadata [[TCNARG5:![0-9]*]], metadata [[TCNARG6:![0-9]*]], metadata [[TCARG7:![0-9]*]], metadata [[TCNARG8:![0-9]*]]} |
David Blaikie | 9dfd243 | 2013-05-10 21:53:14 +0000 | [diff] [blame] | 54 | // CHECK: [[TCNARG1]] = {{.*}}metadata !"T", metadata [[INT]], {{.*}} ; [ DW_TAG_template_type_parameter ] |
| 55 | // CHECK: [[TCNARG2]] = {{.*}}metadata !"", metadata [[INT]], i32 -3, {{.*}} ; [ DW_TAG_template_value_parameter ] |
| 56 | // CHECK: [[TCNARG3]] = {{.*}}metadata !"x", metadata [[INTPTR]], i8 0, {{.*}} ; [ DW_TAG_template_value_parameter ] |
| 57 | |
| 58 | // The interesting null pointer: -1 for member data pointers (since they are |
| 59 | // just an offset in an object, they can be zero and non-null for the first |
| 60 | // member) |
| 61 | |
| 62 | // CHECK: [[TCNARG4]] = {{.*}}metadata !"a", metadata [[MEMINTPTR]], i64 -1, {{.*}} ; [ DW_TAG_template_value_parameter ] |
| 63 | // |
| 64 | // In some future iteration we could possibly emit the value of a null member |
| 65 | // function pointer as '{ i64, i64 } zeroinitializer' as it may be handled |
| 66 | // naturally from the LLVM CodeGen side once we decide how to handle non-null |
| 67 | // member function pointers. For now, it's simpler just to emit the 'i8 0'. |
| 68 | // |
David Blaikie | f8aa155 | 2013-05-13 06:57:50 +0000 | [diff] [blame] | 69 | // CHECK: [[TCNARG5]] = {{.*}}metadata !"b", metadata [[MEMFUNPTR]], i8 0, {{.*}} ; [ DW_TAG_template_value_parameter ] |
| 70 | // CHECK: [[TCNARG6]] = {{.*}}metadata !"f", metadata [[FUNPTR]], i8 0, {{.*}} ; [ DW_TAG_template_value_parameter ] |
David Blaikie | 35178dc | 2013-06-22 18:59:18 +0000 | [diff] [blame] | 71 | // CHECK: [[TCNARG8]] = {{.*}}metadata !"Is", null, metadata [[EMPTY]], {{.*}} ; [ DW_TAG_GNU_template_parameter_pack ] |
David Majnemer | 87b1f6d | 2013-08-24 08:21:10 +0000 | [diff] [blame] | 72 | // CHECK: metadata [[TGIARGS:![0-9]*]]} ; [ DW_TAG_structure_type ] [tmpl_guid<&__uuidof(uuid)>] |
| 73 | // CHECK: [[TGIARGS]] = metadata !{metadata [[TGIARG1:![0-9]*]]} |
| 74 | // CHECK: [[TGIARG1]] = {{.*}}metadata !"", metadata [[CONST_GUID_PTR:![0-9]*]], { i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab, {{.*}} ; [ DW_TAG_template_value_parameter ] |
| 75 | // CHECK: [[CONST_GUID_PTR]] = {{.*}}, metadata [[CONST_GUID:![0-9]*]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] |
| 76 | // CHECK: [[CONST_GUID]] = {{.*}}, metadata [[GUID:![0-9]*]]} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from _GUID] |
| 77 | // CHECK: [[GUID]] = {{.*}} ; [ DW_TAG_structure_type ] [_GUID] [line 100, size 0, align 0, offset 0] [decl] |
David Blaikie | f1e08ac | 2013-05-09 22:43:45 +0000 | [diff] [blame] | 78 | struct foo { |
David Blaikie | 9dfd243 | 2013-05-10 21:53:14 +0000 | [diff] [blame] | 79 | char pad[8]; // make the member pointer to 'e' a bit more interesting (nonzero) |
David Blaikie | f1e08ac | 2013-05-09 22:43:45 +0000 | [diff] [blame] | 80 | int e; |
| 81 | void f(); |
| 82 | }; |
| 83 | |
David Blaikie | 35178dc | 2013-06-22 18:59:18 +0000 | [diff] [blame] | 84 | template<typename T, T, int *x, int foo::*a, void (foo::*b)(), void (*f)(), template<typename> class tmpl, int ...Is> |
David Blaikie | 8058833 | 2013-08-01 20:31:40 +0000 | [diff] [blame] | 85 | struct TC { |
| 86 | struct nested { |
| 87 | }; |
Devang Patel | 700a1cb | 2010-07-20 20:24:18 +0000 | [diff] [blame] | 88 | }; |
| 89 | |
David Blaikie | f1e08ac | 2013-05-09 22:43:45 +0000 | [diff] [blame] | 90 | int glb; |
David Blaikie | f8aa155 | 2013-05-13 06:57:50 +0000 | [diff] [blame] | 91 | void func(); |
David Blaikie | f1e08ac | 2013-05-09 22:43:45 +0000 | [diff] [blame] | 92 | |
David Blaikie | 35178dc | 2013-06-22 18:59:18 +0000 | [diff] [blame] | 93 | template<typename> |
| 94 | struct tmpl_impl { |
| 95 | }; |
David Blaikie | 776a364 | 2013-05-10 22:53:25 +0000 | [diff] [blame] | 96 | |
David Blaikie | 8058833 | 2013-08-01 20:31:40 +0000 | [diff] [blame] | 97 | TC<unsigned, 2, &glb, &foo::e, &foo::f, &func, tmpl_impl, 1, 2, 3>::nested tci; |
David Blaikie | 35178dc | 2013-06-22 18:59:18 +0000 | [diff] [blame] | 98 | TC<int, -3, nullptr, nullptr, nullptr, nullptr, tmpl_impl> tcn; |
David Majnemer | 87b1f6d | 2013-08-24 08:21:10 +0000 | [diff] [blame] | 99 | |
| 100 | struct _GUID; |
David Majnemer | ae3d7a1 | 2013-08-24 09:24:26 +0000 | [diff] [blame] | 101 | template <const _GUID *> |
David Majnemer | 87b1f6d | 2013-08-24 08:21:10 +0000 | [diff] [blame] | 102 | struct tmpl_guid { |
| 103 | }; |
| 104 | |
| 105 | struct __declspec(uuid("{12345678-1234-1234-1234-1234567890ab}")) uuid; |
| 106 | tmpl_guid<&__uuidof(uuid)> tgi; |