Make ToolExecutionError inherit std::exception and implement its
authorAlkis Evlogimenos <alkis@evlogimenos.com>
Thu, 19 Feb 2004 07:39:26 +0000 (07:39 +0000)
committerAlkis Evlogimenos <alkis@evlogimenos.com>
Thu, 19 Feb 2004 07:39:26 +0000 (07:39 +0000)
interface: getMessage() is gone, use what() instead.

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

include/llvm/Support/ToolRunner.h
lib/Support/ToolRunner.cpp
tools/bugpoint/BugDriver.cpp
tools/bugpoint/ToolRunner.cpp
tools/bugpoint/ToolRunner.h
tools/bugpoint/bugpoint.cpp

index d8e7503253fbb0c6a289e26bc04123c4211f54b7..9cbbf7f51e0a0f618b224fc6b11a313ccf35efa8 100644 (file)
@@ -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(); }
 };
 
 
index 6ad3d4392c0a6295f09c5709670b5d3d3b029ce8..4a7be56461a5cb19053460bf9da34d2bc5bee9b7 100644 (file)
@@ -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 ";
index 4359622777ff3da04a7315d6e055fcd3ee32f37c..d3a57f4afe2fe315168dfcc9dae2d6f75bb00898 100644 (file)
@@ -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();
   }
 
index 6ad3d4392c0a6295f09c5709670b5d3d3b029ce8..4a7be56461a5cb19053460bf9da34d2bc5bee9b7 100644 (file)
@@ -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 ";
index d8e7503253fbb0c6a289e26bc04123c4211f54b7..9cbbf7f51e0a0f618b224fc6b11a313ccf35efa8 100644 (file)
@@ -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(); }
 };
 
 
index 3c89dce525a36ff6b0a74e55d7b39d1bd454ca9d..65de9658a7e4ce2476ce66bc6945a6fa2d111984 100644 (file)
@@ -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.  "