summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-02-22 00:13:14 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-02-22 00:13:14 +0000
commita0abc4291178d97662f9b346863f692ecc72c803 (patch)
treed9c13d9a580c528d81fa8f2be43dde0d619b6e00
parent98eafd67d5657d4d8f28996b32a24235e4396dc7 (diff)
downloadbcm5719-llvm-a0abc4291178d97662f9b346863f692ecc72c803.tar.gz
bcm5719-llvm-a0abc4291178d97662f9b346863f692ecc72c803.zip
Fix assertion failure when generating debug information for a variable
declaration declared using class template argument deduction. Patch by Eric Fiselier (who is busy and asked me to commit this on his behalf)! Differential Revision: https://reviews.llvm.org/D30082 llvm-svn: 295794
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp5
-rw-r--r--clang/test/CodeGenCXX/debug-info-template-deduction-guide.cpp17
2 files changed, 20 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 252ee8d71d9..acfe0a4d7d0 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2475,8 +2475,9 @@ static QualType UnwrapTypeForDebugInfo(QualType T, const ASTContext &C) {
case Type::SubstTemplateTypeParm:
T = cast<SubstTemplateTypeParmType>(T)->getReplacementType();
break;
- case Type::Auto: {
- QualType DT = cast<AutoType>(T)->getDeducedType();
+ case Type::Auto:
+ case Type::DeducedTemplateSpecialization: {
+ QualType DT = cast<DeducedType>(T)->getDeducedType();
assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
T = DT;
break;
diff --git a/clang/test/CodeGenCXX/debug-info-template-deduction-guide.cpp b/clang/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
new file mode 100644
index 00000000000..26eb2156e62
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s
+
+// Verify that we don't crash when emitting debug information for objects
+// created from a deduced template specialization.
+
+template <class T>
+struct S {
+ S(T) {}
+};
+
+// CHECK: !DIGlobalVariable(name: "s1"
+// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]]
+// CHECK: !DIGlobalVariable(name: "s2"
+// CHECK-SAME: type: [[TYPE_NUM]]
+// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S<int>",
+S s1(42);
+S<int> s2(42);
OpenPOWER on IntegriCloud