cling/lib/Interpreter/RuntimeException.cpp

50 lines
1.6 KiB
C++
Raw Normal View History

2013-09-07 01:18:14 +04:00
//--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// author: Baozeng Ding <sploving1@gmail.com>
// author: Vassil Vassilev <vasil.georgiev.vasilev@cern.ch>
2014-01-07 14:08:37 +04:00
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
2013-09-07 01:18:14 +04:00
//------------------------------------------------------------------------------
#include "cling/Interpreter/RuntimeException.h"
2013-09-07 01:18:14 +04:00
#include "clang/Basic/SourceLocation.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/SemaDiagnostic.h"
extern "C" {
void cling__runtime__internal__throwNullDerefException(void* Sema, void* Expr) {
clang::Sema* S = (clang::Sema*)Sema;
clang::Expr* E = (clang::Expr*)Expr;
throw cling::runtime::NullDerefException(S, E);
}
}
2013-09-07 01:18:14 +04:00
namespace cling {
namespace runtime {
2014-01-15 18:41:53 +04:00
// Pin vtable
InterpreterException::~InterpreterException() {}
const char* InterpreterException::what() const throw() {
return "runtime_exception\n";
}
2014-01-15 18:41:53 +04:00
NullDerefException::NullDerefException(clang::Sema* S, clang::Expr* E)
: m_Sema(S), m_Arg(E) {}
2013-09-07 01:18:14 +04:00
NullDerefException::~NullDerefException() {}
2013-09-07 01:18:14 +04:00
const char* NullDerefException::what() const throw() {
return "Trying to dereference null pointer or trying to call routine taking non-null arguments";
}
void NullDerefException::diagnose() const throw() {
m_Sema->Diag(m_Arg->getLocStart(), clang::diag::warn_null_arg)
<< m_Arg->getSourceRange();
2013-09-07 01:18:14 +04:00
}
} // end namespace runtime
} // end namespace cling