aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Buch <michaelbuch12@gmail.com>2022-12-16 11:22:15 +0000
committerMichael Buch <michaelbuch12@gmail.com>2022-12-16 11:38:54 +0000
commit2c22cfd4c95606adec311dece051e95e86e3f0f3 (patch)
treef8191da7a6c1c47c901fde7bda499ce0422f0f8d
parent2dff41c320fcf6230bea68568b14ca101c96d187 (diff)
downloadllvm-2c22cfd4c95606adec311dece051e95e86e3f0f3.zip
llvm-2c22cfd4c95606adec311dece051e95e86e3f0f3.tar.gz
llvm-2c22cfd4c95606adec311dece051e95e86e3f0f3.tar.bz2
[clang][DebugInfo] Add DW_AT_default_value support for template template parameters
After this patch, in the following snippet: ``` template <typename T> Foo {}; template <template <typename T> class CT = Foo> Bar {}; Bar<> b; ``` The debug-info entry for the `CT` template parameter will have a `DW_AT_default_value (true)` attached to it. Differential Revision: https://reviews.llvm.org/D139989
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp2
-rw-r--r--clang/test/CodeGenCXX/debug-info-template-parameter.cpp20
2 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 7bfb63d..382b7f3 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2091,7 +2091,7 @@ CGDebugInfo::CollectTemplateParams(Optional<TemplateArgs> OArgs,
TA.getAsTemplate().getAsTemplateDecl()->printQualifiedName(
OS, getPrintingPolicy());
TemplateParams.push_back(DBuilder.createTemplateTemplateParameter(
- TheCU, Name, nullptr, OS.str()));
+ TheCU, Name, nullptr, OS.str(), defaultParameter));
break;
}
case TemplateArgument::Pack:
diff --git a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
index 4c8d1eb..360cc1f 100644
--- a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
+++ b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
@@ -23,17 +23,37 @@
// CXX17: [[THIRD]] = !DITemplateValueParameter(name: "b", type: !{{[0-9]*}}, defaulted: true, value: i1 true)
// CHECK: [[FIFTH]] = !DITemplateTypeParameter(name: "d", type: !{{[0-9]*}}, defaulted: true)
+// CHECK: DILocalVariable(name: "b1", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]]
+// CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: ![[B1_TYPE:[0-9]+]]
+// CHECK: [[B1_TYPE]] = !{![[FIRST:[0-9]+]]}
+// CHECK: [[FIRST]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_template_param, name: "CT", value: !"qux")
+
+// CHECK: DILocalVariable(name: "b2", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]]
+// CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: ![[B2_TYPE:[0-9]+]]
+// CHECK: [[B2_TYPE]] = !{![[FIRST:[0-9]+]]}
+// CHECK: [[FIRST]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_template_param, name: "CT", defaulted: true, value: !"bar")
+
template <typename T>
class bar {
};
+template <typename T>
+class qux {
+};
+
template <typename T = char, int i = 3, bool b = true, int x = sizeof(T),
typename d = bar<T>>
class foo {
};
+template <template <typename T> class CT = bar>
+class baz {
+};
+
int main() {
foo<int, 6, false, 3, double> f1;
foo<> f2;
+ baz<qux> b1;
+ baz<> b2;
return 0;
}