Do the right thing on NULL uint64 fields.
authorEric Christopher <echristo@apple.com>
Fri, 16 Mar 2012 00:21:54 +0000 (00:21 +0000)
committerEric Christopher <echristo@apple.com>
Fri, 16 Mar 2012 00:21:54 +0000 (00:21 +0000)
Patch by Clemens Hammacher!

Fixes PR12243

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

lib/Analysis/DebugInfo.cpp
test/DebugInfo/bug_null_debuginfo.ll [new file with mode: 0644]

index 585a087a02ac1c007e8e780ed7efdf7faf6d0d0c..e30c0a9b3306d60f4581c30b28beb11fbca04fb7 100644 (file)
@@ -68,7 +68,7 @@ uint64_t DIDescriptor::getUInt64Field(unsigned Elt) const {
     return 0;
 
   if (Elt < DbgNode->getNumOperands())
-    if (ConstantInt *CI = dyn_cast<ConstantInt>(DbgNode->getOperand(Elt)))
+    if (ConstantInt *CI = dyn_cast_or_null<ConstantInt>(DbgNode->getOperand(Elt)))
       return CI->getZExtValue();
 
   return 0;
diff --git a/test/DebugInfo/bug_null_debuginfo.ll b/test/DebugInfo/bug_null_debuginfo.ll
new file mode 100644 (file)
index 0000000..a7fdf70
--- /dev/null
@@ -0,0 +1,6 @@
+; RUN: llc
+
+
+!llvm.dbg.cu = !{!0}
+
+!0 = metadata !{null, null, null}