]> granicus.if.org Git - clang/commitdiff
Fix assertion failure when generating debug information for a variable
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 22 Feb 2017 00:13:14 +0000 (00:13 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 22 Feb 2017 00:13:14 +0000 (00:13 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295794 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGenCXX/debug-info-template-deduction-guide.cpp [new file with mode: 0644]

index 252ee8d71d9846f6aed2181567b9a155ca507c51..acfe0a4d7d0bff371fda314fad9cc9b81c5c4bcc 100644 (file)
@@ -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/test/CodeGenCXX/debug-info-template-deduction-guide.cpp b/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
new file mode 100644 (file)
index 0000000..26eb215
--- /dev/null
@@ -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);