summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-06 18:02:27 +0000
committerChris Lattner <sabre@nondot.org>2006-07-06 18:02:27 +0000
commit5734e8d7c38778e6e0575f80353ba8327b412947 (patch)
treeeb8fa69520bb8884e7f63acc2b4874154239a877 /llvm/lib
parent6cf27be54da3d601a6a6148984a98c280bb2dbc3 (diff)
downloadbcm5719-llvm-5734e8d7c38778e6e0575f80353ba8327b412947.tar.gz
bcm5719-llvm-5734e8d7c38778e6e0575f80353ba8327b412947.zip
Change the verifier to never throw an exception. Instead verifyModule canoptionally return the string error, which is an easier api for clients touse anyway.
llvm-svn: 29017
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Bytecode/Reader/Analyzer.cpp40
-rw-r--r--llvm/lib/VMCore/Verifier.cpp15
2 files changed, 22 insertions, 33 deletions
diff --git a/llvm/lib/Bytecode/Reader/Analyzer.cpp b/llvm/lib/Bytecode/Reader/Analyzer.cpp
index 0152104acb8..ce20ac2e3a5 100644
--- a/llvm/lib/Bytecode/Reader/Analyzer.cpp
+++ b/llvm/lib/Bytecode/Reader/Analyzer.cpp
@@ -117,12 +117,10 @@ public:
bca.functionDensity = double(bca.BlockSizes[BytecodeFormat::FunctionBlockID]) /
double(bca.numFunctions);
- if ( bca.progressiveVerify ) {
- try {
- verifyModule(*M, ThrowExceptionAction);
- } catch ( std::string& msg ) {
+ if (bca.progressiveVerify) {
+ std::string msg;
+ if (verifyModule(*M, ReturnStatusAction, &msg))
bca.VerifyInfo += "Verify@Finish: " + msg + "\n";
- }
}
}
@@ -135,12 +133,10 @@ public:
virtual void handleModuleEnd(const std::string& id) {
if (os)
*os << " } End Module " << id << "\n";
- if ( bca.progressiveVerify ) {
- try {
- verifyModule(*M, ThrowExceptionAction);
- } catch ( std::string& msg ) {
+ if (bca.progressiveVerify) {
+ std::string msg;
+ if (verifyModule(*M, ReturnStatusAction, &msg))
bca.VerifyInfo += "Verify@EndModule: " + msg + "\n";
- }
}
}
@@ -232,12 +228,10 @@ public:
virtual void handleModuleGlobalsEnd() {
if (os)
*os << " } END BLOCK: ModuleGlobalInfo\n";
- if ( bca.progressiveVerify ) {
- try {
- verifyModule(*M, ThrowExceptionAction);
- } catch ( std::string& msg ) {
+ if (bca.progressiveVerify) {
+ std::string msg;
+ if (verifyModule(*M, ReturnStatusAction, &msg))
bca.VerifyInfo += "Verify@EndModuleGlobalInfo: " + msg + "\n";
- }
}
}
@@ -346,12 +340,10 @@ public:
currFunc->density = double(currFunc->byteSize) /
double(currFunc->numInstructions);
- if ( bca.progressiveVerify ) {
- try {
- verifyModule(*M, ThrowExceptionAction);
- } catch ( std::string& msg ) {
+ if (bca.progressiveVerify) {
+ std::string msg;
+ if (verifyModule(*M, ReturnStatusAction, &msg))
bca.VerifyInfo += "Verify@EndFunction: " + msg + "\n";
- }
}
}
@@ -522,12 +514,10 @@ public:
if (os)
*os << " } END BLOCK: GlobalConstants\n";
- if ( bca.progressiveVerify ) {
- try {
- verifyModule(*M, ThrowExceptionAction);
- } catch ( std::string& msg ) {
+ if (bca.progressiveVerify) {
+ std::string msg;
+ if (verifyModule(*M, ReturnStatusAction, &msg))
bca.VerifyInfo += "Verify@EndGlobalConstants: " + msg + "\n";
- }
}
}
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp
index d07345e9329..9379abcfd18 100644
--- a/llvm/lib/VMCore/Verifier.cpp
+++ b/llvm/lib/VMCore/Verifier.cpp
@@ -152,18 +152,13 @@ namespace { // Anonymous namespace for class
/// this condition, do so.
///
void abortIfBroken() {
- if (Broken)
- {
+ if (Broken) {
msgs << "Broken module found, ";
- switch (action)
- {
+ switch (action) {
case AbortProcessAction:
msgs << "compilation aborted!\n";
std::cerr << msgs.str();
abort();
- case ThrowExceptionAction:
- msgs << "verification terminated.\n";
- throw msgs.str();
case PrintMessageAction:
msgs << "verification continues.\n";
std::cerr << msgs.str();
@@ -799,11 +794,15 @@ bool llvm::verifyFunction(const Function &f, VerifierFailureAction action) {
/// verifyModule - Check a module for errors, printing messages on stderr.
/// Return true if the module is corrupt.
///
-bool llvm::verifyModule(const Module &M, VerifierFailureAction action) {
+bool llvm::verifyModule(const Module &M, VerifierFailureAction action,
+ std::string *ErrorInfo) {
PassManager PM;
Verifier *V = new Verifier(action);
PM.add(V);
PM.run((Module&)M);
+
+ if (ErrorInfo && V->Broken)
+ *ErrorInfo = V->msgs.str();
return V->Broken;
}
OpenPOWER on IntegriCloud