[PATCH] D25793: Don't crash generating debug info for VLA in function prototype.

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 19 15:26:01 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL284652: Don't crash generating debug info for VLA in function prototype. (authored by efriedma).

Changed prior to commit:
  https://reviews.llvm.org/D25793?vs=75219&id=75243#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25793

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-vla.cpp


Index: cfe/trunk/test/CodeGenCXX/debug-info-vla.cpp
===================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-vla.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-vla.cpp
@@ -1,14 +1,22 @@
-// RUN: %clang -target x86_64-unknown-unknown -fverbose-asm -g -O0 -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -target x86_64-unknown-unknown -fverbose-asm -g -O0 -S -emit-llvm %s -o - -std=c++11 | FileCheck %s
 
 
 void f(int m) {
   int x[3][m];
 }
 
+int (*fp)(int[][*]) = nullptr;
+
+// CHECK: !DICompositeType(tag: DW_TAG_array_type,
+// CHECK-NOT:                               size:
+// CHECK-SAME:                              align: 32
+// CHECK-SAME:                              elements: [[ELEM_TYPE:![0-9]+]]
+// CHECK: [[ELEM_TYPE]] = !{[[NOCOUNT:.*]]}
+// CHECK: [[NOCOUNT]] = !DISubrange(count: -1)
+//
 // CHECK: !DICompositeType(tag: DW_TAG_array_type,
 // CHECK-NOT:                               size:
 // CHECK-SAME:                              align: 32
 // CHECK-SAME:                              elements: [[ELEM_TYPE:![0-9]+]]
-// CHECK: [[ELEM_TYPE]] = !{[[SUB1:.*]], [[SUB2:.*]]}
-// CHECK: [[SUB1]] = !DISubrange(count: 3)
-// CHECK: [[SUB2]] = !DISubrange(count: -1)
+// CHECK: [[ELEM_TYPE]] = !{[[THREE:.*]], [[NOCOUNT]]}
+// CHECK: [[THREE]] = !DISubrange(count: 3)
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -2180,9 +2180,11 @@
     if (const auto *CAT = dyn_cast<ConstantArrayType>(Ty))
       Count = CAT->getSize().getZExtValue();
     else if (const auto *VAT = dyn_cast<VariableArrayType>(Ty)) {
-      llvm::APSInt V;
-      if (VAT->getSizeExpr()->EvaluateAsInt(V, CGM.getContext()))
-        Count = V.getExtValue();
+      if (Expr *Size = VAT->getSizeExpr()) {
+        llvm::APSInt V;
+        if (Size->EvaluateAsInt(V, CGM.getContext()))
+          Count = V.getExtValue();
+      }
     }
 
     // FIXME: Verify this is right for VLAs.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25793.75243.patch
Type: text/x-patch
Size: 2088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161019/87bf7ff2/attachment-0001.bin>


More information about the cfe-commits mailing list