OSDN Git Service

Fix some problems where the verifier would crash on invalid input instead of
authorChris Lattner <sabre@nondot.org>
Thu, 24 Feb 2005 16:58:29 +0000 (16:58 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 24 Feb 2005 16:58:29 +0000 (16:58 +0000)
reporting the problem and exiting.

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

lib/VMCore/AsmWriter.cpp
lib/VMCore/Verifier.cpp

index 5406c83..b42ccc1 100644 (file)
@@ -755,9 +755,12 @@ std::ostream &AssemblyWriter::printTypeAtLeastOneLevel(const Type *Ty) {
 
 void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType, 
                                   bool PrintName) {
-  assert(Operand != 0 && "Illegal Operand");
-  if (PrintType) { Out << ' '; printType(Operand->getType()); }
-  WriteAsOperandInternal(Out, Operand, PrintName, TypeNames, &Machine);
+  if (Operand != 0) {
+    if (PrintType) { Out << ' '; printType(Operand->getType()); }
+    WriteAsOperandInternal(Out, Operand, PrintName, TypeNames, &Machine);
+  } else {
+    Out << "<null operand!>";
+  }
 }
 
 
index ad1074d..4fae3b7 100644 (file)
@@ -592,6 +592,7 @@ void Verifier::visitInstruction(Instruction &I) {
   for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
     // Check to make sure that the "address of" an intrinsic function is never
     // taken.
+    Assert1(I.getOperand(i) != 0, "Instruction has null operand!", &I);
     if (Function *F = dyn_cast<Function>(I.getOperand(i))) {
       Assert1(!F->isIntrinsic() || (i == 0 && isa<CallInst>(I)),
               "Cannot take the address of an intrinsic!", &I);