r295794 - Fix assertion failure when generating debug information for a variable

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 21 16:13:14 PST 2017


Author: rsmith
Date: Tue Feb 21 18:13:14 2017
New Revision: 295794

URL: http://llvm.org/viewvc/llvm-project?rev=295794&view=rev
Log:
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

Added:
    cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=295794&r1=295793&r2=295794&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb 21 18:13:14 2017
@@ -2475,8 +2475,9 @@ static QualType UnwrapTypeForDebugInfo(Q
     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;

Added: cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp?rev=295794&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp Tue Feb 21 18:13:14 2017
@@ -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);




More information about the cfe-commits mailing list