summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Support/ToolRunner.h8
-rw-r--r--lib/Support/ToolRunner.cpp2
-rw-r--r--tools/bugpoint/BugDriver.cpp4
-rw-r--r--tools/bugpoint/ToolRunner.cpp2
-rw-r--r--tools/bugpoint/ToolRunner.h8
-rw-r--r--tools/bugpoint/bugpoint.cpp2
6 files changed, 17 insertions, 9 deletions
diff --git a/include/llvm/Support/ToolRunner.h b/include/llvm/Support/ToolRunner.h
index d8e7503253..9cbbf7f51e 100644
--- a/include/llvm/Support/ToolRunner.h
+++ b/include/llvm/Support/ToolRunner.h
@@ -18,6 +18,7 @@
#define TOOLRUNNER_H
#include "Support/SystemUtils.h"
+#include <exception>
#include <vector>
namespace llvm {
@@ -30,11 +31,12 @@ class LLC;
/// AbstractInterpreter instances if there is an error running a tool (e.g., LLC
/// crashes) which prevents execution of the program.
///
-class ToolExecutionError {
+class ToolExecutionError : std::exception {
std::string Message;
public:
- ToolExecutionError(const std::string &M) : Message(M) {}
- const std::string getMessage() const { return Message; }
+ explicit ToolExecutionError(const std::string &M) : Message(M) {}
+ virtual ~ToolExecutionError() throw();
+ virtual const char* what() const throw() { return Message.c_str(); }
};
diff --git a/lib/Support/ToolRunner.cpp b/lib/Support/ToolRunner.cpp
index 6ad3d4392c..4a7be56461 100644
--- a/lib/Support/ToolRunner.cpp
+++ b/lib/Support/ToolRunner.cpp
@@ -21,6 +21,8 @@
#include <sstream>
using namespace llvm;
+ToolExecutionError::~ToolExecutionError() throw() { }
+
static void ProcessFailure(std::string ProgPath, const char** Args) {
std::ostringstream OS;
OS << "\nError running tool:\n ";
diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp
index 4359622777..d3a57f4afe 100644
--- a/tools/bugpoint/BugDriver.cpp
+++ b/tools/bugpoint/BugDriver.cpp
@@ -159,7 +159,7 @@ bool BugDriver::run() {
CreatedOutput = true;
std::cout << "Reference output is: " << ReferenceOutputFile << "\n";
} catch (ToolExecutionError &TEE) {
- std::cerr << TEE.getMessage();
+ std::cerr << TEE.what();
if (Interpreter != cbe) {
std::cerr << "*** There is a bug running the C backend. Either debug"
<< " it (use the -run-cbe bugpoint option), or fix the error"
@@ -183,7 +183,7 @@ bool BugDriver::run() {
return debugMiscompilation();
}
} catch (ToolExecutionError &TEE) {
- std::cerr << TEE.getMessage();
+ std::cerr << TEE.what();
return debugCodeGeneratorCrash();
}
diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp
index 6ad3d4392c..4a7be56461 100644
--- a/tools/bugpoint/ToolRunner.cpp
+++ b/tools/bugpoint/ToolRunner.cpp
@@ -21,6 +21,8 @@
#include <sstream>
using namespace llvm;
+ToolExecutionError::~ToolExecutionError() throw() { }
+
static void ProcessFailure(std::string ProgPath, const char** Args) {
std::ostringstream OS;
OS << "\nError running tool:\n ";
diff --git a/tools/bugpoint/ToolRunner.h b/tools/bugpoint/ToolRunner.h
index d8e7503253..9cbbf7f51e 100644
--- a/tools/bugpoint/ToolRunner.h
+++ b/tools/bugpoint/ToolRunner.h
@@ -18,6 +18,7 @@
#define TOOLRUNNER_H
#include "Support/SystemUtils.h"
+#include <exception>
#include <vector>
namespace llvm {
@@ -30,11 +31,12 @@ class LLC;
/// AbstractInterpreter instances if there is an error running a tool (e.g., LLC
/// crashes) which prevents execution of the program.
///
-class ToolExecutionError {
+class ToolExecutionError : std::exception {
std::string Message;
public:
- ToolExecutionError(const std::string &M) : Message(M) {}
- const std::string getMessage() const { return Message; }
+ explicit ToolExecutionError(const std::string &M) : Message(M) {}
+ virtual ~ToolExecutionError() throw();
+ virtual const char* what() const throw() { return Message.c_str(); }
};
diff --git a/tools/bugpoint/bugpoint.cpp b/tools/bugpoint/bugpoint.cpp
index 3c89dce525..65de9658a7 100644
--- a/tools/bugpoint/bugpoint.cpp
+++ b/tools/bugpoint/bugpoint.cpp
@@ -54,7 +54,7 @@ int main(int argc, char **argv) {
try {
return D.run();
} catch (ToolExecutionError &TEE) {
- std::cerr << "Tool execution error: " << TEE.getMessage() << "\n";
+ std::cerr << "Tool execution error: " << TEE.what() << "\n";
return 1;
} catch (...) {
std::cerr << "Whoops, an exception leaked out of bugpoint. "