Diagnose Interpreter exceptions.

Enable the TInterpreter to diagnose InterpreterExceptions so that
they can be caught and diagnose from outside ROOT. For that
InterpreterException derives from std::exception.
This commit is contained in:
CristinaCristescu 2016-03-20 19:23:34 +01:00 committed by sftnight
parent 8fe8f2f4ad
commit b9a2d80235
2 changed files with 9 additions and 6 deletions

View File

@ -10,6 +10,8 @@
#ifndef CLING_RUNTIME_EXCEPTION_H
#define CLING_RUNTIME_EXCEPTION_H
#include <exception>
namespace clang {
class Sema;
class Expr;
@ -19,10 +21,12 @@ namespace clang {
namespace cling {
///\brief Base class for all interpreter exceptions.
///
class InterpreterException {
class InterpreterException : public std::exception {
public:
virtual const char* what() const throw();
virtual ~InterpreterException();
virtual const char* what() const throw();
virtual void diagnose() const {}
};
///\brief Exception that is thrown when a invalid pointer dereference is found
@ -40,8 +44,8 @@ namespace cling {
InvalidDerefException(clang::Sema* S, clang::Expr* E, DerefType type);
virtual ~InvalidDerefException();
virtual const char* what() const throw();
void diagnose() const throw();
const char* what() const throw() override;
void diagnose() const override;
};
} // end namespace cling
#endif // CLING_RUNTIME_EXCEPTION_H

View File

@ -48,7 +48,6 @@ namespace cling {
return "runtime_exception\n";
}
InvalidDerefException::InvalidDerefException(clang::Sema* S, clang::Expr* E,
cling::InvalidDerefException::DerefType type)
: m_Sema(S), m_Arg(E), m_Diags(&m_Sema->getDiagnostics()), m_Type(type) {}
@ -64,7 +63,7 @@ namespace cling {
return "Trying to dereference null pointer or trying to call routine taking non-null arguments";
}
void InvalidDerefException::diagnose() const throw() {
void InvalidDerefException::diagnose() const {
// Construct custom diagnostic: warning for invalid memory address;
// no equivalent in clang.
if (m_Type == cling::InvalidDerefException::DerefType::INVALID_MEM) {