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