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
//------------------------------------------------------------------------------
2013-09-09 16:59:47 +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"
2013-09-12 01:04:36 +04:00
extern " C " {
void cling__runtime__internal__throwNullDerefException ( void * Sema , void * Expr ) {
clang : : Sema * S = ( clang : : Sema * ) Sema ;
clang : : Expr * E = ( clang : : Expr * ) Expr ;
2015-11-16 19:52:57 +03:00
throw cling : : runtime : : NullDerefException ( S , E ) ;
2013-09-12 01:04:36 +04:00
}
}
2013-09-07 01:18:14 +04:00
namespace cling {
namespace runtime {
2014-01-15 18:41:53 +04:00
// Pin vtable
InterpreterException : : ~ InterpreterException ( ) { }
2013-09-07 12:41:29 +04:00
const char * InterpreterException : : what ( ) const throw ( ) {
return " runtime_exception \n " ;
2013-09-07 01:30:42 +04:00
}
2014-01-15 18:41:53 +04:00
2013-09-09 16:40:26 +04:00
NullDerefException : : NullDerefException ( clang : : Sema * S , clang : : Expr * E )
: m_Sema ( S ) , m_Arg ( E ) { }
2013-09-07 01:18:14 +04:00
2013-09-07 01:23:45 +04:00
NullDerefException : : ~ NullDerefException ( ) { }
2013-09-07 01:18:14 +04:00
2013-09-07 12:41:29 +04:00
const char * NullDerefException : : what ( ) const throw ( ) {
return " Trying to dereference null pointer or trying to call routine taking non-null arguments " ;
}
2013-09-11 23:10:51 +04:00
2013-09-07 12:41:29 +04:00
void NullDerefException : : diagnose ( ) const throw ( ) {
2013-09-09 16:40:26 +04:00
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