| 1 |
// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++20 | FileCheck %s |
| 2 |
|
| 3 |
// CHECK: @tci = dso_local global %"struct.TC<unsigned int, 2, &glb, &foo::e, &foo::f, &foo::g, 1, 2, 3>::nested" zeroinitializer, align 1, !dbg [[TCI:![0-9]+]] |
| 4 |
// CHECK: @tcn = dso_local global %struct.TC zeroinitializer, align 1, !dbg [[TCN:![0-9]+]] |
| 5 |
// CHECK: @nn = dso_local global %struct.NN zeroinitializer, align 1, !dbg [[NN:![0-9]+]] |
| 6 |
|
| 7 |
// CHECK: !DICompileUnit( |
| 8 |
|
| 9 |
struct foo { |
| 10 |
char pad[8]; // make the member pointer to 'e' a bit more interesting (nonzero) |
| 11 |
int e; |
| 12 |
void f(); |
| 13 |
static void g(); |
| 14 |
}; |
| 15 |
|
| 16 |
typedef int foo::*foo_mem; |
| 17 |
|
| 18 |
template<typename T, T, const int *x, foo_mem a, void (foo::*b)(), void (*f)(), int ...Is> |
| 19 |
struct TC { |
| 20 |
struct nested { |
| 21 |
}; |
| 22 |
}; |
| 23 |
|
| 24 |
int glb; |
| 25 |
void func(); |
| 26 |
|
| 27 |
// CHECK: [[TCI]] = !DIGlobalVariableExpression(var: [[TCIV:.*]], expr: !DIExpression()) |
| 28 |
// CHECK: [[TCIV]] = distinct !DIGlobalVariable(name: "tci", |
| 29 |
// CHECK-SAME: type: ![[TCNESTED:[0-9]+]] |
| 30 |
// CHECK: ![[TCNESTED]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "nested", |
| 31 |
// CHECK-SAME: scope: ![[TC:[0-9]+]], |
| 32 |
|
| 33 |
// CHECK: ![[TC]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "TC<unsigned int, 2U, &glb, &foo::e, &foo::f, &foo::g, 1, 2, 3>" |
| 34 |
// CHECK-SAME: templateParams: [[TCARGS:![0-9]*]] |
| 35 |
TC |
| 36 |
// CHECK: [[EMPTY:![0-9]*]] = !{} |
| 37 |
// CHECK: [[TCARGS]] = !{[[TCARG1:![0-9]*]], [[TCARG2:![0-9]*]], [[TCARG3:![0-9]*]], [[TCARG4:![0-9]*]], [[TCARG5:![0-9]*]], [[TCARG6:![0-9]*]], [[TCARG7:![0-9]*]]} |
| 38 |
// CHECK: [[TCARG1]] = !DITemplateTypeParameter(name: "T", type: [[UINT:![0-9]*]]) |
| 39 |
// CHECK: [[UINT:![0-9]*]] = !DIBasicType(name: "unsigned int" |
| 40 |
< unsigned, |
| 41 |
// CHECK: [[TCARG2]] = !DITemplateValueParameter(type: [[UINT]], value: i32 2) |
| 42 |
2, |
| 43 |
// CHECK: [[TCARG3]] = !DITemplateValueParameter(name: "x", type: [[CINTPTR:![0-9]*]], value: ptr @glb) |
| 44 |
// CHECK: [[CINTPTR]] = !DIDerivedType(tag: DW_TAG_pointer_type, {{.*}}baseType: [[CINT:![0-9]+]] |
| 45 |
// CHECK: [[CINT]] = !DIDerivedType(tag: DW_TAG_const_type, {{.*}}baseType: [[INT:![0-9]+]] |
| 46 |
// CHECK: [[INT]] = !DIBasicType(name: "int" |
| 47 |
&glb, |
| 48 |
// CHECK: [[TCARG4]] = !DITemplateValueParameter(name: "a", type: [[MEMINTPTR:![0-9]*]], value: i64 8) |
| 49 |
// CHECK: [[MEMINTPTR]] = !DIDerivedType(tag: DW_TAG_ptr_to_member_type, {{.*}}baseType: [[INT]], {{.*}}extraData: ![[FOO:[0-9]+]]) |
| 50 |
// |
| 51 |
// We could just emit a declaration of 'foo' here, rather than the entire |
| 52 |
// definition (same goes for any time we emit a member (function or data) |
| 53 |
// pointer type) |
| 54 |
// CHECK: [[FOO]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", {{.*}}identifier: "_ZTS3foo") |
| 55 |
// CHECK: !DISubprogram(name: "f", linkageName: "_ZN3foo1fEv", {{.*}}type: [[FTYPE:![0-9]*]] |
| 56 |
// |
| 57 |
// Currently Clang emits the pointer-to-member-function value, but LLVM doesn't |
| 58 |
// use it (GCC doesn't emit a value for pointers to member functions either - so |
| 59 |
// it's not clear what, if any, format would be acceptable to GDB) |
| 60 |
// |
| 61 |
// CHECK: [[FTYPE:![0-9]*]] = !DISubroutineType(types: [[FARGS:![0-9]*]]) |
| 62 |
// CHECK: [[FARGS]] = !{null, [[FARG1:![0-9]*]]} |
| 63 |
// CHECK: [[FARG1]] = !DIDerivedType(tag: DW_TAG_pointer_type, |
| 64 |
// CHECK-SAME: baseType: ![[FOO]] |
| 65 |
// CHECK-NOT: line: |
| 66 |
// CHECK-SAME: size: 64 |
| 67 |
// CHECK-NOT: offset: 0 |
| 68 |
// CHECK-SAME: DIFlagArtificial |
| 69 |
// CHECK: [[FUNTYPE:![0-9]*]] = !DISubroutineType(types: [[FUNARGS:![0-9]*]]) |
| 70 |
// CHECK: [[FUNARGS]] = !{null} |
| 71 |
&foo::e, |
| 72 |
// CHECK: [[TCARG5]] = !DITemplateValueParameter(name: "b", type: [[MEMFUNPTR:![0-9]*]], value: { i64, i64 } { i64 ptrtoint (ptr @_ZN3foo1fEv to i64), i64 0 }) |
| 73 |
// CHECK: [[MEMFUNPTR]] = !DIDerivedType(tag: DW_TAG_ptr_to_member_type, {{.*}}baseType: [[FTYPE]], {{.*}}extraData: ![[FOO]]) |
| 74 |
&foo::f, |
| 75 |
// CHECK: [[TCARG6]] = !DITemplateValueParameter(name: "f", type: [[FUNPTR:![0-9]*]], value: ptr @_ZN3foo1gEv) |
| 76 |
// CHECK: [[FUNPTR]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: [[FUNTYPE]] |
| 77 |
&foo::g, |
| 78 |
// CHECK: [[TCARG7]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_parameter_pack, name: "Is", value: [[TCARG7_VALS:![0-9]*]]) |
| 79 |
// CHECK: [[TCARG7_VALS]] = !{[[TCARG7_1:![0-9]*]], [[TCARG7_2:![0-9]*]], [[TCARG7_3:![0-9]*]]} |
| 80 |
// CHECK: [[TCARG7_1]] = !DITemplateValueParameter(type: [[INT]], value: i32 1) |
| 81 |
1, |
| 82 |
// CHECK: [[TCARG7_2]] = !DITemplateValueParameter(type: [[INT]], value: i32 2) |
| 83 |
2, |
| 84 |
// CHECK: [[TCARG7_3]] = !DITemplateValueParameter(type: [[INT]], value: i32 3) |
| 85 |
3>::nested tci; |
| 86 |
|
| 87 |
// CHECK: [[TCN]] = !DIGlobalVariableExpression(var: [[TCNV:.*]], expr: !DIExpression()) |
| 88 |
// CHECK: [[TCNV]] = distinct !DIGlobalVariable(name: "tcn" |
| 89 |
// CHECK-SAME: type: ![[TCNT:[0-9]+]] |
| 90 |
TC |
| 91 |
// CHECK: ![[TCNT]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "TC<int, -3, nullptr, nullptr, nullptr, nullptr>" |
| 92 |
// CHECK-SAME: templateParams: [[TCNARGS:![0-9]*]] |
| 93 |
// CHECK: [[TCNARGS]] = !{[[TCNARG1:![0-9]*]], [[TCNARG2:![0-9]*]], [[TCNARG3:![0-9]*]], [[TCNARG4:![0-9]*]], [[TCNARG5:![0-9]*]], [[TCNARG6:![0-9]*]], [[TCNARG7:![0-9]*]]} |
| 94 |
// CHECK: [[TCNARG1]] = !DITemplateTypeParameter(name: "T", type: [[INT]]) |
| 95 |
<int, |
| 96 |
// CHECK: [[TCNARG2]] = !DITemplateValueParameter(type: [[INT]], value: i32 -3) |
| 97 |
-3, |
| 98 |
// CHECK: [[TCNARG3]] = !DITemplateValueParameter(name: "x", type: [[CINTPTR]], value: i8 0) |
| 99 |
nullptr, |
| 100 |
|
| 101 |
// The interesting null pointer: -1 for member data pointers (since they are |
| 102 |
// just an offset in an object, they can be zero and non-null for the first |
| 103 |
// member) |
| 104 |
|
| 105 |
// CHECK: [[TCNARG4]] = !DITemplateValueParameter(name: "a", type: [[MEMINTPTR]], value: i64 -1) |
| 106 |
nullptr, |
| 107 |
// |
| 108 |
// In some future iteration we could possibly emit the value of a null member |
| 109 |
// function pointer as '{ i64, i64 } zeroinitializer' as it may be handled |
| 110 |
// naturally from the LLVM CodeGen side once we decide how to handle non-null |
| 111 |
// member function pointers. For now, it's simpler just to emit the 'i8 0'. |
| 112 |
// |
| 113 |
// CHECK: [[TCNARG5]] = !DITemplateValueParameter(name: "b", type: [[MEMFUNPTR]], value: i8 0) |
| 114 |
nullptr, |
| 115 |
// CHECK: [[TCNARG6]] = !DITemplateValueParameter(name: "f", type: [[FUNPTR]], value: i8 0) |
| 116 |
nullptr |
| 117 |
// CHECK: [[TCNARG7]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_parameter_pack, name: "Is", value: [[EMPTY]]) |
| 118 |
> tcn; |
| 119 |
|
| 120 |
template<typename> |
| 121 |
struct tmpl_impl { |
| 122 |
}; |
| 123 |
|
| 124 |
template <template <typename> class tmpl, int &lvr> |
| 125 |
struct NN { |
| 126 |
}; |
| 127 |
|
| 128 |
// CHECK: [[NN]] = !DIGlobalVariableExpression(var: [[NNV:.*]], expr: !DIExpression()) |
| 129 |
// CHECK: [[NNV]] = distinct !DIGlobalVariable(name: "nn" |
| 130 |
// CHECK-SAME: type: ![[NNT:[0-9]+]] |
| 131 |
|
| 132 |
// CHECK: ![[NNT]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "NN<tmpl_impl, glb>", |
| 133 |
// CHECK-SAME: templateParams: [[NNARGS:![0-9]*]] |
| 134 |
// CHECK-SAME: identifier: |
| 135 |
// CHECK: [[NNARGS]] = !{[[NNARG1:![0-9]*]], [[NNARG2:![0-9]*]]} |
| 136 |
// CHECK: [[NNARG1]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_template_param, name: "tmpl", value: !"tmpl_impl") |
| 137 |
// CHECK: [[NNARG2]] = !DITemplateValueParameter(name: "lvr", type: [[INTLVR:![0-9]*]], value: ptr @glb) |
| 138 |
// CHECK: [[INTLVR]] = !DIDerivedType(tag: DW_TAG_reference_type, baseType: [[INT]] |
| 139 |
NN<tmpl_impl, glb> nn; |
| 140 |
|
| 141 |
// CHECK: ![[PADDINGATEND:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "PaddingAtEnd", |
| 142 |
struct PaddingAtEnd { |
| 143 |
int i; |
| 144 |
char c; |
| 145 |
}; |
| 146 |
|
| 147 |
PaddingAtEnd PaddedObj = {}; |
| 148 |
|
| 149 |
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "PaddingAtEndTemplate<&PaddedObj>" |
| 150 |
// CHECK-SAME: templateParams: [[PTOARGS:![0-9]*]] |
| 151 |
// CHECK: [[PTOARGS]] = !{[[PTOARG1:![0-9]*]]} |
| 152 |
// CHECK: [[PTOARG1]] = !DITemplateValueParameter(type: [[CONST_PADDINGATEND_PTR:![0-9]*]], value: ptr @PaddedObj) |
| 153 |
// CHECK: [[CONST_PADDINGATEND_PTR]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[PADDINGATEND]], size: 64) |
| 154 |
template <PaddingAtEnd *> |
| 155 |
struct PaddingAtEndTemplate { |
| 156 |
}; |
| 157 |
|
| 158 |
PaddingAtEndTemplate<&PaddedObj> PaddedTemplateObj; |
| 159 |
|
| 160 |
struct ClassTemplateArg { |
| 161 |
int a; |
| 162 |
float f; |
| 163 |
}; |
| 164 |
template<ClassTemplateArg A> struct ClassTemplateArgTemplate { |
| 165 |
static constexpr const ClassTemplateArg &Arg = A; |
| 166 |
}; |
| 167 |
|
| 168 |
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ClassTemplateArgTemplate<ClassTemplateArg{1, 2.000000e+00}>", {{.*}}, templateParams: ![[CLASS_TEMP_ARGS:[0-9]*]], |
| 169 |
// CHECK: ![[CLASS_TEMP_ARG_CONST_REF_TYPE:[0-9]*]] = !DIDerivedType(tag: DW_TAG_reference_type, baseType: ![[CLASS_TEMP_ARG_CONST_TYPE:[0-9]*]], |
| 170 |
// CHECK: ![[CLASS_TEMP_ARG_CONST_TYPE]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[CLASS_TEMP_ARG_TYPE:[0-9]*]]) |
| 171 |
// CHECK: ![[CLASS_TEMP_ARG_TYPE]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "ClassTemplateArg", |
| 172 |
// CHECK: ![[CLASS_TEMP_ARGS]] = !{![[CLASS_TEMP_ARG:[0-9]*]]} |
| 173 |
// CHECK: ![[CLASS_TEMP_ARG]] = !DITemplateValueParameter(name: "A", type: ![[CLASS_TEMP_ARG_TYPE]], value: %{{[^ *]+}} { i32 1, float 2.000000e+00 }) |
| 174 |
ClassTemplateArgTemplate<ClassTemplateArg{1, 2.0f}> ClassTemplateArgObj; |
| 175 |
|
| 176 |
template<const ClassTemplateArg&> struct ClassTemplateArgRefTemplate {}; |
| 177 |
ClassTemplateArgRefTemplate<ClassTemplateArgObj.Arg> ClassTemplateArgRefObj; |
| 178 |
|
| 179 |
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ClassTemplateArgRefTemplate<<template param ClassTemplateArg{1, 2.000000e+00}> >", {{.*}}, templateParams: ![[CLASS_TEMP_REF_ARGS:[0-9]*]], |
| 180 |
// CHECK: ![[CLASS_TEMP_REF_ARGS]] = !{![[CLASS_TEMP_REF_ARG:[0-9]*]]} |
| 181 |
// CHECK: ![[CLASS_TEMP_REF_ARG]] = !DITemplateValueParameter(type: ![[CLASS_TEMP_ARG_CONST_REF_TYPE]], value: ptr @_ZTAXtl16ClassTemplateArgLi1ELf40000000EEE) |
| 182 |
|
| 183 |
inline namespace inl { |
| 184 |
struct t1 { }; |
| 185 |
} |
| 186 |
template<typename T> struct ClassTemplateInlineNamespaceArg { |
| 187 |
}; |
| 188 |
ClassTemplateInlineNamespaceArg<inl::t1> ClassTemplateInlineNamespaceArgObj; |
| 189 |
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ClassTemplateInlineNamespaceArg<inl::t1>", |
| 190 |
|
| 191 |
namespace IndirectDefaultArgument { |
| 192 |
template<typename T1, typename T2 = int> |
| 193 |
struct t1 { }; |
| 194 |
template<typename T> |
| 195 |
void f1() { |
| 196 |
} |
| 197 |
template void f1<t1<int>>(); |
| 198 |
// CHECK: !DISubprogram(name: "f1<IndirectDefaultArgument::t1<int, int> >", |
| 199 |
} // namespace IndirectDefaultArgument |
| 200 |
|
| 201 |
namespace EmptyTrailingPack { |
| 202 |
template<typename T> |
| 203 |
struct t1 { }; |
| 204 |
template<typename T, typename ...Ts> |
| 205 |
void f1() { |
| 206 |
} |
| 207 |
template void f1<t1<int>>(); |
| 208 |
// CHECK: !DISubprogram(name: "f1<EmptyTrailingPack::t1<int> >", |
| 209 |
} // namespace EmptyTrailingPack |
| 210 |
|
| 211 |
namespace EmptyInnerPack { |
| 212 |
template<typename ...Ts, typename T = int> |
| 213 |
void f1() { |
| 214 |
} |
| 215 |
template void f1<>(); |
| 216 |
// CHECK: !DISubprogram(name: "f1<int>", |
| 217 |
} // namespace EmptyInnerPack |
| 218 |
|
| 219 |
namespace RawFuncQual { |
| 220 |
struct t1; // use this to ensure the type parameter doesn't shift due to other test cases in this file |
| 221 |
template<typename T1, typename T2, typename T3, typename T4> |
| 222 |
void f1() { } |
| 223 |
template void f1<t1 () volatile, t1 () const volatile, t1 () &, t1 () &&>(); |
| 224 |
// CHECK: !DISubprogram(name: "f1<RawFuncQual::t1 () volatile, RawFuncQual::t1 () const volatile, RawFuncQual::t1 () &, RawFuncQual::t1 () &&>", |
| 225 |
// CHECK-SAME: templateParams: ![[RAW_FUNC_QUAL_ARGS:[0-9]*]] |
| 226 |
|
| 227 |
// CHECK: ![[RAW_FUNC_QUAL_ARGS]] = !{![[RAW_FUNC_QUAL_T1:[0-9]*]], ![[RAW_FUNC_QUAL_T2:[0-9]*]], ![[RAW_FUNC_QUAL_T3:[0-9]*]], ![[RAW_FUNC_QUAL_T4:[0-9]*]]} |
| 228 |
// CHECK: ![[RAW_FUNC_QUAL_T1]] = !DITemplateTypeParameter(name: "T1", type: ![[RAW_FUNC_QUAL_VOL:[0-9]*]]) |
| 229 |
// CHECK: ![[RAW_FUNC_QUAL_VOL]] = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: ![[RAW_FUNC_QUAL_TYPE:[0-9]*]]) |
| 230 |
// CHECK: ![[RAW_FUNC_QUAL_TYPE]] = !DISubroutineType(types: ![[RAW_FUNC_QUAL_LIST:[0-9]*]] |
| 231 |
// CHECK: ![[RAW_FUNC_QUAL_LIST]] = !{![[RAW_FUNC_QUAL_STRUCT:[0-9]*]]} |
| 232 |
// CHECK: ![[RAW_FUNC_QUAL_STRUCT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "t1" |
| 233 |
// CHECK: ![[RAW_FUNC_QUAL_T2]] = !DITemplateTypeParameter(name: "T2", type: ![[RAW_FUNC_QUAL_CNST:[0-9]*]]) |
| 234 |
// CHECK: ![[RAW_FUNC_QUAL_CNST]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[RAW_FUNC_QUAL_TYPE:[0-9]*]]) |
| 235 |
// CHECK: ![[RAW_FUNC_QUAL_T3]] = !DITemplateTypeParameter(name: "T3", type: ![[RAW_FUNC_QUAL_REF:[0-9]*]]) |
| 236 |
// CHECK: ![[RAW_FUNC_QUAL_REF]] = !DISubroutineType(flags: DIFlagLValueReference, types: ![[RAW_FUNC_QUAL_LIST]]) |
| 237 |
// CHECK: ![[RAW_FUNC_QUAL_T4]] = !DITemplateTypeParameter(name: "T4", type: ![[RAW_FUNC_QUAL_REF_REF:[0-9]*]]) |
| 238 |
// CHECK: ![[RAW_FUNC_QUAL_REF_REF]] = !DISubroutineType(flags: DIFlagRValueReference, types: ![[RAW_FUNC_QUAL_LIST]]) |
| 239 |
|
| 240 |
} // namespace RawFuncQual |
| 241 |
|
| 242 |
namespace Nullptr_t { |
| 243 |
template <typename T> |
| 244 |
void f1() {} |
| 245 |
template void f1<decltype(nullptr)>(); |
| 246 |
// CHECK: !DISubprogram(name: "f1<std::nullptr_t>", |
| 247 |
} // namespace Nullptr_t |
| 248 |
|
| 249 |
namespace TemplateTemplateParamInlineNamespace { |
| 250 |
inline namespace inl { |
| 251 |
template<typename> |
| 252 |
struct t1 { }; |
| 253 |
} // namespace inl |
| 254 |
template<template<typename> class> void f1() { } |
| 255 |
template void f1<t1>(); |
| 256 |
// CHECK: !DISubprogram(name: "f1<TemplateTemplateParamInlineNamespace::inl::t1>", |
| 257 |
// CHECK-SAME: templateParams: ![[TEMP_TEMP_INL_ARGS:[0-9]*]] |
| 258 |
// CHECK: ![[TEMP_TEMP_INL_ARGS]] = !{![[TEMP_TEMP_INL_ARGS_T:[0-9]*]]} |
| 259 |
// CHECK: ![[TEMP_TEMP_INL_ARGS_T]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_template_param, value: !"TemplateTemplateParamInlineNamespace::inl::t1") |
| 260 |
} // namespace TemplateTemplateParamInlineNamespace |
| 261 |
|
| 262 |
namespace NoPreferredNames { |
| 263 |
template <typename T> struct t1; |
| 264 |
using t1i = t1<int>; |
| 265 |
template <typename T> |
| 266 |
struct __attribute__((__preferred_name__(t1i))) t1 {}; |
| 267 |
template <typename T> |
| 268 |
void f1() {} |
| 269 |
template void f1<t1<int>>(); |
| 270 |
// CHECK: !DISubprogram(name: "f1<NoPreferredNames::t1<int> >", |
| 271 |
|
| 272 |
} // namespace NoPreferredNames |