2012-10-10 17:00:17 +04:00
// RUN: cat %s | %cling | FileCheck %s
2012-09-05 13:37:39 +04:00
// The test verifies the expected behavior in cling::utils::Transform class,
// which is supposed to provide different transformation of AST nodes and types.
# include "cling/Interpreter/Interpreter.h"
# include "cling/Interpreter/LookupHelper.h"
# include "cling/Utils/AST.h"
# include "clang/AST/Type.h"
2012-10-26 23:51:56 +04:00
# include "clang/AST/ASTContext.h"
2012-09-05 13:37:39 +04:00
# include "llvm/ADT/SmallSet.h"
2012-10-03 16:57:48 +04:00
# include "clang/Sema/Sema.h"
2012-09-05 13:37:39 +04:00
. rawInput 1
2012-12-11 12:26:00 +04:00
# include <vector>
# include <iostream>
2012-09-05 13:37:39 +04:00
typedef double Double32_t ;
typedef int Int_t ;
typedef long Long_t ;
typedef Int_t * IntPtr_t ;
2012-10-19 17:33:38 +04:00
typedef Int_t & IntRef_t ;
2012-09-05 13:37:39 +04:00
template < typename T > class A { } ;
template < typename T , typename U > class B { } ;
template < typename T , typename U > class C { } ;
typedef C < A < B < Double32_t , Int_t > > , Double32_t > CTD ;
typedef C < A < B < const Double32_t , const Int_t > > , Double32_t > CTDConst ;
2013-02-12 22:38:58 +04:00
template < typename key , typename value , typename compare_operation = std : : less < key > , typename alloc = std : : allocator < std : : pair < const key , value > > > class cmap { key fKey ; const value fValue ; alloc fAlloc ; } ;
// : public std::map<key, value, compare_operation, alloc> {
template < typename key , typename value = const key > class mypair { public : key fKey ; value fValue ; } ;
2012-09-27 12:49:18 +04:00
# include <string>
namespace Details {
2012-12-11 12:26:00 +04:00
class Impl { } ;
2012-09-27 12:49:18 +04:00
}
2013-02-08 02:56:10 +04:00
// To insure instantiation.
// typedef std::pair<Details::Impl,std::vector<Details::Impl> > details_pairs;
2012-09-27 12:49:18 +04:00
namespace NS {
2012-12-11 12:26:00 +04:00
template < typename T , int size = 0 > class ArrayType { } ;
template < typename T > class Array { } ;
template < typename T > class Container {
public :
class Content { } ;
typedef T Value_t ;
typedef Content Content_t ;
typedef : : Details : : Impl Impl_t ;
} ;
2013-10-30 16:23:58 +04:00
2012-12-11 12:26:00 +04:00
template < typename T > class TDataPoint { } ;
typedef TDataPoint < float > TDataPointF ;
typedef TDataPoint < Double32_t > TDataPointD32 ;
2013-10-30 16:23:58 +04:00
const int typeN = 1 ;
typedef ArrayType < float , typeN + 1 > FArray ;
2013-11-06 20:04:33 +04:00
typedef int IntNS_t ;
2012-09-27 12:49:18 +04:00
}
2012-10-26 23:51:56 +04:00
// Anonymous namespace
namespace {
2012-12-11 12:26:00 +04:00
class InsideAnonymous {
} ;
2012-10-26 23:51:56 +04:00
}
2013-03-01 23:05:54 +04:00
using namespace std ;
2012-12-11 12:26:00 +04:00
class Embedded_objects {
public :
2012-12-11 14:41:56 +04:00
enum Eenum {
kEnumConst = 16
} ;
2012-12-11 12:26:00 +04:00
class EmbeddedClasses ;
typedef EmbeddedClasses EmbeddedTypedef ;
class EmbeddedClasses {
public :
class Embedded1 { } ;
class Embedded2 { } ;
class Embedded3 { } ;
class Embedded4 { } ;
class Embedded5 { } ;
class Embedded6 { } ;
} ;
EmbeddedClasses m_embedded ;
EmbeddedClasses : : Embedded1 m_emb1 ;
EmbeddedClasses : : Embedded2 m_emb2 ;
EmbeddedClasses : : Embedded3 m_emb3 ;
EmbeddedTypedef : : Embedded4 m_emb4 ;
Embedded_objects : : EmbeddedClasses : : Embedded5 m_emb5 ;
Embedded_objects : : EmbeddedTypedef : : Embedded6 m_emb6 ;
typedef std : : vector < int > vecint ;
vecint : : iterator m_iter ;
2012-12-11 14:41:56 +04:00
const Eenum m_enum ;
2013-03-01 23:05:54 +04:00
typedef vector < int > vecint2 ;
vecint2 : : iterator m_iter2 ;
2012-12-11 12:26:00 +04:00
} ;
2013-03-01 23:05:54 +04:00
namespace NS1 {
namespace NS2 {
namespace NS3 {
class Point { } ;
class Inner3 {
public :
Point p1 ;
NS3 : : Point p2 ;
: : NS1 : : NS2 : : NS3 : : Point p3 ;
} ;
}
}
}
2012-09-05 13:37:39 +04:00
. rawInput 0
const cling : : LookupHelper & lookup = gCling - > getLookupHelper ( ) ;
2012-10-03 16:57:48 +04:00
const clang : : ASTContext & Ctx = gCling - > getSema ( ) . getASTContext ( ) ;
2013-09-03 16:27:29 +04:00
cling : : utils : : Transform : : Config transConfig ;
2013-01-06 21:06:31 +04:00
2013-09-03 16:27:29 +04:00
transConfig . m_toSkip . insert ( lookup . findType ( " Double32_t " ) . getTypePtr ( ) ) ;
2013-01-06 21:06:31 +04:00
using namespace std ;
2013-09-03 16:27:29 +04:00
transConfig . m_toSkip . insert ( lookup . findType ( " string " ) . getTypePtr ( ) ) ;
transConfig . m_toSkip . insert ( lookup . findType ( " std::string " ) . getTypePtr ( ) ) ;
2013-01-06 21:06:31 +04:00
2012-09-05 13:37:39 +04:00
const clang : : Type * t = 0 ;
2013-08-29 02:02:57 +04:00
const clang : : TypedefType * td = 0 ;
2012-09-05 13:37:39 +04:00
clang : : QualType QT ;
using namespace cling : : utils ;
2012-10-26 23:51:56 +04:00
// Test the behavior on a simple class
lookup . findScope ( " Details::Impl " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
//QT.getAsString().c_str()
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:15:35 +04:00
// CHECK: (const char *) "Details::Impl"
2012-10-26 23:51:56 +04:00
// Test the behavior for a class inside an anonymous namespace
lookup . findScope ( " InsideAnonymous " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
//QT.getAsString().c_str()c
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:15:35 +04:00
// CHECK: (const char *) "class <anonymous>::InsideAnonymous"
2012-10-26 23:51:56 +04:00
// The above result is not quite want we want, so the client must using
// the following:
// The scope suppression is required for getting rid of the anonymous part of the name of a class defined in an anonymous namespace.
// This gives us more control vs not using the clang::ElaboratedType and relying on the Policy.SuppressUnwrittenScope which would
// strip both the anonymous and the inline namespace names (and we probably do not want the later to be suppressed).
clang : : PrintingPolicy Policy ( Ctx . getPrintingPolicy ( ) ) ;
Policy . SuppressTagKeyword = true ; // Never get the class or struct keyword
Policy . SuppressScope = true ; // Force the scope to be coming from a clang::ElaboratedType.
std : : string name ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsStringInternal ( name , Policy ) ;
2012-10-26 23:51:56 +04:00
name . c_str ( )
2012-11-11 20:15:35 +04:00
// CHECK: (const char *) "InsideAnonymous"
2012-10-26 23:51:56 +04:00
2012-09-05 13:37:39 +04:00
// Test desugaring pointers types:
QT = lookup . findType ( " Int_t* " ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:15:35 +04:00
// CHECK:(const char *) "int *"
2012-09-05 13:37:39 +04:00
QT = lookup . findType ( " const IntPtr_t* " ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:15:35 +04:00
// CHECK:(const char *) "int *const *"
2012-09-05 13:37:39 +04:00
// Test desugaring reference (both r- or l- value) types:
QT = lookup . findType ( " const IntPtr_t& " ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK:(const char *) "int *const &"
2012-09-05 13:37:39 +04:00
//TODO: QT = lookup.findType("IntPtr_t[32]");
2012-10-19 17:33:38 +04:00
// To do: findType does not return the const below:
// Test desugaring reference (both r- or l- value) types:
2013-11-07 00:33:57 +04:00
// QT = lookup.findType("const IntRef_t");
// Transform::GetPartiallyDesugaredType(Ctx, QT, transConfig).getAsString().c_str()
2012-11-11 20:38:14 +04:00
// should print:(const char *) "int &const"
2013-11-07 00:33:57 +04:00
// but this is actually an illegal type:
// C++ [dcl.ref]p1:
// Cv-qualified references are ill-formed except when the
// cv-qualifiers are introduced through the use of a typedef
// (7.1.3) or of a template type argument (14.3), in which
// case the cv-qualifiers are ignored.
// So the following is the right behavior:
QT = lookup . findType ( " const IntRef_t " ) ;
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
// CHECK: (const char *) "int &"
2012-10-19 17:33:38 +04:00
// Test desugaring reference (both r- or l- value) types:
QT = lookup . findType ( " IntRef_t " ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK:(const char *) "int &"
2012-10-19 17:33:38 +04:00
2012-09-05 13:37:39 +04:00
//Desugar template parameters:
lookup . findScope ( " A<B<Double32_t, Int_t*> > " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK:(const char *) "A<B<Double32_t, int *> >"
2012-09-05 13:37:39 +04:00
2013-02-14 21:45:49 +04:00
lookup . findScope ( " A<B<Double32_t, std::size_t*> > " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2013-03-02 06:38:59 +04:00
// CHECK:(const char *) "A<B<Double32_t, unsigned {{long|int}} *> >"
2013-02-14 21:45:49 +04:00
2012-09-05 13:37:39 +04:00
lookup . findScope ( " CTD " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK: (const char *) "C<A<B<Double32_t, int> >, Double32_t>"
2012-09-05 13:37:39 +04:00
lookup . findScope ( " CTDConst " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK: (const char *) "C<A<B<const Double32_t, const int> >, Double32_t>"
2012-09-27 12:49:18 +04:00
lookup . findScope ( " std::pair<const std::string,int> " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK: (const char *) "std::pair<const std::string, int>"
2012-09-27 12:49:18 +04:00
lookup . findScope ( " NS::Array<NS::ArrayType<double> > " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK: (const char *) "NS::Array<NS::ArrayType<double> >"
2012-09-27 12:49:18 +04:00
lookup . findScope ( " NS::Array<NS::ArrayType<Double32_t> > " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK: (const char *) "NS::Array<NS::ArrayType<Double32_t> >"
2012-09-27 12:49:18 +04:00
lookup . findScope ( " NS::Container<Long_t>::Content " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK: (const char *) "NS::Container<long>::Content"
2012-09-27 12:49:18 +04:00
QT = lookup . findType ( " NS::Container<Long_t>::Value_t " ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK: (const char *) "long"
2012-09-27 12:49:18 +04:00
lookup . findScope ( " NS::Container<Long_t>::Content_t " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK: (const char *) "NS::Container<long>::Content"
2012-09-27 12:49:18 +04:00
lookup . findScope ( " NS::Container<Long_t>::Impl_t " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2013-03-01 16:29:22 +04:00
// CHECK: (const char *) "Details::Impl"
2012-09-27 12:49:18 +04:00
lookup . findScope ( " NS::Container<Double32_t>::Content " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK: (const char *) "NS::Container<Double32_t>::Content"
2012-09-27 12:49:18 +04:00
QT = lookup . findType ( " NS::Container<Double32_t>::Value_t " ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK: (const char *) "double"
2012-09-27 12:49:18 +04:00
// Really we would want it to say Double32_t but oh well.
lookup . findScope ( " NS::Container<Double32_t>::Content_t " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK: (const char *) "NS::Container<Double32_t>::Content"
2012-09-27 12:49:18 +04:00
lookup . findScope ( " NS::Container<Double32_t>::Impl_t " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2013-03-01 15:28:35 +04:00
// CHECK: (const char *) "Details::Impl"
2012-09-27 12:49:18 +04:00
lookup . findScope ( " NS::TDataPointF " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK: (const char *) "NS::TDataPoint<float>"
2012-09-27 12:49:18 +04:00
lookup . findScope ( " NS::TDataPointD32 " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2012-11-11 20:38:14 +04:00
// CHECK: (const char *) "NS::TDataPoint<Double32_t>"
2012-12-11 12:26:00 +04:00
2013-10-30 16:23:58 +04:00
lookup . findScope ( " NS::ArrayType<float,1> " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
// CHECK: (const char *) "NS::ArrayType<float, 1>"
lookup . findScope ( " NS::FArray " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
// CHECK: (const char *) "NS::ArrayType<float, 2>"
2013-11-06 20:04:33 +04:00
QT = lookup . findType ( " const NS::IntNS_t " ) ;
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
// CHECK: (const char *) "const int"
2013-02-14 21:45:49 +04:00
lookup . findScope ( " vector<Details::Impl>::value_type " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2013-02-14 21:45:49 +04:00
// CHECK: (const char *) "Details::Impl"
lookup . findScope ( " vector<Details::Impl>::iterator " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( )
2013-02-14 21:45:49 +04:00
// CHECK: (const char *) "std::vector<Details::Impl>::iterator"
2013-08-29 02:02:57 +04:00
lookup . findScope ( " vector<Details::Impl>::const_iterator " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
td = QT - > getAs < clang : : TypedefType > ( ) ;
clang : : TypedefNameDecl * tdDecl = td - > getDecl ( ) ;
QT = Ctx . getTypedefType ( tdDecl ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig , true ) . getAsString ( ) . c_str ( )
2013-08-29 02:02:57 +04:00
// CHECK: (const char *) "std::vector<Details::Impl, std::allocator<Details::Impl> >::const_iterator"
2012-12-11 12:26:00 +04:00
const clang : : Decl * decl = lookup . findScope ( " Embedded_objects " , & t ) ;
if ( decl ) {
const clang : : CXXRecordDecl * cxxdecl
= llvm : : dyn_cast < clang : : CXXRecordDecl > ( decl ) ;
if ( cxxdecl ) {
clang : : DeclContext : : decl_iterator iter = cxxdecl - > decls_begin ( ) ;
while ( * iter ) {
const clang : : Decl * mdecl = * iter ;
if ( const clang : : ValueDecl * vd = llvm : : dyn_cast < clang : : ValueDecl > ( mdecl ) ) {
clang : : QualType vdType = vd - > getType ( ) ;
2012-12-11 14:41:56 +04:00
name . clear ( ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , vdType , transConfig ) . getAsStringInternal ( name , Policy ) ;
2012-12-11 14:41:56 +04:00
std : : cout < < name . c_str ( ) < < std : : endl ;
2012-12-11 12:26:00 +04:00
}
+ + iter ;
}
}
}
2012-12-11 14:41:56 +04:00
// CHECK: Embedded_objects::EmbeddedClasses
// CHECK: Embedded_objects::EmbeddedClasses::Embedded1
// CHECK: Embedded_objects::EmbeddedClasses::Embedded2
// CHECK: Embedded_objects::EmbeddedClasses::Embedded3
// CHECK: Embedded_objects::EmbeddedClasses::Embedded4
// CHECK: Embedded_objects::EmbeddedClasses::Embedded5
// CHECK: Embedded_objects::EmbeddedClasses::Embedded6
2012-12-11 12:26:00 +04:00
// CHECK: std::vector<int>::iterator
2013-02-08 02:56:10 +04:00
// CHECK: const Embedded_objects::Eenum
2013-03-01 23:05:54 +04:00
// CHECK: std::vector<int>::iterator
2013-02-08 02:56:10 +04:00
// In the partial desugaring add support for the case where we have a type
// that point to an already completely desugared template instantiation in
// which case the type is a RecordDecl rather than a TemplateInstantationType
decl = lookup . findScope ( " std::pair<Details::Impl,std::vector<Details::Impl> > " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
std : : cout < < Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( ) < < std : : endl ;
2013-02-08 02:56:10 +04:00
// CHECK: std::pair<Details::Impl, std::vector<Details::Impl> >
if ( const clang : : RecordDecl * rdecl = llvm : : dyn_cast_or_null < clang : : RecordDecl > ( decl ) ) {
clang : : RecordDecl : : field_iterator field_iter = rdecl - > field_begin ( ) ;
// For some reason we can not call field_end:
// cling: root/interpreter/llvm/src/tools/clang/lib/CodeGen/CGCall.cpp:1839: void checkArgMatches(llvm::Value*, unsigned int&, llvm::FunctionType*): Assertion `Elt->getType() == FTy->getParamType(ArgNo)' failed.
// so just 'guess' the size
int i = 0 ;
while ( i < 2 ) {
name . clear ( ) ;
clang : : QualType fdType = field_iter - > getType ( ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , fdType , transConfig ) . getAsStringInternal ( name , Policy ) ;
2013-02-08 02:56:10 +04:00
std : : cout < < name . c_str ( ) < < std : : endl ;
+ + field_iter ;
+ + i ;
}
}
// CHECK: Details::Impl
// CHECK: std::vector<Details::Impl, std::allocator<Details::Impl> >
2012-12-11 12:26:00 +04:00
2013-03-01 23:05:54 +04:00
decl = lookup . findScope ( " NS1::NS2::NS3::Inner3 " , & t ) ;
if ( decl ) {
const clang : : CXXRecordDecl * cxxdecl
= llvm : : dyn_cast < clang : : CXXRecordDecl > ( decl ) ;
if ( cxxdecl ) {
clang : : DeclContext : : decl_iterator iter = cxxdecl - > decls_begin ( ) ;
while ( * iter ) {
const clang : : Decl * mdecl = * iter ;
if ( const clang : : ValueDecl * vd = llvm : : dyn_cast < clang : : ValueDecl > ( mdecl ) ) {
clang : : QualType vdType = vd - > getType ( ) ;
name . clear ( ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , vdType , transConfig ) . getAsStringInternal ( name , Policy ) ;
2013-03-01 23:05:54 +04:00
std : : cout < < name . c_str ( ) < < std : : endl ;
}
+ + iter ;
}
}
}
// CHECK: NS1::NS2::NS3::Point
// CHECK: NS1::NS2::NS3::Point
// CHECK: NS1::NS2::NS3::Point
2013-02-12 22:38:58 +04:00
decl = lookup . findScope ( " cmap<volatile int,volatile int> " , & t ) ;
QT = clang : : QualType ( t , 0 ) ;
2013-09-03 16:27:29 +04:00
std : : cout < < Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( ) < < std : : endl ;
2013-02-12 22:38:58 +04:00
if ( const clang : : RecordDecl * rdecl = llvm : : dyn_cast_or_null < clang : : RecordDecl > ( decl ) ) {
QT = clang : : QualType ( rdecl - > getTypeForDecl ( ) , 0 ) ;
2013-09-03 16:27:29 +04:00
std : : cout < < Transform : : GetPartiallyDesugaredType ( Ctx , QT , transConfig ) . getAsString ( ) . c_str ( ) < < std : : endl ;
2013-02-12 22:38:58 +04:00
clang : : RecordDecl : : field_iterator field_iter = rdecl - > field_begin ( ) ;
// For some reason we can not call field_end:
// cling: root/interpreter/llvm/src/tools/clang/lib/CodeGen/CGCall.cpp:1839: void checkArgMatches(llvm::Value*, unsigned int&, llvm::FunctionType*): Assertion `Elt->getType() == FTy->getParamType(ArgNo)' failed.
// so just 'guess' the size
int i = 0 ;
while ( i < 2 ) {
name . clear ( ) ;
clang : : QualType fdType = field_iter - > getType ( ) ;
2013-09-03 16:27:29 +04:00
Transform : : GetPartiallyDesugaredType ( Ctx , fdType , transConfig ) . getAsStringInternal ( name , Policy ) ;
2013-02-12 22:38:58 +04:00
std : : cout < < name . c_str ( ) < < std : : endl ;
+ + field_iter ;
+ + i ;
}
}
// CHECK: cmap<volatile int, volatile int>
// CHECK: cmap<volatile int, volatile int, std::less<volatile int>, std::allocator<std::pair<const volatile int, volatile int> > >
// CHECK: volatile int
// CHECK: const volatile int