diff --git a/include/cling/UserInterface/CompilationException.h b/include/cling/UserInterface/CompilationException.h new file mode 100644 index 00000000..d7f35c8b --- /dev/null +++ b/include/cling/UserInterface/CompilationException.h @@ -0,0 +1,30 @@ +//--------------------------------------------------------------------*- C++ -*- +// CLING - the C++ LLVM-based InterpreterG :) +// author: Axel Naumann +//------------------------------------------------------------------------------ + +#ifndef CLING_COMPILATIONEXCEPTION_H +#define CLING_COMPILATIONEXCEPTION_H + +#include +#include +#include "cling/Interpreter/RuntimeExceptions.h" + +namespace cling { + class Interpreter; + class MetaProcessor; + + //\brief Exception pull us out of JIT (llvm + clang) errors. + class CompilationException: + public virtual runtime::InterpreterException, + public virtual std::runtime_error { + public: + CompilationException(const std::string& reason): + std::runtime_error(reason) {} + ~CompilationException() throw(); // vtable pinned to UserInterface.cpp + virtual const char* what() const throw() { + return std::runtime_error::what(); } + }; +} + +#endif // CLING_COMPILATIONEXCEPTION_H diff --git a/lib/UserInterface/UserInterface.cpp b/lib/UserInterface/UserInterface.cpp index 27c195c2..f1a768c4 100644 --- a/lib/UserInterface/UserInterface.cpp +++ b/lib/UserInterface/UserInterface.cpp @@ -6,6 +6,7 @@ #include "cling/UserInterface/UserInterface.h" +#include "cling/UserInterface/CompilationException.h" #include "cling/Interpreter/RuntimeException.h" #include "cling/Interpreter/StoredValueRef.h" #include "cling/MetaProcessor/MetaProcessor.h" @@ -35,17 +36,6 @@ #endif #endif -namespace cling { - class compilerException: public std::exception { - public: - compilerException(const std::string& reason): Reason(reason) {} - ~compilerException() throw() {} - virtual const char* what() const throw() { return Reason.c_str(); } - private: - std::string Reason; - }; -} - namespace { // Handle fatal llvm errors by throwing an exception.. // Yes, throwing exceptions in error handlers is bad. @@ -53,11 +43,14 @@ namespace { void exceptionErrorHandler(void * /*user_data*/, const std::string& reason, bool /*gen_crash_diag*/) { - throw cling::compilerException(reason); + throw cling::CompilationException(reason); } } namespace cling { + // Declared in CompilationException.h; vtable pinned here. + CompilationException::~CompilationException() throw() {} + UserInterface::UserInterface(Interpreter& interp) { // We need stream that doesn't close its file descriptor, thus we are not // using llvm::outs. Keeping file descriptor open we will be able to use