Fix some error messages; Make LLVMC pass through the exit code of a failed tool.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50971 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/llvmc2/CompilationGraph.cpp b/tools/llvmc2/CompilationGraph.cpp
index d149c0f..e06a168 100644
--- a/tools/llvmc2/CompilationGraph.cpp
+++ b/tools/llvmc2/CompilationGraph.cpp
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "Error.h"
 #include "CompilationGraph.h"
 
 #include "llvm/ADT/STLExtras.h"
@@ -90,7 +91,7 @@
 const std::string& CompilationGraph::getLanguage(const sys::Path& File) const {
   LanguageMap::const_iterator Lang = ExtsToLangs.find(File.getSuffix());
   if (Lang == ExtsToLangs.end())
-    throw std::runtime_error("Unknown suffix: " + File.getSuffix() + '!');
+    throw std::runtime_error("Unknown suffix: " + File.getSuffix());
   return Lang->second;
 }
 
@@ -101,7 +102,7 @@
   tools_map_type::const_iterator I = ToolsMap.find(LangName);
   if (I == ToolsMap.end())
     throw std::runtime_error("No tool corresponding to the language "
-                             + LangName + "found!");
+                             + LangName + "found");
   return I->second;
 }
 
@@ -176,8 +177,8 @@
       Out = MakeTempFile(TempDir, In.getBasename(), CurTool->OutputSuffix());
     }
 
-    if (CurTool->GenerateAction(In, Out).Execute() != 0)
-      throw std::runtime_error("Tool returned error code!");
+    if (int ret = CurTool->GenerateAction(In, Out).Execute())
+      throw error_code(ret);
 
     if (Last)
       return;
@@ -205,8 +206,8 @@
   // Find the toolchain for the input language.
   const tools_vector_type& TV = getToolsVector(InLanguage);
   if (TV.empty())
-    throw std::runtime_error("No toolchain corresponding to language"
-                             + InLanguage + " found!");
+    throw std::runtime_error("No toolchain corresponding to language "
+                             + InLanguage + " found");
   return &getNode(ChooseEdge(TV, InLangs)->ToolName());
 }
 
@@ -342,8 +343,8 @@
       Out = MakeTempFile(TempDir, "tmp", JT->OutputSuffix());
     }
 
-    if (JT->GenerateAction(Out).Execute() != 0)
-      throw std::runtime_error("Tool returned error code!");
+    if (int ret = JT->GenerateAction(Out).Execute())
+      throw error_code(ret);
 
     if (!IsLast) {
       const Node* NextNode =
@@ -397,7 +398,7 @@
     O.close();
   }
   else {
-    throw std::runtime_error("");
+    throw std::runtime_error("Error opening file for writing");
   }
 }