Make the verifier reject instructions which have null pointers
authorChris Lattner <sabre@nondot.org>
Thu, 28 Aug 2008 04:02:44 +0000 (04:02 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 28 Aug 2008 04:02:44 +0000 (04:02 +0000)
for operands: rdar://6179606.  no testcase, because I can't write
a .ll file that is this broken ;-)

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

lib/VMCore/Verifier.cpp

index b5876a7e98e71ec784559bbedb02735072645185..034a0628fbaeeba1fd182070cedf77a466fd86e1 100644 (file)
@@ -224,6 +224,10 @@ namespace {
     void visitGlobalAlias(GlobalAlias &GA);
     void visitFunction(Function &F);
     void visitBasicBlock(BasicBlock &BB);
+    using InstVisitor<Verifier>::visit;
+       
+    void visit(Instruction &I);
+       
     void visitTruncInst(TruncInst &I);
     void visitZExtInst(ZExtInst &I);
     void visitSExtInst(SExtInst &I);
@@ -326,6 +330,13 @@ static RegisterPass<Verifier> X("verify", "Module Verifier");
   do { if (!(C)) { CheckFailed(M, V1, V2, V3, V4); return; } } while (0)
 
 
+void Verifier::visit(Instruction &I) {
+  for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
+    Assert1(I.getOperand(i) != 0, "Operand is null", &I);
+  InstVisitor<Verifier>::visit(I);
+}
+
+
 void Verifier::visitGlobalValue(GlobalValue &GV) {
   Assert1(!GV.isDeclaration() ||
           GV.hasExternalLinkage() ||