diff options
author | Chris Lattner <sabre@nondot.org> | 2008-08-28 04:02:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-08-28 04:02:44 +0000 |
commit | cad208b8bc1458c42ca93430fcccbc18e1a5d4ab (patch) | |
tree | 3ed39f97023c8d54eccdd745a86925cb65c76911 /lib/VMCore/Verifier.cpp | |
parent | 1e1ef3e2bd40920ff26b50fbf44e442db99e7801 (diff) | |
download | external_llvm-cad208b8bc1458c42ca93430fcccbc18e1a5d4ab.zip external_llvm-cad208b8bc1458c42ca93430fcccbc18e1a5d4ab.tar.gz external_llvm-cad208b8bc1458c42ca93430fcccbc18e1a5d4ab.tar.bz2 |
Make the verifier reject instructions which have null pointers
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
Diffstat (limited to 'lib/VMCore/Verifier.cpp')
-rw-r--r-- | lib/VMCore/Verifier.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index b5876a7..034a062 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -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() || |