Get rid of exceptions in llvmc.

llvmc can be now compiled with llvm-gcc on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109215 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mikhail Glushenkov
2010-07-23 03:42:55 +00:00
parent a23650bc01
commit b374d4fd82
13 changed files with 361 additions and 258 deletions

View File

@ -7,29 +7,27 @@
//
//===----------------------------------------------------------------------===//
//
// Exception classes for llvmc.
// Error handling.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_INCLUDE_COMPILER_DRIVER_ERROR_H
#define LLVM_INCLUDE_COMPILER_DRIVER_ERROR_H
#include <stdexcept>
#include "llvm/Support/raw_ostream.h"
#include <string>
namespace llvmc {
/// error_code - This gets thrown during the compilation process if a tool
/// invocation returns a non-zero exit code.
class error_code: public std::runtime_error {
int Code_;
public:
error_code (int c)
: std::runtime_error("Tool returned error code"), Code_(c)
{}
int code() const { return Code_; }
};
inline void PrintError(const char* Err) {
extern const char* ProgramName;
llvm::errs() << ProgramName << ": " << Err << '\n';
}
inline void PrintError(const std::string& Err) {
PrintError(Err.c_str());
}
}
#endif // LLVM_INCLUDE_COMPILER_DRIVER_ERROR_H