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 \ 2 // RUN: | FileCheck %s 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 9 10 template <typename... T> 11 void f1() {} 12 template <typename T, T V> 13 void f2() {} 14 template <typename... T> 15 struct t1 {}; 16 extern int x; 17 int x; 18 struct t2 { 19 template <typename T = float> 20 operator t1<int>() { __builtin_unreachable(); } 21 }; 22 template <template <typename...> class T> 23 void f3() {} 24 namespace { 25 enum LocalEnum { LocalEnum1 }; 26 } 27 template<typename T, T ... ts> 28 struct t3 { }; 29 struct t4 { 30 t3<LocalEnum, LocalEnum1> m1; 31 }; 32 33 t4 v1; 34 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "t3<(anonymous namespace)::LocalEnum, (anonymous namespace)::LocalEnum1>" 35 void f() { 36 // Basic examples of simplifiable/rebuildable names 37 f1<>(); 38 // CHECK: !DISubprogram(name: "_STNf1|<>", 39 // SIMPLE: !DISubprogram(name: "f1", 40 // FULL: !DISubprogram(name: "f1<>", 41 f1<int>(); 42 // CHECK: !DISubprogram(name: "_STNf1|<int>", 43 f1<void()>(); 44 // CHECK: !DISubprogram(name: "_STNf1|<void ()>", 45 f2<int, 42>(); 46 // CHECK: !DISubprogram(name: "_STNf2|<int, 42>", 47 48 // Check that even though the nested name can't be rebuilt, it'll carry its 49 // full name and the outer name can be rebuilt from that. 50 f1<t1<void() noexcept>>(); 51 // CHECK: !DISubprogram(name: "_STNf1|<t1<void () noexcept> >", 52 53 // Vector array types are encoded in DWARF but the decoding in llvm-dwarfdump 54 // isn't implemented yet. 55 f1<__attribute__((__vector_size__((sizeof(int) * 2)))) int>(); 56 // CHECK: !DISubprogram(name: "f1<__attribute__((__vector_size__(2 * sizeof(int)))) int>", 57 58 // noexcept is part of function types in C++17 onwards, but not encoded in 59 // DWARF 60 f1<void() noexcept>(); 61 // CHECK: !DISubprogram(name: "f1<void () noexcept>", 62 63 // Unnamed entities (lambdas, structs/classes, enums) can't be fully rebuilt 64 // since we don't emit the column number. Also lambdas and unnamed classes are 65 // ambiguous with each other - there's no DWARF that designates a lambda as 66 // anything other than another unnamed class/struct. 67 auto Lambda = [] {}; 68 f1<decltype(Lambda)>(); 69 // CHECK: !DISubprogram(name: "f1<(lambda at {{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 2]]:17)>", 70 f1<t1<t1<decltype(Lambda)>>>(); 71 // CHECK: !DISubprogram(name: "f1<t1<t1<(lambda at {{.*}}> > >", 72 struct { 73 } unnamed_struct; 74 f1<decltype(unnamed_struct)>(); 75 // CHECK: !DISubprogram(name: "f1<(unnamed struct at {{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 3]]:3)>", 76 f1<void (decltype(unnamed_struct))>(); 77 // CHECK: !DISubprogram(name: "f1<void ((unnamed struct at {{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 5]]:3))>", 78 enum {} unnamed_enum; 79 f1<decltype(unnamed_enum)>(); 80 // CHECK: !DISubprogram(name: "f1<(unnamed enum at {{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 2]]:3)>", 81 82 // Declarations can't readily be reversed as the value in the DWARF only 83 // contains the address of the value - we'd have to do symbol lookup to find 84 // the name of that value (& rely on it not having been stripped out, etc). 85 f2<int *, &x>(); 86 // CHECK: !DISubprogram(name: "f2<int *, &x>", 87 88 // We could probably handle \/ this case, but since it's a small subset of 89 // pointer typed non-type-template parameters which can't be handled it 90 // doesn't seem high priority. 91 f2<decltype(nullptr), nullptr>(); 92 // CHECK: !DISubprogram(name: "f2<std::nullptr_t, nullptr>", 93 94 // These larger constants are encoded as data blocks which makes them a bit 95 // harder to re-render. I think they might be missing sign information, or at 96 // maybe it's just a question of doing APInt things to render such large 97 // values. Punting on this for now. 98 f2<__int128, ((__int128)9223372036854775807) * 2>(); 99 // CHECK: !DISubprogram(name: "f2<__int128, (__int128)18446744073709551614>", 100 101 t2().operator t1<int>(); 102 // FIXME: This should be something like "operator t1<int><float>" 103 // CHECK: !DISubprogram(name: "operator t1<float>", 104 105 // Function pointer non-type-template parameters currently don't get any DWARF 106 // value (GCC doesn't provide one either) and even if there was a value, if 107 // it's like variable/pointer non-type template parameters, it couldn't be 108 // rebuilt anyway (see the note above for details on that) so we don't have to 109 // worry about seeing conversion operators as parameters to other templates. 110 111 f3<t1>(); 112 // CHECK: !DISubprogram(name: "_STNf3|<t1>", 113 114 f1<_BitInt(3)>(); 115 // CHECK: !DISubprogram(name: "f1<_BitInt(3)>", 116 117 f1<const unsigned _BitInt(5)>(); 118 // CHECK: !DISubprogram(name: "f1<const unsigned _BitInt(5)>", 119 } 120