diff options
Diffstat (limited to 'tools/llvmc')
-rw-r--r-- | tools/llvmc/CompilerDriver.cpp | 24 | ||||
-rw-r--r-- | tools/llvmc/CompilerDriver.h | 3 | ||||
-rw-r--r-- | tools/llvmc/llvmc.cpp | 5 |
3 files changed, 19 insertions, 13 deletions
diff --git a/tools/llvmc/CompilerDriver.cpp b/tools/llvmc/CompilerDriver.cpp index 64232f3d2c..a204964cd8 100644 --- a/tools/llvmc/CompilerDriver.cpp +++ b/tools/llvmc/CompilerDriver.cpp @@ -451,7 +451,7 @@ private: 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 @@ private: 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 @@ private: /// @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 @@ public: 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 @@ public: 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(); diff --git a/tools/llvmc/CompilerDriver.h b/tools/llvmc/CompilerDriver.h index 41ad2c3bb4..02ec0e9f52 100644 --- a/tools/llvmc/CompilerDriver.h +++ b/tools/llvmc/CompilerDriver.h @@ -150,7 +150,8 @@ namespace llvm { /// @{ 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; diff --git a/tools/llvmc/llvmc.cpp b/tools/llvmc/llvmc.cpp index 496eaa4194..f2e7c1fb37 100644 --- a/tools/llvmc/llvmc.cpp +++ b/tools/llvmc/llvmc.cpp @@ -355,9 +355,10 @@ int main(int argc, char **argv) { } // 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; } |