+ToolExecutionError::~ToolExecutionError() throw() { }
+
+static void ProcessFailure(std::string ProgPath, const char** Args) {
+ std::ostringstream OS;
+ OS << "\nError running tool:\n ";
+ for (const char **Arg = Args; *Arg; ++Arg)
+ OS << " " << *Arg;
+ OS << "\n";
+
+ // Rerun the compiler, capturing any error messages to print them.
+ std::string ErrorFilename = getUniqueFilename("error_messages");
+ RunProgramWithTimeout(ProgPath, Args, "/dev/null", ErrorFilename.c_str(),
+ ErrorFilename.c_str());
+
+ // Print out the error messages generated by GCC if possible...
+ std::ifstream ErrorFile(ErrorFilename.c_str());
+ if (ErrorFile) {
+ std::copy(std::istreambuf_iterator<char>(ErrorFile),
+ std::istreambuf_iterator<char>(),
+ std::ostreambuf_iterator<char>(OS));
+ ErrorFile.close();
+ }
+
+ removeFile(ErrorFilename);
+ throw ToolExecutionError(OS.str());
+}
+