Manman Ren | 7b1e9b4 | 2013-08-28 18:31:02 +0000 | [diff] [blame] | 1 | // RUN: %clang -S -emit-llvm -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 | |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 3 | // CHECK: !MDCompileUnit( |
| 4 | // CHECK-SAME: retainedTypes: [[RETAIN:![0-9]*]] |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 5 | // CHECK: [[EMPTY:![0-9]*]] = !{} |
| 6 | // CHECK: [[RETAIN]] = !{!{{[0-9]]*}}, [[FOO:![0-9]*]], |
David Blaikie | 776a364 | 2013-05-10 22:53:25 +0000 | [diff] [blame] | 7 | |
David Blaikie | 776a364 | 2013-05-10 22:53:25 +0000 | [diff] [blame] | 8 | |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 9 | // CHECK: [[TC:![0-9]*]] = !MDCompositeType(tag: DW_TAG_structure_type, name: "TC<unsigned int, 2, &glb, &foo::e, &foo::f, &foo::g, 1, 2, 3>" |
| 10 | // CHECK-SAME: templateParams: [[TCARGS:![0-9]*]] |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 11 | // CHECK: [[TCARGS]] = !{[[TCARG1:![0-9]*]], [[TCARG2:![0-9]*]], [[TCARG3:![0-9]*]], [[TCARG4:![0-9]*]], [[TCARG5:![0-9]*]], [[TCARG6:![0-9]*]], [[TCARG7:![0-9]*]]} |
David Blaikie | 0cd9ede | 2013-05-09 21:32:04 +0000 | [diff] [blame] | 12 | // |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 13 | // CHECK: [[TCARG1]] = !MDTemplateTypeParameter(name: "T", type: [[UINT:![0-9]*]]) |
| 14 | // CHECK: [[UINT:![0-9]*]] = !MDBasicType(name: "unsigned int" |
| 15 | // CHECK: [[TCARG2]] = !MDTemplateValueParameter(type: [[UINT]], value: i32 2) |
| 16 | // CHECK: [[TCARG3]] = !MDTemplateValueParameter(name: "x", type: [[CINTPTR:![0-9]*]], value: i32* @glb) |
| 17 | // CHECK: [[CINTPTR]] = !MDDerivedType(tag: DW_TAG_pointer_type, {{.*}}baseType: [[CINT:![0-9]+]] |
| 18 | // CHECK: [[CINT]] = !MDDerivedType(tag: DW_TAG_const_type, {{.*}}baseType: [[INT:![0-9]+]] |
| 19 | // CHECK: [[INT]] = !MDBasicType(name: "int" |
| 20 | // CHECK: [[TCARG4]] = !MDTemplateValueParameter(name: "a", type: [[MEMINTPTR:![0-9]*]], value: i64 8) |
| 21 | // CHECK: [[MEMINTPTR]] = !MDDerivedType(tag: DW_TAG_ptr_to_member_type, {{.*}}baseType: [[INT]], {{.*}}extraData: !"_ZTS3foo") |
David Blaikie | 9dfd243 | 2013-05-10 21:53:14 +0000 | [diff] [blame] | 22 | // |
| 23 | // Currently Clang emits the pointer-to-member-function value, but LLVM doesn't |
| 24 | // use it (GCC doesn't emit a value for pointers to member functions either - so |
| 25 | // it's not clear what, if any, format would be acceptable to GDB) |
| 26 | // |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 27 | // CHECK: [[TCARG5]] = !MDTemplateValueParameter(name: "b", type: [[MEMFUNPTR:![0-9]*]], value: { i64, i64 } { i64 ptrtoint (void (%struct.foo*)* @_ZN3foo1fEv to i64), i64 0 }) |
| 28 | // CHECK: [[MEMFUNPTR]] = !MDDerivedType(tag: DW_TAG_ptr_to_member_type, {{.*}}baseType: [[FTYPE:![0-9]*]], {{.*}}extraData: !"_ZTS3foo") |
| 29 | // CHECK: [[FTYPE]] = !MDSubroutineType(types: [[FARGS:![0-9]*]]) |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 30 | // CHECK: [[FARGS]] = !{null, [[FARG1:![0-9]*]]} |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 31 | // CHECK: [[FARG1]] = !MDDerivedType(tag: DW_TAG_pointer_type, |
| 32 | // CHECK-SAME: baseType: !"_ZTS3foo" |
| 33 | // CHECK-NOT: line: |
| 34 | // CHECK-SAME: size: 64, align: 64 |
| 35 | // CHECK-NOT: offset: 0 |
| 36 | // CHECK-SAME: DIFlagArtificial |
Manman Ren | 832e921 | 2013-09-05 18:51:02 +0000 | [diff] [blame] | 37 | // |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 38 | // CHECK: [[TCARG6]] = !MDTemplateValueParameter(name: "f", type: [[FUNPTR:![0-9]*]], value: void ()* @_ZN3foo1gEv) |
| 39 | // CHECK: [[FUNPTR]] = !MDDerivedType(tag: DW_TAG_pointer_type, baseType: [[FUNTYPE:![0-9]*]] |
| 40 | // CHECK: [[FUNTYPE]] = !MDSubroutineType(types: [[FUNARGS:![0-9]*]]) |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 41 | // CHECK: [[FUNARGS]] = !{null} |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 42 | // CHECK: [[TCARG7]] = !MDTemplateValueParameter(tag: DW_TAG_GNU_template_parameter_pack, name: "Is", value: [[TCARG7_VALS:![0-9]*]]) |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 43 | // CHECK: [[TCARG7_VALS]] = !{[[TCARG7_1:![0-9]*]], [[TCARG7_2:![0-9]*]], [[TCARG7_3:![0-9]*]]} |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 44 | // CHECK: [[TCARG7_1]] = !MDTemplateValueParameter(type: [[INT]], value: i32 1) |
| 45 | // CHECK: [[TCARG7_2]] = !MDTemplateValueParameter(type: [[INT]], value: i32 2) |
| 46 | // CHECK: [[TCARG7_3]] = !MDTemplateValueParameter(type: [[INT]], value: i32 3) |
Manman Ren | 8e0f65f | 2013-10-05 01:43:22 +0000 | [diff] [blame] | 47 | // |
| 48 | // We could just emit a declaration of 'foo' here, rather than the entire |
| 49 | // definition (same goes for any time we emit a member (function or data) |
| 50 | // pointer type) |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 51 | // CHECK: [[FOO]] = !MDCompositeType(tag: DW_TAG_structure_type, name: "foo", {{.*}}identifier: "_ZTS3foo") |
| 52 | // CHECK: !MDSubprogram(name: "f", linkageName: "_ZN3foo1fEv", {{.*}}type: [[FTYPE:![0-9]*]] |
Manman Ren | 8e0f65f | 2013-10-05 01:43:22 +0000 | [diff] [blame] | 53 | // |
Devang Patel | fa275df | 2011-02-02 21:38:49 +0000 | [diff] [blame] | 54 | |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 55 | // CHECK: !MDCompositeType(tag: DW_TAG_structure_type, name: "nested", |
| 56 | // CHECK-SAME: scope: !"_ZTS2TCIjLj2EXadL_Z3glbEEXadL_ZN3foo1eEEEXadL_ZNS0_1fEvEEXadL_ZNS0_1gEvEEJLi1ELi2ELi3EEE" |
| 57 | // CHECK-SAME: identifier: "[[TCNESTED:.*]]") |
| 58 | // CHECK: !MDCompositeType(tag: DW_TAG_structure_type, name: "TC<int, -3, nullptr, nullptr, nullptr, nullptr>" |
| 59 | // CHECK-SAME: templateParams: [[TCNARGS:![0-9]*]] |
| 60 | // CHECK-SAME: identifier: "[[TCNT:.*]]") |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 61 | // CHECK: [[TCNARGS]] = !{[[TCNARG1:![0-9]*]], [[TCNARG2:![0-9]*]], [[TCNARG3:![0-9]*]], [[TCNARG4:![0-9]*]], [[TCNARG5:![0-9]*]], [[TCNARG6:![0-9]*]], [[TCNARG7:![0-9]*]]} |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 62 | // CHECK: [[TCNARG1]] = !MDTemplateTypeParameter(name: "T", type: [[INT]]) |
| 63 | // CHECK: [[TCNARG2]] = !MDTemplateValueParameter(type: [[INT]], value: i32 -3) |
| 64 | // CHECK: [[TCNARG3]] = !MDTemplateValueParameter(name: "x", type: [[CINTPTR]], value: i8 0) |
David Blaikie | 9dfd243 | 2013-05-10 21:53:14 +0000 | [diff] [blame] | 65 | |
| 66 | // The interesting null pointer: -1 for member data pointers (since they are |
| 67 | // just an offset in an object, they can be zero and non-null for the first |
| 68 | // member) |
| 69 | |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 70 | // CHECK: [[TCNARG4]] = !MDTemplateValueParameter(name: "a", type: [[MEMINTPTR]], value: i64 -1) |
David Blaikie | 9dfd243 | 2013-05-10 21:53:14 +0000 | [diff] [blame] | 71 | // |
| 72 | // In some future iteration we could possibly emit the value of a null member |
| 73 | // function pointer as '{ i64, i64 } zeroinitializer' as it may be handled |
| 74 | // naturally from the LLVM CodeGen side once we decide how to handle non-null |
| 75 | // member function pointers. For now, it's simpler just to emit the 'i8 0'. |
| 76 | // |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 77 | // CHECK: [[TCNARG5]] = !MDTemplateValueParameter(name: "b", type: [[MEMFUNPTR]], value: i8 0) |
| 78 | // CHECK: [[TCNARG6]] = !MDTemplateValueParameter(name: "f", type: [[FUNPTR]], value: i8 0) |
| 79 | // CHECK: [[TCNARG7]] = !MDTemplateValueParameter(tag: DW_TAG_GNU_template_parameter_pack, name: "Is", value: [[EMPTY]]) |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 80 | |
| 81 | // FIXME: these parameters should probably be rendered as 'glb' rather than |
| 82 | // '&glb', since they're references, not pointers. |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 83 | // CHECK: !MDCompositeType(tag: DW_TAG_structure_type, name: "NN<tmpl_impl, &glb, &glb>", |
| 84 | // CHECK-SAME: templateParams: [[NNARGS:![0-9]*]] |
| 85 | // CHECK-SAME: identifier: "[[NNT:.*]]") |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 86 | // CHECK: [[NNARGS]] = !{[[NNARG1:![0-9]*]], [[NNARG2:![0-9]*]], [[NNARG3:![0-9]*]]} |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 87 | // CHECK: [[NNARG1]] = !MDTemplateValueParameter(tag: DW_TAG_GNU_template_template_param, name: "tmpl", value: !"tmpl_impl") |
| 88 | // CHECK: [[NNARG2]] = !MDTemplateValueParameter(name: "lvr", type: [[INTLVR:![0-9]*]], value: i32* @glb) |
| 89 | // CHECK: [[INTLVR]] = !MDDerivedType(tag: DW_TAG_reference_type, baseType: [[INT]] |
| 90 | // CHECK: [[NNARG3]] = !MDTemplateValueParameter(name: "rvr", type: [[INTRVR:![0-9]*]], value: i32* @glb) |
| 91 | // CHECK: [[INTRVR]] = !MDDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: [[INT]] |
David Majnemer | 5db8b31 | 2013-08-25 22:13:27 +0000 | [diff] [blame] | 92 | |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 93 | // CHECK: !MDCompositeType(tag: DW_TAG_structure_type, name: "PaddingAtEndTemplate<&PaddedObj>" |
| 94 | // CHECK-SAME: templateParams: [[PTOARGS:![0-9]*]] |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 95 | // CHECK: [[PTOARGS]] = !{[[PTOARG1:![0-9]*]]} |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 96 | // CHECK: [[PTOARG1]] = !MDTemplateValueParameter(type: [[CONST_PADDINGATEND_PTR:![0-9]*]], value: %struct.PaddingAtEnd* @PaddedObj) |
| 97 | // CHECK: [[CONST_PADDINGATEND_PTR]] = !MDDerivedType(tag: DW_TAG_pointer_type, baseType: !"_ZTS12PaddingAtEnd", size: 64, align: 64) |
Manman Ren | 83369bf | 2013-08-29 23:19:58 +0000 | [diff] [blame] | 98 | |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 99 | // CHECK: !MDGlobalVariable(name: "tci", |
| 100 | // CHECK-SAME: type: !"[[TCNESTED]]" |
| 101 | // CHECK-SAME: variable: %"struct.TC<unsigned int, 2, &glb, &foo::e, &foo::f, &foo::g, 1, 2, 3>::nested"* @tci |
Manman Ren | 83369bf | 2013-08-29 23:19:58 +0000 | [diff] [blame] | 102 | |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 103 | // CHECK: !MDGlobalVariable(name: "tcn" |
| 104 | // CHECK-SAME: type: !"[[TCNT]]" |
| 105 | // CHECK-SAME: variable: %struct.TC* @tcn |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 106 | |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 107 | // CHECK: !MDGlobalVariable(name: "nn" |
| 108 | // CHECK-SAME: type: !"[[NNT]]" |
| 109 | // CHECK-SAME: variable: %struct.NN* @nn |
David Blaikie | f1e08ac | 2013-05-09 22:43:45 +0000 | [diff] [blame] | 110 | struct foo { |
David Blaikie | 9dfd243 | 2013-05-10 21:53:14 +0000 | [diff] [blame] | 111 | 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] | 112 | int e; |
| 113 | void f(); |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 114 | static void g(); |
David Blaikie | f1e08ac | 2013-05-09 22:43:45 +0000 | [diff] [blame] | 115 | }; |
| 116 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 117 | typedef int foo::*foo_mem; |
| 118 | |
| 119 | template<typename T, T, const int *x, foo_mem a, void (foo::*b)(), void (*f)(), int ...Is> |
David Blaikie | 8058833 | 2013-08-01 20:31:40 +0000 | [diff] [blame] | 120 | struct TC { |
| 121 | struct nested { |
| 122 | }; |
Devang Patel | 700a1cb | 2010-07-20 20:24:18 +0000 | [diff] [blame] | 123 | }; |
| 124 | |
David Blaikie | f1e08ac | 2013-05-09 22:43:45 +0000 | [diff] [blame] | 125 | int glb; |
David Blaikie | f8aa155 | 2013-05-13 06:57:50 +0000 | [diff] [blame] | 126 | void func(); |
David Blaikie | f1e08ac | 2013-05-09 22:43:45 +0000 | [diff] [blame] | 127 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 128 | TC<unsigned, 2, &glb, &foo::e, &foo::f, &foo::g, 1, 2, 3>::nested tci; |
| 129 | TC<int, -3, nullptr, nullptr, nullptr, nullptr> tcn; |
| 130 | |
David Blaikie | 35178dc | 2013-06-22 18:59:18 +0000 | [diff] [blame] | 131 | template<typename> |
| 132 | struct tmpl_impl { |
| 133 | }; |
David Blaikie | 776a364 | 2013-05-10 22:53:25 +0000 | [diff] [blame] | 134 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 135 | template <template <typename> class tmpl, int &lvr, int &&rvr> |
| 136 | struct NN { |
| 137 | }; |
| 138 | |
| 139 | NN<tmpl_impl, glb, glb> nn; |
David Majnemer | 87b1f6d | 2013-08-24 08:21:10 +0000 | [diff] [blame] | 140 | |
David Majnemer | 5db8b31 | 2013-08-25 22:13:27 +0000 | [diff] [blame] | 141 | struct PaddingAtEnd { |
| 142 | int i; |
| 143 | char c; |
| 144 | }; |
| 145 | |
| 146 | PaddingAtEnd PaddedObj = {}; |
| 147 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 148 | template <PaddingAtEnd *> |
David Majnemer | 5db8b31 | 2013-08-25 22:13:27 +0000 | [diff] [blame] | 149 | struct PaddingAtEndTemplate { |
| 150 | }; |
| 151 | |
| 152 | PaddingAtEndTemplate<&PaddedObj> PaddedTemplateObj; |