[llvm-commits] CVS: llvm/tools/llvmc/CompilerDriver.cpp CompilerDriver.h llvmc.cpp

Reid Spencer reid at x10sys.com
Sun Aug 20 23:05:05 PDT 2006



Changes in directory llvm/tools/llvmc:

CompilerDriver.cpp updated: 1.38 -> 1.39
CompilerDriver.h updated: 1.20 -> 1.21
llvmc.cpp updated: 1.29 -> 1.30
---
Log message:

For PR797: http://llvm.org/PR797 :
Adjust usage of the ExecuteAndWait function to use the last argument which
is the ErrMsg string. This is necessitated because this function no longer
throws exceptions on error.


---
Diffs of the changes:  (+19 -13)

 CompilerDriver.cpp |   24 ++++++++++++++----------
 CompilerDriver.h   |    3 ++-
 llvmc.cpp          |    5 +++--
 3 files changed, 19 insertions(+), 13 deletions(-)


Index: llvm/tools/llvmc/CompilerDriver.cpp
diff -u llvm/tools/llvmc/CompilerDriver.cpp:1.38 llvm/tools/llvmc/CompilerDriver.cpp:1.39
--- llvm/tools/llvmc/CompilerDriver.cpp:1.38	Wed Aug 16 15:31:44 2006
+++ llvm/tools/llvmc/CompilerDriver.cpp	Mon Aug 21 01:04:45 2006
@@ -451,7 +451,7 @@
     return action;
   }
 
-  bool DoAction(Action*action) {
+  int DoAction(Action*action, std::string& ErrMsg) {
     assert(action != 0 && "Invalid Action!");
     if (isSet(VERBOSE_FLAG))
       WriteAction(action);
@@ -477,15 +477,17 @@
       if (isSet(TIME_ACTIONS_FLAG)) {
         Timer timer(action->program.toString());
         timer.startTimer();
-        int resultCode = sys::Program::ExecuteAndWait(action->program, Args);
+        int resultCode = 
+          sys::Program::ExecuteAndWait(action->program, Args,0,0,0,&ErrMsg);
         timer.stopTimer();
         timer.print(timer,std::cerr);
-        return resultCode == 0;
+        return resultCode;
       }
       else
-        return 0 == sys::Program::ExecuteAndWait(action->program, Args);
+        return 
+          sys::Program::ExecuteAndWait(action->program, Args, 0,0,0, &ErrMsg);
     }
-    return true;
+    return 0;
   }
 
   /// This method tries various variants of a linkage item's file
@@ -594,7 +596,7 @@
 /// @name Methods
 /// @{
 public:
-  virtual int execute(const InputList& InpList, const sys::Path& Output ) {
+  virtual int execute(const InputList& InpList, const sys::Path& Output, std::string& ErrMsg ) {
     try {
       // Echo the configuration of options if we're running verbose
       if (isSet(DEBUG_FLAG)) {
@@ -851,8 +853,9 @@
       std::vector<Action*>::iterator AI = actions.begin();
       std::vector<Action*>::iterator AE = actions.end();
       while (AI != AE) {
-        if (!DoAction(*AI))
-          throw std::string("Action failed");
+        int ActionResult = DoAction(*AI, ErrMsg);
+        if (ActionResult != 0)
+          return ActionResult;
         AI++;
       }
 
@@ -932,8 +935,9 @@
         link->args.push_back(Output.toString());
 
         // Execute the link
-        if (!DoAction(link))
-            throw std::string("Action failed");
+        int ActionResult = DoAction(link, ErrMsg);
+        if (ActionResult != 0)
+          return ActionResult;
       }
     } catch (std::string& msg) {
       cleanup();


Index: llvm/tools/llvmc/CompilerDriver.h
diff -u llvm/tools/llvmc/CompilerDriver.h:1.20 llvm/tools/llvmc/CompilerDriver.h:1.21
--- llvm/tools/llvmc/CompilerDriver.h:1.20	Mon May 29 13:52:05 2006
+++ llvm/tools/llvmc/CompilerDriver.h	Mon Aug 21 01:04:45 2006
@@ -150,7 +150,8 @@
     /// @{
     public:
       /// @brief Execute the actions requested for the given input list.
-      virtual int execute(const InputList& list, const sys::Path& output) = 0;
+      virtual int execute(
+        const InputList& list, const sys::Path& output, std::string& ErrMsg) =0;
 
       /// @brief Set the final phase at which compilation terminates
       virtual void setFinalPhase(Phases phase) = 0;


Index: llvm/tools/llvmc/llvmc.cpp
diff -u llvm/tools/llvmc/llvmc.cpp:1.29 llvm/tools/llvmc/llvmc.cpp:1.30
--- llvm/tools/llvmc/llvmc.cpp:1.29	Mon May 29 13:52:05 2006
+++ llvm/tools/llvmc/llvmc.cpp	Mon Aug 21 01:04:45 2006
@@ -355,9 +355,10 @@
     }
 
     // Tell the driver to do its thing
-    int result = CD->execute(InpList, sys::Path(OutputFilename));
+    std::string ErrMsg;
+    int result = CD->execute(InpList, sys::Path(OutputFilename), ErrMsg);
     if (result != 0) {
-      throw std::string("Error executing actions. Terminated.");
+      std::cerr << argv[0] << ": " << ErrMsg << '\n';
       return result;
     }
 






More information about the llvm-commits mailing list