704 clang::QualType
toSkip =
lh.findType(
name, cling::LookupHelper::WithDiagnostics);
705 if (
const clang::Type* T =
toSkip.getTypePtr()) {
706 const clang::TypedefType *
tt = llvm::dyn_cast<clang::TypedefType>(T);
708 clang::Decl* D =
tt->getDecl();
709 fConfig.m_toSkip.insert(D);
711 clang::QualType
canon =
toSkip->getCanonicalTypeInternal();
712 fConfig.m_toReplace.insert(std::make_pair(
canon.getTypePtr(),T));
714 fTypeWithAlternative.insert(T);
727 keepTypedef(
lh,
"Double32_t");
728 keepTypedef(
lh,
"Float16_t");
729 keepTypedef(
lh,
"Long64_t",
true);
730 keepTypedef(
lh,
"ULong64_t",
true);
732 clang::QualType
toSkip =
lh.findType(
"string", cling::LookupHelper::WithDiagnostics);
734 if (
const clang::TypedefType* TT
735 = llvm::dyn_cast_or_null<clang::TypedefType>(
toSkip.getTypePtr()))
736 fConfig.m_toSkip.insert(TT->getDecl());
738 toSkip =
lh.findType(
"std::string", cling::LookupHelper::WithDiagnostics);
740 if (
const clang::TypedefType* TT
741 = llvm::dyn_cast_or_null<clang::TypedefType>(
toSkip.getTypePtr()))
742 fConfig.m_toSkip.insert(TT->getDecl());
744 clang::QualType
canon =
toSkip->getCanonicalTypeInternal();
745 fConfig.m_toReplace.insert(std::make_pair(
canon.getTypePtr(),
toSkip.getTypePtr()));
820 const clang::CXXRecordDecl *context,
const cling::Interpreter &
interp)
826 if (!cl->getDefinition() || !cl->isCompleteDefinition()) {
834 if (!base->hasDefinition()) {
838 return cl->isDerivedFrom(base);
1066 const cling::LookupHelper&
lh =
interpreter.getLookupHelper();
1075 return EIOCtorCategory::kAbsent;
1078 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
1079 for (
auto iter = cl->ctor_begin(), end = cl->ctor_end(); iter != end; ++iter)
1081 if ((iter->getAccess() != clang::AS_public) || (iter->getNumParams() != 1))
1085 clang::QualType
argType((*iter->param_begin())->getType());
1089 if (
argType->isPointerType()) {
1092 }
else if (
argType->isReferenceType()) {
1099 const clang::CXXRecordDecl *
argDecl =
argType->getAsCXXRecordDecl();
1106 std::string
clarg(
"class ");
1113 return EIOCtorCategory::kAbsent;
1473 std::stringstream
dims;
1476 const clang::ASTContext&
astContext = cl.getASTContext();
1479 for(clang::RecordDecl::field_iterator
field_iter = cl.field_begin(), end = cl.field_end();
1493 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
fieldType.getTypePtr());
1495 dims <<
"[" <<
arrayType->getSize().getLimitedValue() <<
"]";
1497 arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual());
1507 for(clang::CXXRecordDecl::base_class_const_iterator iter = cl.bases_begin(), end = cl.bases_end();
1510 std::string
basename( iter->getType()->getAsCXXRecordDecl()->getNameAsString() );
1584 while (llvm::isa<clang::PointerType>(
instanceType.getTypePtr())
1585 || llvm::isa<clang::ReferenceType>(
instanceType.getTypePtr()))
1590 const clang::ElaboratedType* etype
1591 = llvm::dyn_cast<clang::ElaboratedType>(
instanceType.getTypePtr());
1593 instanceType = clang::QualType(etype->getNamedType().getTypePtr(),0);
1607 if (
clxx &&
clxx->getTemplateSpecializationKind() != clang::TSK_Undeclared) {
1609 const clang::TemplateSpecializationType*
TST
1610 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instanceType.getTypePtr());
1617 for (
const clang::TemplateArgument &
TA :
TST->template_arguments()) {
1618 if (
TA.getKind() == clang::TemplateArgument::Type) {
1737 const clang::CXXRecordDecl *
decl,
1738 const cling::Interpreter &
interp,
1747 std::string
csymbol = classname;
1761 bool isStd = TMetaUtils::IsStdClass(*
decl);
1762 const cling::LookupHelper&
lh =
interp.getLookupHelper();
1772 <<
" static void " <<
mappedname.c_str() <<
"_TClassManip(TClass*);\n";
1790 finalString <<
" static void delete_" <<
mappedname.c_str() <<
"(void *p);" <<
"\n" <<
" static void deleteArray_" <<
mappedname.c_str() <<
"(void *p);" <<
"\n" <<
" static void destruct_" <<
mappedname.c_str() <<
"(void *p);" <<
"\n";
1793 finalString <<
" static void directoryAutoAdd_" <<
mappedname.c_str() <<
"(void *obj, TDirectory *dir);" <<
"\n";
1796 finalString <<
" static void streamer_" <<
mappedname.c_str() <<
"(TBuffer &buf, void *obj);" <<
"\n";
1799 finalString <<
" static void conv_streamer_" <<
mappedname.c_str() <<
"(TBuffer &buf, void *obj, const TClass*);" <<
"\n";
1802 finalString <<
" static Long64_t merge_" <<
mappedname.c_str() <<
"(void *obj, TCollection *coll,TFileMergeInfo *info);" <<
"\n";
1805 finalString <<
" static void reset_" <<
mappedname.c_str() <<
"(void *obj, TFileMergeInfo *info);" <<
"\n";
1824 finalString <<
"\n // Schema evolution read functions\n";
1825 std::list<ROOT::SchemaRuleMap_t>::iterator
rIt =
rulesIt1->second.fRules.
begin();
1843 if(
rIt->find(
"code" ) !=
rIt->
end() ) {
1859 finalString <<
"\n // Schema evolution read raw functions\n";
1860 std::list<ROOT::SchemaRuleMap_t>::iterator
rIt =
rulesIt2->second.fRules.
begin();
1886 finalString <<
"\n" <<
" // Function generating the singleton type initializer" <<
"\n";
1888 finalString <<
" static TGenericClassInfo *GenerateInitInstanceLocal(const " <<
csymbol <<
"*)" <<
"\n" <<
" {" <<
"\n";
1894 finalString <<
" static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< " <<
csymbol <<
" >(nullptr);" <<
"\n";
1897 finalString <<
" static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(" <<
csymbol <<
"));" <<
"\n";
1899 finalString <<
" static ::ROOT::TGenericClassInfo " <<
"\n" <<
" instance(\"" << classname.c_str() <<
"\", ";
1912 static const char *
versionFunc =
"GetClassVersion";
1916 std::string
proto = classname +
"*";
1917 const clang::Decl*
ctxt = llvm::dyn_cast<clang::Decl>((*cl).getDeclContext());
1920 interp, cling::LookupHelper::NoDiagnostics);
1939 for (
unsigned int i=0; i<
filename.length(); i++) {
1944 <<
"," <<
"\n" <<
" typeid(" <<
csymbol
1945 <<
"), ::ROOT::Internal::DefineBehavior(ptr, ptr)," <<
"\n" <<
" ";
1968 finalString <<
" instance.SetDelete(&delete_" <<
mappedname.c_str() <<
");" <<
"\n" <<
" instance.SetDeleteArray(&deleteArray_" <<
mappedname.c_str() <<
");" <<
"\n" <<
" instance.SetDestructor(&destruct_" <<
mappedname.c_str() <<
");" <<
"\n";
1971 finalString <<
" instance.SetDirectoryAutoAdd(&directoryAutoAdd_" <<
mappedname.c_str() <<
");" <<
"\n";
1979 finalString <<
" instance.SetConvStreamerFunc(&conv_streamer_" <<
mappedname.c_str() <<
");" <<
"\n";
1988 finalString <<
" instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" <<
"Pushback" <<
"<Internal::TStdBitsetHelper< " << classname.c_str() <<
" > >()));" <<
"\n";
1991 }
else if (
stl != 0 &&
1994 int idx = classname.find(
"<");
2023 finalString <<
" instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" <<
methodTCP <<
"< " <<
classNameForIO.c_str() <<
" >()));" <<
"\n";
2033 finalString <<
"\n" <<
" instance.AdoptAlternate(::ROOT::AddClassAlternate(\""
2040 finalString <<
"\n" <<
" instance.AdoptAlternate(::ROOT::AddClassAlternate(\""
2050 finalString <<
"\n" <<
" ::ROOT::Internal::TSchemaHelper* rule;" <<
"\n";
2054 finalString <<
"\n" <<
" // the io read rules" <<
"\n" <<
" std::vector<::ROOT::Internal::TSchemaHelper> readrules(" <<
rulesIt1->second.size() <<
");" <<
"\n";
2056 finalString <<
" instance.SetReadRules( readrules );" <<
"\n";
2057 rulesIt1->second.fGenerated =
true;
2061 finalString <<
"\n" <<
" // the io read raw rules" <<
"\n" <<
" std::vector<::ROOT::Internal::TSchemaHelper> readrawrules(" <<
rulesIt2->second.size() <<
");" <<
"\n";
2063 finalString <<
" instance.SetReadRawRules( readrawrules );" <<
"\n";
2064 rulesIt2->second.fGenerated =
true;
2067 finalString <<
" return &instance;" <<
"\n" <<
" }" <<
"\n";
2071 finalString <<
" TGenericClassInfo *GenerateInitInstance(const " <<
csymbol <<
"*)" <<
"\n" <<
" {\n return GenerateInitInstanceLocal(static_cast<" <<
csymbol <<
"*>(nullptr));\n }" <<
"\n";
2074 finalString <<
" // Static variable to force the class initialization" <<
"\n";
2078 finalString <<
" static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal(static_cast<const " <<
csymbol <<
"*>(nullptr)); R__UseDummy(_R__UNIQUE_DICT_(Init));" <<
"\n";
2081 finalString <<
"\n" <<
" // Dictionary for non-ClassDef classes" <<
"\n"
2082 <<
" static TClass *" <<
mappedname <<
"_Dictionary() {\n"
2083 <<
" TClass* theClass ="
2084 <<
"::ROOT::GenerateInitInstanceLocal(static_cast<const " <<
csymbol <<
"*>(nullptr))->GetClass();\n"
2085 <<
" " <<
mappedname <<
"_TClassManip(theClass);\n";
2096 if (
decl->hasAttrs()){
2098 for (clang::Decl::attr_iterator
attrIt =
decl->attr_begin();
2115 manipString+=
" theClass->CreateAttributeMap();\n";
2116 manipString+=
" TDictAttributeMap* attrMap( theClass->GetAttributeMap() );\n";
2127 if (!(!(*internalDeclIt)->isImplicit()
2148 TMetaUtils::Error(
nullptr,
"Cannot convert field declaration to clang::NamedDecl");
2164 if (
attrName == propNames::comment ||
2166 attrName == propNames::ioname )
continue;
2191 finalString <<
"} // end of namespace ROOT" <<
"\n" <<
"\n";
3011 const clang::ASTContext&
Ctx =
interpreter.getCI()->getASTContext();
3017 if (llvm::isa<clang::PointerType>(
instanceType.getTypePtr())) {
3031 if (llvm::isa<clang::ReferenceType>(
instanceType.getTypePtr())) {
3051 clang::NestedNameSpecifier *prefix =
nullptr;
3053 const clang::ElaboratedType* etype
3054 = llvm::dyn_cast<clang::ElaboratedType>(
instanceType.getTypePtr());
3059 instanceType = clang::QualType(etype->getNamedType().getTypePtr(),0);
3065 const clang::TemplateSpecializationType*
TST
3066 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instanceType.getTypePtr());
3068 const clang::ClassTemplateSpecializationDecl*
TSTdecl
3069 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
instanceType.getTypePtr()->getAsCXXRecordDecl());
3085 clang::TemplateDecl *Template =
TSTdecl->getSpecializedTemplate()->getMostRecentDecl();
3086 clang::TemplateParameterList *Params = Template->getTemplateParameters();
3093 llvm::SmallVector<clang::TemplateArgument, 4>
desArgs;
3094 llvm::SmallVector<clang::TemplateArgument, 4>
canonArgs;
3103 if (
I->getKind() == clang::TemplateArgument::Template) {
3110 clang::NamespaceDecl* ns = clang::dyn_cast<clang::NamespaceDecl>(
declCtxt);
3111 clang::NestedNameSpecifier*
nns;
3113 nns = cling::utils::TypeName::CreateNestedNameSpecifier(
Ctx, ns);
3114 }
else if (clang::TagDecl*
TD = llvm::dyn_cast<clang::TagDecl>(
declCtxt)) {
3115 nns = cling::utils::TypeName::CreateNestedNameSpecifier(
Ctx,
TD,
false );
3122 if (clang::UsingShadowDecl *
USD =
templateName.getAsUsingShadowDecl())
3132 if (
I->getKind() != clang::TemplateArgument::Type) {
3137 clang::QualType
SubTy =
I->getAsType();
3159 if (
templateArg.getKind() != clang::TemplateArgument::Type) {
3165 clang::SourceLocation
TemplateLoc = Template->getSourceRange ().getBegin();
3168 clang::TemplateTypeParmDecl *
TTP = llvm::dyn_cast<clang::TemplateTypeParmDecl>(*
Param);
3171 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
3173 clang::TemplateArgumentLoc
ArgType = S.SubstDefaultTemplateArgumentIfAvailable(
3183 if (
ArgType.getArgument().isNull()
3184 ||
ArgType.getArgument().getKind() != clang::TemplateArgument::Type) {
3186 "Template parameter substitution failed for %s around %s\n",
3206 TST->getCanonicalTypeInternal());
3235 llvm::StringRef title;
3238 if (clang::AnnotateAttr *A =
m.getAttr<clang::AnnotateAttr>())
3239 title = A->getAnnotation();
3253 if (title.size() == 0 || (title[0] !=
'['))
return llvm::StringRef();
3255 if (
rightbracket == llvm::StringRef::npos)
return llvm::StringRef();
3274 char *current =
const_cast<char*
>(
working.c_str());
3280 for(i=0;i<
strlen(current);i++) {
3288 return llvm::StringRef();
3293 const clang::CXXRecordDecl *
parent_clxx = llvm::dyn_cast<clang::CXXRecordDecl>(
m.getDeclContext());
3294 const clang::FieldDecl *
index1 =
nullptr;
3307 if (
field_iter->getNameAsString() ==
m.getNameAsString() ) {
3315 return llvm::StringRef();
3327 return llvm::StringRef();
3352 return llvm::StringRef();
3354 if ( found && (
index1->getAccess() == clang::AS_private) ) {
3359 return llvm::StringRef();
3368 return llvm::StringRef();
3450 const cling::Interpreter&
interp)
3480 using namespace clang;
3505 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>>(),
3520 assert(
decl.isFirstDecl() &&
"Couldn't trace back include from a decl"
3521 " that is not from an AST file");
3546 clang::OptionalFileEntryRef
FELong;
3548 for (llvm::sys::path::const_iterator
3561 &&
"Mismatched partitioning of file name!");
3565 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>>(),
3577 for (llvm::sys::path::reverse_iterator
3585 &&
"Mismatched partitioning of file name!");
3591 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>>(),
3594 nullptr,
nullptr ) ==
FELong) {
3635 clang::ClassTemplateDecl*&
ctd,
3636 clang::ClassTemplateSpecializationDecl*&
ctsd)
3638 using namespace clang;
3646 if (
theType->isPointerType()) {
3651 ctsd = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
rType->getDecl());
3653 ctd =
ctsd->getSpecializedTemplate();
3663 ctsd = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
qt->getAsCXXRecordDecl());
3665 ctd =
ctsd->getSpecializedTemplate();
3715 const clang::NamedDecl&
tPar,
3716 const cling::Interpreter&
interp,
3720 using namespace clang;
3725 if (!
ttpdPtr->hasDefaultArgument())
return false;
3747 const clang::ElaboratedType* etype
3748 = llvm::dyn_cast<clang::ElaboratedType>(
tParQualType.getTypePtr());
3750 tParQualType = clang::QualType(etype->getNamedType().getTypePtr(),0);
3751 etype = llvm::dyn_cast<clang::ElaboratedType>(
tParQualType.getTypePtr());
3755 llvm::dyn_cast<TemplateSpecializationType>(
tParQualType.getTypePtr());
3761 = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
tArgQualType->getAsCXXRecordDecl());
3779 clang::Sema& S =
interp.getCI()->getSema();
3780 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interp));
3781 llvm::SmallVector<clang::TemplateArgument, 4>
canonArgs;
3794 newArg.getKind() != clang::TemplateArgument::Type) {
3796 "Template parameter substitution failed!");
3800 = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
newArg.getAsType()->getAsCXXRecordDecl());
3915 const cling::Interpreter&
interp,
3919 using namespace clang;
3928 const int nArgsToKeep =
normCtxt.GetNargsToKeep(
ctd);
3938 if (llvm::isa<clang::PointerType>(
normalizedType.getTypePtr())) {
3951 if (llvm::isa<clang::ReferenceType>(
normalizedType.getTypePtr())) {
3970 clang::NestedNameSpecifier* prefix =
nullptr;
3972 const clang::ElaboratedType* etype
3973 = llvm::dyn_cast<clang::ElaboratedType>(
normalizedType.getTypePtr());
3979 normalizedType = clang::QualType(etype->getNamedType().getTypePtr(),0);
3987 clang::TemplateParameterList*
tpl =
rd->getTemplateParameters();
3988 if (
tpl->getMinRequiredArguments () <
tpl->size()) {
3995 Error(
"KeepNParams",
"Not found template default arguments\n");
4012 llvm::dyn_cast<TemplateSpecializationType>(
normalizedType.getTypePtr());
4018 const clang::ClassTemplateSpecializationDecl*
TSTdecl
4019 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
normalizedType.getTypePtr()->getAsCXXRecordDecl());
4027 llvm::SmallVector<TemplateArgument, 4>
argsToKeep;
4039 Error(
"KeepNParams",
"The parameter number %s is null.\n",
formal);
4061 if (
tParPtr->isTemplateParameterPack() ) {
4091 if (
argKind == clang::TemplateArgument::Type){
4094 }
else if (
argKind == clang::TemplateArgument::Integral){