aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-03-15 20:25:09 +0000
committerChris Lattner <sabre@nondot.org>2002-03-15 20:25:09 +0000
commitacd3caec0d5419f454cfc4e15afe7945de46547f (patch)
tree7b3146c10a50722025fab1fd99c2ce90fa8b84d3
parent9b638019ca8870f418e3b42b39dd34dc7deebb2d (diff)
Checkin new test for problem anand ran into
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1880 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/VMCore/Verifier.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index d7c209cc9b..e6333f71dd 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -26,6 +26,7 @@
// . Method's cannot take a void typed parameter
// . Verify that a method's argument list agrees with it's declared type.
// . Verify that arrays and structures have fixed elements: No unsized arrays.
+// * It is illegal to specify a name for a void value.
// . All other things that are tested by asserts spread about the code...
//
//===----------------------------------------------------------------------===//
@@ -38,6 +39,7 @@
#include "llvm/BasicBlock.h"
#include "llvm/Type.h"
#include "llvm/iPHINode.h"
+#include "llvm/SymbolTable.h"
#include "llvm/Support/CFG.h"
#include "Support/STLExtras.h"
#include <algorithm>
@@ -142,13 +144,37 @@ static bool verifyBasicBlock(const BasicBlock *BB) {
return Broken;
}
+// verifySymbolTable - Verify that a method or module symbol table is ok
+//
+static bool verifySymbolTable(const SymbolTable *ST) {
+ if (ST == 0) return false;
+ bool Broken = false;
+
+ // Loop over all of the types in the symbol table...
+ for (SymbolTable::const_iterator TI = ST->begin(), TE = ST->end();
+ TI != TE; ++TI)
+ for (SymbolTable::type_const_iterator I = TI->second.begin(),
+ E = TI->second.end(); I != E; ++I) {
+ Value *V = I->second;
+
+ // Check that there are no void typed values in the symbol table. Values
+ // with a void type cannot be put into symbol tables because they cannot
+ // have names!
+ Assert1(V->getType() != Type::VoidTy,
+ "Values with void type are not allowed to have names!\n", V);
+ }
+
+ return Broken;
+}
-// verifyMethod - Verify that a method is ok.
+// verifyMethod - Verify that a method is ok. Return true if not so that
+// verifyModule and direct clients of the verifyMethod function are correctly
+// informed.
//
bool verifyMethod(const Method *M) {
if (M->isExternal()) return false; // Can happen if called by verifyModule
- bool Broken = false;
+ bool Broken = verifySymbolTable(M->getSymbolTable());
const BasicBlock *Entry = M->front();
Assert1(pred_begin(Entry) == pred_end(Entry),
"Entry block to method must not have predecessors!", Entry);
@@ -160,6 +186,11 @@ bool verifyMethod(const Method *M) {
namespace { // Anonymous namespace for class
struct VerifierPass : public MethodPass {
+
+ bool doInitialization(Module *M) {
+ verifySymbolTable(M->getSymbolTable());
+ return false;
+ }
bool runOnMethod(Method *M) { verifyMethod(M); return false; }
};
}
@@ -172,5 +203,6 @@ Pass *createVerifierPass() {
// Return true if the module is corrupt.
//
bool verifyModule(const Module *M) {
- return reduce_apply_bool(M->begin(), M->end(), verifyMethod);
+ return verifySymbolTable(M->getSymbolTable()) |
+ reduce_apply_bool(M->begin(), M->end(), verifyMethod);
}