VMCore/DebugInfo.cpp: DICompileUnit::getSubprograms(): Check numOperands().
authorNAKAMURA Takumi <geek4civic@gmail.com>
Sat, 1 Dec 2012 02:23:45 +0000 (02:23 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Sat, 1 Dec 2012 02:23:45 +0000 (02:23 +0000)
2012-11-30-misched-dbg.ll had crashed. Then (MDNode)N was "!{}".
I am not sure it would be ill-formed or not.

llvm-svn: 169074

llvm/lib/VMCore/DebugInfo.cpp

index 5eea2ce..a4fd705 100644 (file)
@@ -659,8 +659,9 @@ DIArray DICompileUnit::getSubprograms() const {
     return DIArray();
 
   if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(12)))
-    if (MDNode *A = dyn_cast_or_null<MDNode>(N->getOperand(0)))
-      return DIArray(A);
+    if (N->getNumOperands() > 0)
+      if (MDNode *A = dyn_cast_or_null<MDNode>(N->getOperand(0)))
+        return DIArray(A);
   return DIArray();
 }