1 // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown_unknown -std=c++17 %s -o - -w -debug-info-kind=limited -gsimple-template-names=mangled \
3 // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown_unknown -std=c++17 %s -o - -w -debug-info-kind=limited -gsimple-template-names=simple \
4 // RUN: | FileCheck %s --implicit-check-not=_STN --check-prefix=SIMPLE
5 // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown_unknown -std=c++17 %s -o - -w -debug-info-kind=limited \
6 // RUN: | FileCheck %s --implicit-check-not=_STN --check-prefix=FULL
7 // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown_unknown -std=c++17 %s -o - -w -debug-info-kind=line-tables-only -gsimple-template-names=mangled -fdebug-info-for-profiling \
8 // RUN: | FileCheck %s --implicit-check-not=_STN --check-prefix=FULL
10 template <typename
... T
>
12 template <typename T
, T V
>
14 template <typename
... T
>
19 template <typename T
= float>
20 operator t1
<int>() { __builtin_unreachable(); }
22 template <template <typename
...> class T
>
25 enum LocalEnum
{ LocalEnum1
};
27 template<typename T
, T
... ts
>
30 t3
<LocalEnum
, LocalEnum1
> m1
;
34 enum { UnnamedEnum1
};
35 template<decltype(UnnamedEnum1
)>
38 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "t3<(anonymous namespace)::LocalEnum, ((anonymous namespace)::LocalEnum)0>"
40 // Basic examples of simplifiable/rebuildable names
42 // CHECK: !DISubprogram(name: "_STN|f1|<>",
43 // SIMPLE: !DISubprogram(name: "f1",
44 // FULL: !DISubprogram(name: "f1<>",
46 // CHECK: !DISubprogram(name: "_STN|f1|<int>",
48 // CHECK: !DISubprogram(name: "_STN|f1|<void ()>",
50 // CHECK: !DISubprogram(name: "_STN|f2|<int, 42>",
52 // Check that even though the nested name can't be rebuilt, it'll carry its
53 // full name and the outer name can be rebuilt from that.
54 f1
<t1
<void() noexcept
>>();
55 // CHECK: !DISubprogram(name: "_STN|f1|<t1<void () noexcept> >",
57 // Vector array types are encoded in DWARF but the decoding in llvm-dwarfdump
58 // isn't implemented yet.
59 f1
<__attribute__((__vector_size__((sizeof(int) * 2)))) int>();
60 // CHECK: !DISubprogram(name: "f1<__attribute__((__vector_size__(2 * sizeof(int)))) int>",
62 // noexcept is part of function types in C++17 onwards, but not encoded in
64 f1
<void() noexcept
>();
65 // CHECK: !DISubprogram(name: "f1<void () noexcept>",
67 // Unnamed entities (lambdas, structs/classes, enums) can't be fully rebuilt
68 // since we don't emit the column number. Also lambdas and unnamed classes are
69 // ambiguous with each other - there's no DWARF that designates a lambda as
70 // anything other than another unnamed class/struct.
72 f1
<decltype(Lambda
)>();
73 // CHECK: !DISubprogram(name: "f1<(lambda at {{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 2]]:17)>",
74 f1
<t1
<t1
<decltype(Lambda
)>>>();
75 // CHECK: !DISubprogram(name: "f1<t1<t1<(lambda at {{.*}}> > >",
78 f1
<decltype(unnamed_struct
)>();
79 // CHECK: !DISubprogram(name: "f1<(unnamed struct at {{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 3]]:3)>",
80 f1
<void (decltype(unnamed_struct
))>();
81 // CHECK: !DISubprogram(name: "f1<void ((unnamed struct at {{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 5]]:3))>",
83 f1
<decltype(unnamed_enum
)>();
84 // CHECK: !DISubprogram(name: "f1<(unnamed enum at {{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 2]]:3)>",
86 // Declarations can't readily be reversed as the value in the DWARF only
87 // contains the address of the value - we'd have to do symbol lookup to find
88 // the name of that value (& rely on it not having been stripped out, etc).
90 // CHECK: !DISubprogram(name: "f2<int *, &x>",
92 // We could probably handle \/ this case, but since it's a small subset of
93 // pointer typed non-type-template parameters which can't be handled it
94 // doesn't seem high priority.
95 f2
<decltype(nullptr), nullptr>();
96 // CHECK: !DISubprogram(name: "f2<std::nullptr_t, nullptr>",
98 // These larger constants are encoded as data blocks which makes them a bit
99 // harder to re-render. I think they might be missing sign information, or at
100 // maybe it's just a question of doing APInt things to render such large
101 // values. Punting on this for now.
102 f2
<__int128
, ((__int128
)9223372036854775807) * 2>();
103 // CHECK: !DISubprogram(name: "f2<__int128, (__int128)18446744073709551614>",
105 t2().operator t1
<int>();
106 // FIXME: This should be something like "operator t1<int><float>"
107 // CHECK: !DISubprogram(name: "operator t1<float>",
109 // Function pointer non-type-template parameters currently don't get any DWARF
110 // value (GCC doesn't provide one either) and even if there was a value, if
111 // it's like variable/pointer non-type template parameters, it couldn't be
112 // rebuilt anyway (see the note above for details on that) so we don't have to
113 // worry about seeing conversion operators as parameters to other templates.
116 // CHECK: !DISubprogram(name: "_STN|f3|<t1>",
119 // CHECK: !DISubprogram(name: "f1<_BitInt(3)>",
121 f1
<const unsigned _BitInt(5)>();
122 // CHECK: !DISubprogram(name: "f1<const unsigned _BitInt(5)>",
124 // Add a parameter just so this differs from other attributed function types
125 // that don't mangle differently.
126 int fnrt() __attribute__((noreturn
));
127 f1
<decltype(fnrt
)>();
128 // CHECK: !DISubprogram(name: "f1<int () __attribute__((noreturn))>",
131 // CHECK: !DISubprogram(name: "f4<((unnamed enum at {{.*}}))0>"