2014-01-07 11:57:02 +01:00
//------------------------------------------------------------------------------
// CLING - the C++ LLVM-based InterpreterG :)
//
// 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-12-12 14:16:48 +01:00
// RUN: cat %s | %cling -Xclang -verify | FileCheck %s
2012-12-04 15:43:55 +00:00
// XFAIL:*
2012-11-21 01:15:58 +00:00
2014-08-03 21:05:42 -05:00
// Test whether the interpreter is able to generate properly the symbols
2012-11-21 01:15:58 +00:00
// and the vtables of classes.
2012-11-18 22:56:46 +00:00
# include "cling/Interpreter/Interpreter.h"
# include "cling/Interpreter/LookupHelper.h"
# include "cling/Utils/AST.h"
# include "clang/AST/Decl.h"
# include "llvm/Support/Casting.h"
. rawInput
template < typename T > struct C {
virtual void f ( ) { }
static int S ;
} ;
template < typename T > int C < T > : : S = 12 ;
template class C < int > ;
2012-11-21 01:15:58 +00:00
// Nested in function class
void f ( ) {
class NestedC {
public :
virtual void g ( ) { }
} ;
}
2012-11-18 22:56:46 +00:00
. rawInput
const cling : : LookupHelper & lh = gCling - > getLookupHelper ( ) ;
2012-11-21 01:15:58 +00:00
clang : : Sema & S = gCling - > getSema ( ) ;
2012-11-18 22:56:46 +00:00
const clang : : NamedDecl * D = 0 ;
clang : : DeclContext * DC = 0 ;
DC = llvm : : dyn_cast_or_null < clang : : DeclContext > ( const_cast < clang : : Decl * > ( lh . findScope ( " C<int> " ) ) ) ;
2012-11-21 01:15:58 +00:00
D = cling : : utils : : Lookup : : Named ( & S , " S " , DC ) ;
2012-11-18 22:56:46 +00:00
gCling - > getAddressOfGlobal ( D )
//CHECK-NOT: (void *) 0x0
D = cling : : utils : : Lookup : : Named ( & S , " f " , DC ) ;
gCling - > getAddressOfGlobal ( D )
//TODO-CHECK-NOT: (void *) 0x0
2012-11-21 01:15:58 +00:00
. rawInput
// Nested classes
class N1 {
public :
class N2 {
public :
class N3 {
public :
virtual void fN3 ( ) { }
} ;
virtual void fN2 ( ) = 0 ;
} ;
} ;
. rawInput
DC = llvm : : dyn_cast_or_null < clang : : DeclContext > ( const_cast < clang : : Decl * > ( lh . findScope ( " N1::N2 " ) ) ) ;
D = cling : : utils : : Lookup : : Named ( & S , " fN2 " , DC ) ;
gCling - > getAddressOfGlobal ( D )
//CHECK-NOT: (void *) 0x0
. rawInput
// vbases
class V { public : virtual void fV ( ) { } } ;
class B1 : virtual public V { /* ... */ } ;
class B2 : virtual public V { /* ... */ } ;
class B3 : public V { /* ... */ } ;
2014-08-03 21:05:42 -05:00
class X : public B1 , public B2 , public B3 {
public :
virtual void fV ( ) { }
2012-11-21 01:15:58 +00:00
struct S {
virtual void fS ( ) { }
} ;
} ;
. rawInput
DC = llvm : : dyn_cast_or_null < clang : : DeclContext > ( const_cast < clang : : Decl * > ( lh . findScope ( " X " ) ) ) ;
D = cling : : utils : : Lookup : : Named ( & S , " fV " , DC ) ;
gCling - > getAddressOfGlobal ( D )
//CHECK-NOT: (void *) 0x0
DC = llvm : : dyn_cast_or_null < clang : : DeclContext > ( const_cast < clang : : Decl * > ( lh . findScope ( " X::S " ) ) ) ;
D = cling : : utils : : Lookup : : Named ( & S , " fS " , DC ) ;
gCling - > getAddressOfGlobal ( D )
//CHECK-NOT: (void *) 0x0