24#include <unordered_set>
26#include "RConfigure.h"
34#include "clang/AST/ASTContext.h"
35#include "clang/AST/Attr.h"
36#include "clang/AST/CXXInheritance.h"
37#include "clang/AST/Decl.h"
38#include "clang/AST/DeclTemplate.h"
39#include "clang/AST/Mangle.h"
40#include "clang/AST/Type.h"
41#include "clang/AST/TypeVisitor.h"
42#include "clang/Frontend/CompilerInstance.h"
43#include "clang/Lex/HeaderSearch.h"
44#include "clang/Lex/ModuleMap.h"
45#include "clang/Lex/Preprocessor.h"
46#include "clang/Lex/PreprocessorOptions.h"
48#include "clang/Sema/Lookup.h"
49#include "clang/Sema/Sema.h"
50#include "clang/Sema/SemaDiagnostic.h"
52#include "cling/Interpreter/LookupHelper.h"
53#include "cling/Interpreter/Transaction.h"
54#include "cling/Interpreter/Interpreter.h"
55#include "cling/Utils/AST.h"
57#include "llvm/Support/Path.h"
58#include "llvm/Support/FileSystem.h"
63#define strncasecmp _strnicmp
83 using DeclsCont_t = TNormalizedCtxt::Config_t::SkipCollection;
100 bool replace =
false);
111 clang::NestedNameSpecifier*
scope,
114 if (!
scope)
return nullptr;
137static bool CheckDefinition(
const clang::CXXRecordDecl *cl,
const clang::CXXRecordDecl *context)
139 if (!cl->hasDefinition()) {
142 "Missing definition for class %s, please #include its header in the header of %s\n",
143 cl->getName().str().c_str(), context->getName().str().c_str());
146 "Missing definition for class %s\n",
147 cl->getName().str().c_str());
160 clang::NestedNameSpecifier *
scope,
163 if (!
scope)
return nullptr;
185 const clang::BuiltinType *
builtin = llvm::dyn_cast<clang::BuiltinType>(
type->getCanonicalTypeInternal().getTypePtr());
205 clang::ASTContext &
C = cl.getASTContext();
206 clang::DeclarationName
DName = &
C.Idents.get(
what);
207 auto R = cl.lookup(
DName);
208 for (
const clang::NamedDecl *D :
R)
220 clang::LookupResult
R(
SemaR,
DName, clang::SourceLocation(),
221 clang::Sema::LookupOrdinaryName,
222 clang::Sema::ForExternalRedeclaration);
223 SemaR.LookupInSuper(
R, &
const_cast<clang::CXXRecordDecl&
>(cl));
226 return llvm::dyn_cast<const clang::FieldDecl>(
R.getFoundDecl());
232 ? cling::LookupHelper::WithDiagnostics
233 : cling::LookupHelper::NoDiagnostics;
240namespace TMetaUtils {
249 Error(
"TNormalizedCtxt::AddTemplAndNargsToKeep",
250 "Tring to specify a number of template arguments to keep for a null pointer. Exiting without assigning any value.\n");
254 const clang::ClassTemplateDecl*
canTempl =
templ->getCanonicalDecl();
259 const std::string
i_str (std::to_string(i));
261 Error(
"TNormalizedCtxt::AddTemplAndNargsToKeep",
262 "Tring to specify for template %s %s arguments to keep, while before this number was %s\n",
263 canTempl->getNameAsString().c_str(),
276 const clang::ClassTemplateDecl*
constTempl =
templ->getCanonicalDecl();
327 std::unique_ptr<clang::MangleContext>
mangleCtx(
rDecl->getASTContext().createMangleContext());
331 if (
const clang::TypeDecl*
TD = llvm::dyn_cast<clang::TypeDecl>(
rDecl)) {
332 mangleCtx->mangleCXXRTTI(clang::QualType(
TD->getTypeForDecl(), 0),
sstr);
358 "Demangled typeinfo name '%s' does not contain `RTTI Type Descriptor'\n",
362 "Demangled typeinfo name '%s' does not start with 'typeinfo for'\n",
378 const clang::RecordDecl *
decl,
398 const clang::RecordDecl *
decl,
418 "Could not remove the requested template arguments.\n");
428 const clang::RecordDecl *
decl,
452 const clang::RecordDecl *
decl,
504 if (
tname.empty())
return false;
518 if (!
dest.isNull() && (
dest != t)) {
535 if (!
dest.isNull() && (
dest != t) &&
554 const clang::NamespaceDecl *
nsdecl = llvm::dyn_cast<clang::NamespaceDecl>(
scope);
567 if (
tname.empty())
return false;
596 clang::PrintingPolicy
policy(
fInterpreter->getCI()->getASTContext().getPrintingPolicy());
597 policy.SuppressTagKeyword =
true;
598 policy.SuppressScope =
true;
613 for(
unsigned int i = 1; i<
result.length(); ++i) {
625 }
else if ( (i+1) <
result.length() &&
663 clang::QualType
toSkip =
lh.findType(
name, cling::LookupHelper::WithDiagnostics);
664 if (
const clang::Type* T =
toSkip.getTypePtr()) {
665 const clang::TypedefType *
tt = llvm::dyn_cast<clang::TypedefType>(T);
667 clang::Decl* D =
tt->getDecl();
668 fConfig.m_toSkip.insert(D);
670 clang::QualType
canon =
toSkip->getCanonicalTypeInternal();
671 fConfig.m_toReplace.insert(std::make_pair(
canon.getTypePtr(),T));
673 fTypeWithAlternative.insert(T);
686 keepTypedef(
lh,
"Double32_t");
687 keepTypedef(
lh,
"Float16_t");
688 keepTypedef(
lh,
"Long64_t",
true);
689 keepTypedef(
lh,
"ULong64_t",
true);
691 clang::QualType
toSkip =
lh.findType(
"string", cling::LookupHelper::WithDiagnostics);
693 if (
const clang::TypedefType* TT
694 = llvm::dyn_cast_or_null<clang::TypedefType>(
toSkip.getTypePtr()))
695 fConfig.m_toSkip.insert(TT->getDecl());
697 toSkip =
lh.findType(
"std::string", cling::LookupHelper::WithDiagnostics);
699 if (
const clang::TypedefType* TT
700 = llvm::dyn_cast_or_null<clang::TypedefType>(
toSkip.getTypePtr()))
701 fConfig.m_toSkip.insert(TT->getDecl());
703 clang::QualType
canon =
toSkip->getCanonicalTypeInternal();
704 fConfig.m_toReplace.insert(std::make_pair(
canon.getTypePtr(),
toSkip.getTypePtr()));
715 return (cl.getKind() == clang::Decl::ClassTemplatePartialSpecialization
716 || cl.getKind() == clang::Decl::ClassTemplateSpecialization);
723 const cling::Interpreter&
interp)
725 clang::Sema* S = &
interp.getSema();
726 const clang::NamedDecl*
ND = cling::utils::Lookup::Named(S,
name, cl);
727 if (
ND == (clang::NamedDecl*)-1)
728 return (clang::FunctionDecl*)-1;
729 return llvm::dyn_cast_or_null<clang::FunctionDecl>(
ND);
735const clang::CXXRecordDecl *
739 const cling::LookupHelper&
lh =
interp.getLookupHelper();
742 const clang::CXXRecordDecl *
result
743 = llvm::dyn_cast_or_null<clang::CXXRecordDecl>
750 result = llvm::dyn_cast_or_null<clang::CXXRecordDecl>
761 clang::QualType
qType(cl->getTypeForDecl(),0);
769 clang::Sema& S =
interp.getCI()->getSema();
772 cling::Interpreter::PushTransactionRAII
RAII(
const_cast<cling::Interpreter*
>(&
interp));
773 return S.RequireCompleteType(
Loc, Type, clang::diag::err_incomplete_type);
779 const clang::CXXRecordDecl *context,
const cling::Interpreter &
interp)
785 if (!cl->getDefinition() || !cl->isCompleteDefinition()) {
793 if (!base->hasDefinition()) {
797 return cl->isDerivedFrom(base);
809 const clang::NamedDecl *base
813 return IsBase(
CRD, llvm::dyn_cast<clang::CXXRecordDecl>( base ),
814 llvm::dyn_cast<clang::CXXRecordDecl>(
m.getDeclContext()),
interp);
823 const clang::QualType &
qti,
825 const cling::Interpreter &
interp,
833 kBIT_ISSTRING = 0x40000000,
840 const clang::Type &
ti( *
qti.getTypePtr() );
863 if (
tiName ==
"string")
kase |= kBIT_ISSTRING;
864 if (
tiName ==
"string*")
kase |= kBIT_ISSTRING;
868 tcl =
" internal error in rootcling ";
893 <<
" R__b >> readtemp;" << std::endl
894 <<
" " <<
R__t <<
" = static_cast<" <<
tiName <<
">(readtemp);" << std::endl;
906 finalString <<
" if (R__b.GetInfo() && R__b.GetInfo()->GetOldVersion()<=3) {" << std::endl;
908 finalString <<
" R__ASSERT(0);// " <<
objType <<
" is abstract. We assume that older file could not be produced using this streaming method." << std::endl;
911 <<
" " <<
R__t <<
"->Streamer(R__b);" << std::endl;
914 <<
" " <<
R__t <<
" = (" <<
tiName <<
")R__b.ReadObjectAny(" <<
tcl <<
");" << std::endl
915 <<
" }" << std::endl;
921 <<
" R__str.Streamer(R__b);" << std::endl
922 <<
" " <<
R__t <<
" = R__str.Data();}" << std::endl;
928 <<
" R__str.Streamer(R__b);" << std::endl
929 <<
" " <<
R__t <<
" = new string(R__str.Data());}" << std::endl;
956 finalString <<
" R__b >> *reinterpret_cast<Int_t*>(ptr_enum); }" << std::endl;
972 finalString <<
" {TString R__str(" <<
R__t <<
".c_str());" << std::endl
973 <<
" R__str.Streamer(R__b);};" << std::endl;
978 finalString <<
" {TString R__str(" <<
R__t <<
"->c_str());" << std::endl
979 <<
" R__str.Streamer(R__b);}" << std::endl;
1001 clang::CXXRecordDecl*
ncCl =
const_cast<clang::CXXRecordDecl*
>(cl);
1004 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
1007 if (
Ctor->getAccess() == clang::AS_public && !
Ctor->isDeleted()) {
1025 const cling::LookupHelper&
lh =
interpreter.getLookupHelper();
1034 return EIOCtorCategory::kAbsent;
1037 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
1038 for (
auto iter = cl->ctor_begin(), end = cl->ctor_end(); iter != end; ++iter)
1040 if ((iter->getAccess() != clang::AS_public) || (iter->getNumParams() != 1))
1044 clang::QualType
argType((*iter->param_begin())->getType());
1048 if (
argType->isPointerType()) {
1051 }
else if (
argType->isReferenceType()) {
1058 const clang::CXXRecordDecl *
argDecl =
argType->getAsCXXRecordDecl();
1065 std::string
clarg(
"class ");
1072 return EIOCtorCategory::kAbsent;
1085 if (!
ioctortype.GetType() && (!arg || !arg[0])) {
1099 const cling::Interpreter &
interp,
1102 const clang::FunctionDecl*
funcD
1104 diagnose ? cling::LookupHelper::WithDiagnostics
1105 : cling::LookupHelper::NoDiagnostics);
1107 return llvm::dyn_cast<const clang::CXXMethodDecl>(
funcD);
1116 namespace TMetaUtils {
1119 const cling::LookupHelper&
lh =
interp.getLookupHelper();
1138 const cling::Interpreter &
interp)
1140 if (cl->isAbstract())
return false;
1146 if (EIOCtorCategory::kAbsent ==
ioCtorCat)
1156 if (EIOCtorCategory::kIOPtrType ==
ioCtorCat) {
1158 }
else if (EIOCtorCategory::kIORefType ==
ioCtorCat) {
1162 arg +=
")nullptr )";
1165 const clang::CXXMethodDecl *
method
1167 cling::LookupHelper::NoDiagnostics);
1168 if (
method &&
method->getAccess() != clang::AS_public) {
1182 const cling::Interpreter&
interp)
1184 if (!cl)
return false;
1186 if (cl->hasUserDeclaredDestructor()) {
1188 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interp));
1189 clang::CXXDestructorDecl *
dest = cl->getDestructor();
1191 return (
dest->getAccess() == clang::AS_public);
1205 const cling::Interpreter &
interp,
1208 const clang::CXXMethodDecl *
method
1210 diagnose ? cling::LookupHelper::WithDiagnostics
1211 : cling::LookupHelper::NoDiagnostics);
1212 return (
method &&
method->getAccess() == clang::AS_public);
1223 const char *
proto =
"TDirectory*";
1224 const char *
name =
"DirectoryAutoAdd";
1238 const char *
proto =
"TCollection*,TFileMergeInfo*";
1239 const char *
name =
"Merge";
1252 const char *
proto =
"TCollection*";
1253 const char *
name =
"Merge";
1268 const char *
proto =
"TFileMergeInfo*";
1269 const char *
name =
"ResetAfterMerge";
1279 const clang::CXXRecordDecl*
clxx,
1280 const cling::Interpreter &
interp,
1283 static const char *
proto =
"TBuffer&";
1285 const clang::CXXMethodDecl *
method
1287 cling::LookupHelper::NoDiagnostics);
1298 const clang::CXXRecordDecl*
clxx,
1299 const cling::Interpreter &
interp,
1302 static const char *
proto =
"TBuffer&,TClass*";
1304 const clang::CXXMethodDecl *
method
1306 cling::LookupHelper::NoDiagnostics);
1371 llvm::raw_string_ostream stream(
qual_name);
1372 clang::PrintingPolicy
policy( cl.getASTContext().getPrintingPolicy() );
1373 policy.SuppressTagKeyword =
true;
1374 policy.SuppressUnwrittenScope =
true;
1376 cl.getNameForDiagnostic(stream,
policy,
true);
1432 std::stringstream
dims;
1435 const clang::ASTContext&
astContext = cl.getASTContext();
1438 for(clang::RecordDecl::field_iterator
field_iter = cl.field_begin(), end = cl.field_end();
1452 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
fieldType.getTypePtr());
1454 dims <<
"[" <<
arrayType->getSize().getLimitedValue() <<
"]";
1456 arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual());
1466 for(clang::CXXRecordDecl::base_class_const_iterator iter = cl.bases_begin(), end = cl.bases_end();
1469 std::string
basename( iter->getType()->getAsCXXRecordDecl()->getNameAsString() );
1479 const cling::Interpreter &
interp,
1483 diagnose ? cling::LookupHelper::WithDiagnostics
1484 : cling::LookupHelper::NoDiagnostics);
1543 while (llvm::isa<clang::PointerType>(
instanceType.getTypePtr())
1544 || llvm::isa<clang::ReferenceType>(
instanceType.getTypePtr()))
1549 const clang::ElaboratedType* etype
1550 = llvm::dyn_cast<clang::ElaboratedType>(
instanceType.getTypePtr());
1552 instanceType = clang::QualType(etype->getNamedType().getTypePtr(),0);
1566 if (
clxx &&
clxx->getTemplateSpecializationKind() != clang::TSK_Undeclared) {
1568 const clang::TemplateSpecializationType*
TST
1569 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instanceType.getTypePtr());
1576 for (
const clang::TemplateArgument &
TA :
TST->template_arguments()) {
1577 if (
TA.getKind() == clang::TemplateArgument::Type) {
1589 const cling::Interpreter &
interp,
1592 const clang::CXXRecordDecl *
clxx = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
1593 if (!
clxx ||
clxx->getTemplateSpecializationKind() == clang::TSK_Undeclared)
return false;
1596 cling::LookupHelper::WithDiagnostics);
1610 clang::AnnotateAttr*
annAttr = clang::dyn_cast<clang::AnnotateAttr>(
attribute);
1653 for (clang::Decl::attr_iterator
attrIt =
decl.attr_begin();
1655 clang::AnnotateAttr*
annAttr = clang::dyn_cast<clang::AnnotateAttr>(*
attrIt);
1659 std::pair<llvm::StringRef,llvm::StringRef> split =
attribute.split(propNames::separator.c_str());
1660 if (split.first !=
propName.c_str())
continue;
1676 for (clang::Decl::attr_iterator
attrIt =
decl.attr_begin();
1678 clang::AnnotateAttr*
annAttr = clang::dyn_cast<clang::AnnotateAttr>(*
attrIt);
1682 std::pair<llvm::StringRef,llvm::StringRef> split =
attribute.split(propNames::separator.c_str());
1683 if (split.first !=
propName.c_str())
continue;
1685 return split.second.getAsInteger(10,
propValue);
1696 const clang::CXXRecordDecl *
decl,
1697 const cling::Interpreter &
interp,
1706 std::string
csymbol = classname;
1720 bool isStd = TMetaUtils::IsStdClass(*
decl);
1721 const cling::LookupHelper&
lh =
interp.getLookupHelper();
1731 <<
" static void " <<
mappedname.c_str() <<
"_TClassManip(TClass*);\n";
1749 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";
1752 finalString <<
" static void directoryAutoAdd_" <<
mappedname.c_str() <<
"(void *obj, TDirectory *dir);" <<
"\n";
1755 finalString <<
" static void streamer_" <<
mappedname.c_str() <<
"(TBuffer &buf, void *obj);" <<
"\n";
1758 finalString <<
" static void conv_streamer_" <<
mappedname.c_str() <<
"(TBuffer &buf, void *obj, const TClass*);" <<
"\n";
1761 finalString <<
" static Long64_t merge_" <<
mappedname.c_str() <<
"(void *obj, TCollection *coll,TFileMergeInfo *info);" <<
"\n";
1764 finalString <<
" static void reset_" <<
mappedname.c_str() <<
"(void *obj, TFileMergeInfo *info);" <<
"\n";
1783 finalString <<
"\n // Schema evolution read functions\n";
1802 if(
rIt->find(
"code" ) !=
rIt->
end() ) {
1818 finalString <<
"\n // Schema evolution read raw functions\n";
1845 finalString <<
"\n" <<
" // Function generating the singleton type initializer" <<
"\n";
1847 finalString <<
" static TGenericClassInfo *GenerateInitInstanceLocal(const " <<
csymbol <<
"*)" <<
"\n" <<
" {" <<
"\n";
1853 finalString <<
" static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< " <<
csymbol <<
" >(nullptr);" <<
"\n";
1856 finalString <<
" static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(" <<
csymbol <<
"));" <<
"\n";
1858 finalString <<
" static ::ROOT::TGenericClassInfo " <<
"\n" <<
" instance(\"" << classname.c_str() <<
"\", ";
1871 static const char *
versionFunc =
"GetClassVersion";
1875 std::string
proto = classname +
"*";
1876 const clang::Decl*
ctxt = llvm::dyn_cast<clang::Decl>((*cl).getDeclContext());
1879 interp, cling::LookupHelper::NoDiagnostics);
1898 for (
unsigned int i=0; i<
filename.length(); i++) {
1903 <<
"," <<
"\n" <<
" typeid(" <<
csymbol
1904 <<
"), ::ROOT::Internal::DefineBehavior(ptr, ptr)," <<
"\n" <<
" ";
1927 finalString <<
" instance.SetDelete(&delete_" <<
mappedname.c_str() <<
");" <<
"\n" <<
" instance.SetDeleteArray(&deleteArray_" <<
mappedname.c_str() <<
");" <<
"\n" <<
" instance.SetDestructor(&destruct_" <<
mappedname.c_str() <<
");" <<
"\n";
1930 finalString <<
" instance.SetDirectoryAutoAdd(&directoryAutoAdd_" <<
mappedname.c_str() <<
");" <<
"\n";
1938 finalString <<
" instance.SetConvStreamerFunc(&conv_streamer_" <<
mappedname.c_str() <<
");" <<
"\n";
1947 finalString <<
" instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" <<
"Pushback" <<
"<Internal::TStdBitsetHelper< " << classname.c_str() <<
" > >()));" <<
"\n";
1950 }
else if (
stl != 0 &&
1953 int idx = classname.find(
"<");
1982 finalString <<
" instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" <<
methodTCP <<
"< " <<
classNameForIO.c_str() <<
" >()));" <<
"\n";
1992 finalString <<
"\n" <<
" instance.AdoptAlternate(::ROOT::AddClassAlternate(\""
1999 finalString <<
"\n" <<
" instance.AdoptAlternate(::ROOT::AddClassAlternate(\""
2009 finalString <<
"\n" <<
" ::ROOT::Internal::TSchemaHelper* rule;" <<
"\n";
2013 finalString <<
"\n" <<
" // the io read rules" <<
"\n" <<
" std::vector<::ROOT::Internal::TSchemaHelper> readrules(" <<
rulesIt1->second.size() <<
");" <<
"\n";
2015 finalString <<
" instance.SetReadRules( readrules );" <<
"\n";
2019 finalString <<
"\n" <<
" // the io read raw rules" <<
"\n" <<
" std::vector<::ROOT::Internal::TSchemaHelper> readrawrules(" <<
rulesIt2->second.size() <<
");" <<
"\n";
2021 finalString <<
" instance.SetReadRawRules( readrawrules );" <<
"\n";
2024 finalString <<
" return &instance;" <<
"\n" <<
" }" <<
"\n";
2028 finalString <<
" TGenericClassInfo *GenerateInitInstance(const " <<
csymbol <<
"*)" <<
"\n" <<
" {\n return GenerateInitInstanceLocal(static_cast<" <<
csymbol <<
"*>(nullptr));\n }" <<
"\n";
2031 finalString <<
" // Static variable to force the class initialization" <<
"\n";
2035 finalString <<
" static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal(static_cast<const " <<
csymbol <<
"*>(nullptr)); R__UseDummy(_R__UNIQUE_DICT_(Init));" <<
"\n";
2038 finalString <<
"\n" <<
" // Dictionary for non-ClassDef classes" <<
"\n"
2039 <<
" static TClass *" <<
mappedname <<
"_Dictionary() {\n"
2040 <<
" TClass* theClass ="
2041 <<
"::ROOT::GenerateInitInstanceLocal(static_cast<const " <<
csymbol <<
"*>(nullptr))->GetClass();\n"
2042 <<
" " <<
mappedname <<
"_TClassManip(theClass);\n";
2053 if (
decl->hasAttrs()){
2055 for (clang::Decl::attr_iterator
attrIt =
decl->attr_begin();
2072 manipString+=
" theClass->CreateAttributeMap();\n";
2073 manipString+=
" TDictAttributeMap* attrMap( theClass->GetAttributeMap() );\n";
2084 if (!(!(*internalDeclIt)->isImplicit()
2105 TMetaUtils::Error(
nullptr,
"Cannot convert field declaration to clang::NamedDecl");
2121 if (
attrName == propNames::comment ||
2123 attrName == propNames::ioname )
continue;
2148 finalString <<
"} // end of namespace ROOT" <<
"\n" <<
"\n";
2160 const clang::CXXRecordDecl *cl)
2170 auto ctxt = cl->getEnclosingNamespaceContext();
2175 const clang::NamedDecl *
namedCtxt = llvm::dyn_cast<clang::NamedDecl>(
ctxt);
2177 const clang::NamespaceDecl *
nsdecl = llvm::dyn_cast<clang::NamespaceDecl>(
namedCtxt);
2192 const clang::DeclContext *
ctxt = cl.getDeclContext();
2193 while(
ctxt && !
ctxt->isNamespace()) {
2214 const clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(
ctxt);
2220 out <<
"namespace " << ns->getNameAsString() <<
" {" << std::endl;
2239 clang::TemplateSpecializationKind kind = cl->getTemplateSpecializationKind();
2240 if (kind == clang::TSK_Undeclared ) {
2243 }
else if (kind == clang::TSK_ExplicitSpecialization) {
2258 const char *
proto =
"size_t";
2265 cling::LookupHelper::NoDiagnostics);
2269 cling::LookupHelper::NoDiagnostics);
2271 const clang::DeclContext *
ctxtnew =
nullptr;
2307 const clang::CXXRecordDecl*
clnew = llvm::dyn_cast<clang::CXXRecordDecl>(
ctxtnew);
2354 const clang::CXXRecordDecl *
decl,
2355 const cling::Interpreter &
interp,
2379 classname.insert(0,
"::");
2387 finalString <<
" // Wrappers around operator new" <<
"\n";
2388 finalString <<
" static void *new_" <<
mappedname.c_str() <<
"(void *p) {" <<
"\n" <<
" return p ? ";
2395 finalString <<
"::new(static_cast<::ROOT::Internal::TOperatorNewHelper*>(p)) ";
2400 finalString <<
"new " << classname.c_str() << args <<
";" <<
"\n";
2415 finalString <<
"::new(static_cast<::ROOT::Internal::TOperatorNewHelper*>(p)) ";
2429 finalString <<
" // Wrapper around operator delete" <<
"\n" <<
" static void delete_" <<
mappedname.c_str() <<
"(void *p) {" <<
"\n" <<
" delete (static_cast<" << classname.c_str() <<
"*>(p));" <<
"\n" <<
" }" <<
"\n" <<
" static void deleteArray_" <<
mappedname.c_str() <<
"(void *p) {" <<
"\n" <<
" delete [] (static_cast<" << classname.c_str() <<
"*>(p));" <<
"\n" <<
" }" <<
"\n" <<
" static void destruct_" <<
mappedname.c_str() <<
"(void *p) {" <<
"\n" <<
" typedef " << classname.c_str() <<
" current_t;" <<
"\n" <<
" (static_cast<current_t*>(p))->~current_t();" <<
"\n" <<
" }" <<
"\n";
2433 finalString <<
" // Wrapper around the directory auto add." <<
"\n" <<
" static void directoryAutoAdd_" <<
mappedname.c_str() <<
"(void *p, TDirectory *dir) {" <<
"\n" <<
" ((" << classname.c_str() <<
"*)p)->DirectoryAutoAdd(dir);" <<
"\n" <<
" }" <<
"\n";
2437 finalString <<
" // Wrapper around a custom streamer member function." <<
"\n" <<
" static void streamer_" <<
mappedname.c_str() <<
"(TBuffer &buf, void *obj) {" <<
"\n" <<
" ((" << classname.c_str() <<
"*)obj)->" << classname.c_str() <<
"::Streamer(buf);" <<
"\n" <<
" }" <<
"\n";
2441 finalString <<
" // Wrapper around a custom streamer member function." <<
"\n" <<
" static void conv_streamer_" <<
mappedname.c_str() <<
"(TBuffer &buf, void *obj, const TClass *onfile_class) {" <<
"\n" <<
" ((" << classname.c_str() <<
"*)obj)->" << classname.c_str() <<
"::Streamer(buf,onfile_class);" <<
"\n" <<
" }" <<
"\n";
2445 finalString <<
" // Wrapper around the merge function." <<
"\n" <<
" static Long64_t merge_" <<
mappedname.c_str() <<
"(void *obj,TCollection *coll,TFileMergeInfo *info) {" <<
"\n" <<
" return ((" << classname.c_str() <<
"*)obj)->Merge(coll,info);" <<
"\n" <<
" }" <<
"\n";
2447 finalString <<
" // Wrapper around the merge function." <<
"\n" <<
" static Long64_t merge_" <<
mappedname.c_str() <<
"(void *obj,TCollection *coll,TFileMergeInfo *) {" <<
"\n" <<
" return ((" << classname.c_str() <<
"*)obj)->Merge(coll);" <<
"\n" <<
" }" <<
"\n";
2451 finalString <<
" // Wrapper around the Reset function." <<
"\n" <<
" static void reset_" <<
mappedname.c_str() <<
"(void *obj,TFileMergeInfo *info) {" <<
"\n" <<
" ((" << classname.c_str() <<
"*)obj)->ResetAfterMerge(info);" <<
"\n" <<
" }" <<
"\n";
2453 finalString <<
"} // end of namespace ROOT for class " << classname.c_str() <<
"\n" <<
"\n";
2460 const cling::Interpreter &
interp,
2471 const clang::CXXRecordDecl *
clxx = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
2475 for(clang::CXXRecordDecl::base_class_const_iterator iter =
clxx->bases_begin(), end =
clxx->bases_end();
2481 Internal::RStl::Instance().GenerateTClassFor( iter->getType(),
interp,
normCtxt);
2486 for(clang::RecordDecl::field_iterator
field_iter =
clxx->field_begin(), end =
clxx->field_end();
2518 const clang::Type *
rawtype =
m.getType()->getCanonicalTypeInternal().getTypePtr();
2534 const clang::CXXRecordDecl*
CRD = llvm::dyn_cast<clang::CXXRecordDecl>(cl);
2546 if (
funcCV == (clang::FunctionDecl*)-1)
return 1;
2561 using res_t = std::pair<bool, int>;
2563 const clang::CompoundStmt*
FuncBody
2564 = llvm::dyn_cast_or_null<clang::CompoundStmt>(
funcCV->getBody());
2566 return res_t{
false, -1};
2571 return res_t{
false, -1};
2573 const clang::ReturnStmt*
RetStmt
2574 = llvm::dyn_cast<clang::ReturnStmt>(
FuncBody->body_back());
2576 return res_t{
false, -1};
2588 return res_t{
false, -1};
2596 return TMetaUtils::IsSTLCont(*
annotated.GetRecordDecl());
2604 clang::QualType
type =
m.getType();
2607 if (
decl)
return TMetaUtils::IsSTLCont(*
decl);
2616 clang::QualType
type = base.getType();
2619 if (
decl)
return TMetaUtils::IsSTLCont(*
decl);
2629 const std::function<
void(
const clang::Module::Header &)> &
closure,
2642 const std::size_t
maxArrayLength = ((
sizeof module.Headers) / (sizeof *module.Headers));
2644 "'Headers' has changed it's size, we need to update publicHeaderIndex");
2649 llvm::SetVector<const clang::Module *>
modules;
2651 for (
size_t i = 0; i <
modules.size(); ++i) {
2652 const clang::Module *M =
modules[i];
2653 for (
const clang::Module *
subModule : M->submodules())
2657 for (
const clang::Module *
m :
modules) {
2659 for (clang::Module *
used :
m->DirectUses) {
2681 static char t[4096];
2682 static const char*
constwd =
"const ";
2691 if (
lev==0 && *s==
'*')
continue;
2697 if (
lev==0 && *s==
' ' && *(s+1)!=
'*') {
p = t;
continue;}
2698 if (
p - t > (
long)
sizeof(t)) {
2699 printf(
"ERROR (rootcling): type name too long for StortTypeName: %s\n",
2712 const cling::Interpreter&
interp)
2717 if (!comment.empty() && comment[0] ==
'!')
2720 clang::QualType
type =
m.getType();
2722 if (
type->isReferenceType()) {
2727 std::string
mTypeName =
type.getAsString(
m.getASTContext().getPrintingPolicy());
2739 const clang::Type *
rawtype =
type.getTypePtr()->getBaseElementTypeUnsafe ();
2741 if (
rawtype->isPointerType()) {
2755 const clang::CXXRecordDecl *
cxxdecl =
rawtype->getAsCXXRecordDecl();
2772 const clang::Type *
rawtype =
m.getType().getTypePtr();
2796 return rawtype->getAsCXXRecordDecl();
2805 const cling::Interpreter &
interp,
2811 const clang::CXXRecordDecl*
decl = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
2813 if (!
decl || !
decl->isCompleteDefinition()) {
2817 std::string fullname;
2831 ROOT::TMetaUtils::Info(
nullptr,
"Class %s: Do not generate Streamer() [*** custom streamer ***]\n",fullname.c_str());
2856 const clang::ASTContext&
Ctx =
interpreter.getCI()->getASTContext();
2862 if (llvm::isa<clang::PointerType>(
instanceType.getTypePtr())) {
2876 if (llvm::isa<clang::ReferenceType>(
instanceType.getTypePtr())) {
2896 clang::NestedNameSpecifier *prefix =
nullptr;
2898 const clang::ElaboratedType* etype
2899 = llvm::dyn_cast<clang::ElaboratedType>(
instanceType.getTypePtr());
2904 instanceType = clang::QualType(etype->getNamedType().getTypePtr(),0);
2910 const clang::TemplateSpecializationType*
TST
2911 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instanceType.getTypePtr());
2913 const clang::ClassTemplateSpecializationDecl*
TSTdecl
2914 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
instanceType.getTypePtr()->getAsCXXRecordDecl());
2930 clang::TemplateDecl *Template =
TSTdecl->getSpecializedTemplate()->getMostRecentDecl();
2931 clang::TemplateParameterList *Params = Template->getTemplateParameters();
2938 llvm::SmallVector<clang::TemplateArgument, 4>
desArgs;
2939 llvm::SmallVector<clang::TemplateArgument, 4>
canonArgs;
2948 if (
I->getKind() == clang::TemplateArgument::Template) {
2955 clang::NamespaceDecl* ns = clang::dyn_cast<clang::NamespaceDecl>(
declCtxt);
2956 clang::NestedNameSpecifier*
nns;
2958 nns = cling::utils::TypeName::CreateNestedNameSpecifier(
Ctx, ns);
2959 }
else if (clang::TagDecl*
TD = llvm::dyn_cast<clang::TagDecl>(
declCtxt)) {
2960 nns = cling::utils::TypeName::CreateNestedNameSpecifier(
Ctx,
TD,
false );
2967 if (clang::UsingShadowDecl *
USD =
templateName.getAsUsingShadowDecl())
2977 if (
I->getKind() != clang::TemplateArgument::Type) {
2982 clang::QualType
SubTy =
I->getAsType();
3004 if (
templateArg.getKind() != clang::TemplateArgument::Type) {
3010 clang::SourceLocation
TemplateLoc = Template->getSourceRange ().getBegin();
3013 clang::TemplateTypeParmDecl *
TTP = llvm::dyn_cast<clang::TemplateTypeParmDecl>(*
Param);
3016 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
3018 clang::TemplateArgumentLoc
ArgType = S.SubstDefaultTemplateArgumentIfAvailable(
3028 if (
ArgType.getArgument().isNull()
3029 ||
ArgType.getArgument().getKind() != clang::TemplateArgument::Type) {
3031 "Template parameter substitution failed for %s around %s\n",
3051 TST->getCanonicalTypeInternal());
3080 llvm::StringRef title;
3083 if (clang::AnnotateAttr *A =
m.getAttr<clang::AnnotateAttr>())
3084 title = A->getAnnotation();
3098 if (title.size() == 0 || (title[0] !=
'['))
return llvm::StringRef();
3100 if (
rightbracket == llvm::StringRef::npos)
return llvm::StringRef();
3119 char *current =
const_cast<char*
>(
working.c_str());
3125 for(i=0;i<
strlen(current);i++) {
3133 return llvm::StringRef();
3138 const clang::CXXRecordDecl *
parent_clxx = llvm::dyn_cast<clang::CXXRecordDecl>(
m.getDeclContext());
3139 const clang::FieldDecl *
index1 =
nullptr;
3152 if (
field_iter->getNameAsString() ==
m.getNameAsString() ) {
3160 return llvm::StringRef();
3172 return llvm::StringRef();
3197 return llvm::StringRef();
3199 if ( found && (
index1->getAccess() == clang::AS_private) ) {
3204 return llvm::StringRef();
3213 return llvm::StringRef();
3234 while((
c = in[i++])) {
3235 const char *
repl =
nullptr;
3237 case '+':
repl =
"pL";
break;
3238 case '-':
repl =
"mI";
break;
3239 case '*':
repl =
"mU";
break;
3240 case '/':
repl =
"dI";
break;
3241 case '&':
repl =
"aN";
break;
3242 case '%':
repl =
"pE";
break;
3243 case '|':
repl =
"oR";
break;
3244 case '^':
repl =
"hA";
break;
3245 case '>':
repl =
"gR";
break;
3246 case '<':
repl =
"lE";
break;
3247 case '=':
repl =
"eQ";
break;
3248 case '~':
repl =
"wA";
break;
3249 case '.':
repl =
"dO";
break;
3250 case '(':
repl =
"oP";
break;
3251 case ')':
repl =
"cP";
break;
3252 case '[':
repl =
"oB";
break;
3253 case ']':
repl =
"cB";
break;
3254 case '!':
repl =
"nO";
break;
3255 case ',':
repl =
"cO";
break;
3256 case '$':
repl =
"dA";
break;
3257 case ' ':
repl =
"sP";
break;
3258 case ':':
repl =
"cL";
break;
3259 case '"':
repl =
"dQ";
break;
3260 case '@':
repl =
"aT";
break;
3261 case '\'':
repl =
"sQ";
break;
3262 case '\\':
repl =
"fI";
break;
3276static clang::SourceLocation
3290 const cling::Interpreter&
interp)
3320 using namespace clang;
3345 ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>>(),
3360 assert(
decl.isFirstDecl() &&
"Couldn't trace back include from a decl"
3361 " that is not from an AST file");
3386 clang::OptionalFileEntryRef
FELong;
3388 for (llvm::sys::path::const_iterator
3401 &&
"Mismatched partitioning of file name!");
3405 ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>>(),
3417 for (llvm::sys::path::reverse_iterator
3425 &&
"Mismatched partitioning of file name!");
3431 ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>>(),
3434 nullptr,
nullptr ) ==
FELong) {
3445 const clang::QualType &
qtype,
3457 const clang::QualType &
qtype,
3463 cling::Interpreter::PushTransactionRAII
RAII(
const_cast<cling::Interpreter*
>(&
interpreter));
3475 clang::ClassTemplateDecl*&
ctd,
3476 clang::ClassTemplateSpecializationDecl*&
ctsd)
3478 using namespace clang;
3486 if (
theType->isPointerType()) {
3491 ctsd = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
rType->getDecl());
3493 ctd =
ctsd->getSpecializedTemplate();
3503 ctsd = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
qt->getAsCXXRecordDecl());
3505 ctd =
ctsd->getSpecializedTemplate();
3520 using namespace clang;
3536 using namespace clang;
3555 const clang::NamedDecl&
tPar,
3556 const cling::Interpreter&
interp,
3560 using namespace clang;
3565 if (!
ttpdPtr->hasDefaultArgument())
return false;
3587 const clang::ElaboratedType* etype
3588 = llvm::dyn_cast<clang::ElaboratedType>(
tParQualType.getTypePtr());
3590 tParQualType = clang::QualType(etype->getNamedType().getTypePtr(),0);
3591 etype = llvm::dyn_cast<clang::ElaboratedType>(
tParQualType.getTypePtr());
3595 llvm::dyn_cast<TemplateSpecializationType>(
tParQualType.getTypePtr());
3601 = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
tArgQualType->getAsCXXRecordDecl());
3619 clang::Sema& S =
interp.getCI()->getSema();
3620 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interp));
3621 llvm::SmallVector<clang::TemplateArgument, 4>
canonArgs;
3634 newArg.getKind() != clang::TemplateArgument::Type) {
3636 "Template parameter substitution failed!");
3640 = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
newArg.getAsType()->getAsCXXRecordDecl());
3656 const clang::NamedDecl&
tPar)
3658 using namespace clang;
3663 if (!
nttpd.hasDefaultArgument())
3674 const int value =
tArg.getAsIntegral().getLimitedValue();
3687 using namespace clang;
3688 if (!
nDecl)
return false;
3690 return ttpd->hasDefaultArgument();
3692 return nttpd->hasDefaultArgument();
3699 const cling::Interpreter&
interp,
3704 const clang::TemplateArgument &
tArg,
3705 const cling::Interpreter&
interp,
3707 const clang::ASTContext&
astCtxt)
3710 using namespace clang;
3717 if (
tArg.getKind() == clang::TemplateArgument::Type) {
3726 }
else if (
normTArg.getKind() == clang::TemplateArgument::Pack) {
3727 assert(
tArg.getKind() == clang::TemplateArgument::Pack );
3755 const cling::Interpreter&
interp,
3759 using namespace clang;
3768 const int nArgsToKeep =
normCtxt.GetNargsToKeep(
ctd);
3778 if (llvm::isa<clang::PointerType>(
normalizedType.getTypePtr())) {
3791 if (llvm::isa<clang::ReferenceType>(
normalizedType.getTypePtr())) {
3810 clang::NestedNameSpecifier* prefix =
nullptr;
3812 const clang::ElaboratedType* etype
3813 = llvm::dyn_cast<clang::ElaboratedType>(
normalizedType.getTypePtr());
3819 normalizedType = clang::QualType(etype->getNamedType().getTypePtr(),0);
3827 clang::TemplateParameterList*
tpl =
rd->getTemplateParameters();
3828 if (
tpl->getMinRequiredArguments () <
tpl->size()) {
3835 Error(
"KeepNParams",
"Not found template default arguments\n");
3852 llvm::dyn_cast<TemplateSpecializationType>(
normalizedType.getTypePtr());
3858 const clang::ClassTemplateSpecializationDecl*
TSTdecl
3859 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
normalizedType.getTypePtr()->getAsCXXRecordDecl());
3867 llvm::SmallVector<TemplateArgument, 4>
argsToKeep;
3879 Error(
"KeepNParams",
"The parameter number %s is null.\n",
formal);
3901 if (
tParPtr->isTemplateParameterPack() ) {
3931 if (
argKind == clang::TemplateArgument::Type){
3934 }
else if (
argKind == clang::TemplateArgument::Integral){
3982 cling::Interpreter::PushTransactionRAII
RAII(
const_cast<cling::Interpreter*
>(&
interpreter));
4005 if (
type.isNull()) {
4013 clang::PrintingPolicy
policy(
ctxt.getPrintingPolicy());
4014 policy.SuppressTagKeyword =
true;
4015 policy.SuppressScope =
true;
4016 policy.AnonymousTagLocations =
false;
4024 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
4049 clang::ASTContext&
astCtxt =
sema.getASTContext();
4059std::pair<std::string,clang::QualType>
4080 cling::LookupHelper::DiagSetting::NoDiagnostics,
4099 "The type for IO corresponding to %s is %s and it could not be found in the AST as class.\n",
thisTypeName.c_str(),
thisTypeNameForIO.c_str());
4127 llvm::errs() << llvm::StringRef(
commentStart, 80) <<
'\n';
4176 if (
const clang::FunctionDecl*
FD = clang::dyn_cast<clang::FunctionDecl>(&
decl)) {
4177 if (
FD->isImplicit()) {
4181 if (
FD->isExplicitlyDefaulted() ||
FD->isDeletedAsWritten()) {
4185 }
else if (
FD->doesThisDeclarationHaveABody()) {
4190 &&
"Expected macro or end of body at '}'");
4202 }
else if (
const clang::EnumConstantDecl*
ECD
4203 = clang::dyn_cast<clang::EnumConstantDecl>(&
decl)) {
4205 if (
ECD->getNextDeclInContext())
4282 if (!
decl)
return false;
4289 static const std::vector<std::string>
signatures =
4290 {
"ClassDef",
"ClassDefOverride",
"ClassDefNV",
"ClassDefInline",
"ClassDefInlineOverride",
"ClassDefInlineNV" };
4307 clang::SourceLocation *
loc,
4310 using namespace clang;
4313 =
interpreter.getLookupHelper().findFunctionProto(&
decl,
"DeclFileLine",
"",
4314 cling::LookupHelper::NoDiagnostics);
4320 if (comment.size()) {
4327 return llvm::StringRef();
4339 if (
rawtype->isElaboratedTypeSpecifier() ) {
4343 rawtype =
type.getTypePtr()->getBaseElementTypeUnsafe ();
4352 if (
rawtype->isElaboratedTypeSpecifier() ) {
4372 if (
ctxt.isNamespace() ||
ctxt.isTranslationUnit())
4374 else if(
const auto parentdecl = llvm::dyn_cast<clang::CXXRecordDecl>(&
ctxt))
4387 const clang::DeclContext *
ctxt =
decl.getDeclContext();
4388 switch (
decl.getAccess()) {
4389 case clang::AS_public:
4391 case clang::AS_protected:
4393 case clang::AS_private:
4395 case clang::AS_none:
4399 assert(
false &&
"Unexpected value for the access property value in Clang");
4409 return cling::utils::Analyze::IsStdClass(cl);
4419 if (cling::utils::Analyze::IsStdClass(cl)) {
4420 static const char *names[] =
4421 {
"shared_ptr",
"__shared_ptr",
4422 "vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset"};
4423 llvm::StringRef
clname(cl.getName());
4424 for(
auto &&
name : names) {
4462 const clang::CXXRecordDecl *
thisDecl =
4463 llvm::dyn_cast_or_null<clang::CXXRecordDecl>(
lh.findScope(
typ, cling::LookupHelper::WithDiagnostics));
4467 Error(
"IsOfType",
"Record decl of type %s not found in the AST.",
typ.c_str());
4497 if (!IsStdClass(cl)) {
4498 auto *
nsDecl = llvm::dyn_cast<clang::NamespaceDecl>(cl.getDeclContext());
4499 if (cl.getName() !=
"RVec" ||
nsDecl ==
nullptr ||
nsDecl->getName() !=
"VecOps")
4502 auto *
parentNsDecl = llvm::dyn_cast<clang::NamespaceDecl>(cl.getDeclContext()->getParent());
4507 return STLKind(cl.getName());
4511 using namespace clang;
4512 struct SearchTypedef:
public TypeVisitor<SearchTypedef, bool> {
4517 return Visit(
AT->getElementType().getTypePtr());
4520 return Visit(
DT->getUnderlyingType().getTypePtr());
4523 return Visit(
PT->getPointeeType().getTypePtr());
4526 return Visit(
RT->getPointeeType().getTypePtr());
4529 return Visit(
STST->getReplacementType().getTypePtr());
4533 if (
TA.getKind() == TemplateArgument::Type && Visit(
TA.getAsType().getTypePtr()))
4542 return TOT->getUnmodifiedType().getTypePtr();
4547 if (
NNS->getKind() == NestedNameSpecifier::TypeSpec) {
4548 if (Visit(
NNS->getAsType()))
4553 return Visit(
ET->getNamedType().getTypePtr());
4574 using namespace llvm;
4575 using namespace clang;
4576 const clang::ASTContext &
Ctxt =
instance->getAsCXXRecordDecl()->getASTContext();
4579 const clang::ElaboratedType* etype
4580 = llvm::dyn_cast<clang::ElaboratedType>(
input.getTypePtr());
4585 assert(
instance->getAsCXXRecordDecl() !=
nullptr &&
"ReSubstTemplateArg only makes sense with a type representing a class.");
4604 if (
nQT ==
QT->getPointeeType())
return QT;
4620 if (
nQT ==
QT->getPointeeType())
return QT;
4641 if (
newQT ==
arr->getElementType())
return QT;
4645 arr->getSizeModifier(),
4646 arr->getIndexTypeCVRQualifiers());
4654 arr->getSizeModifier(),
4655 arr->getIndexTypeCVRQualifiers(),
4656 arr->getBracketsRange());
4661 if (
newQT ==
arr->getElementType())
return QT;
4663 arr->getSizeModifier(),
4664 arr->getIndexTypeCVRQualifiers());
4669 if (
newQT ==
arr->getElementType())
return QT;
4672 arr->getSizeModifier(),
4673 arr->getIndexTypeCVRQualifiers(),
4674 arr->getBracketsRange());
4683 etype = llvm::dyn_cast<clang::ElaboratedType>(
instance);
4685 instance = etype->getNamedType().getTypePtr();
4689 const clang::TemplateSpecializationType*
TST
4690 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instance);
4694 const clang::ClassTemplateSpecializationDecl*
TSTdecl
4695 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
instance->getAsCXXRecordDecl());
4699 const clang::SubstTemplateTypeParmType *
substType
4700 = llvm::dyn_cast<clang::SubstTemplateTypeParmType>(
input.getTypePtr());
4704 const clang::ClassTemplateDecl *
replacedCtxt =
nullptr;
4708 unsigned int index =
substType->getReplacedParameter()->getIndex();
4711 if (
decl->getKind() == clang::Decl::ClassTemplatePartialSpecialization) {
4712 const clang::ClassTemplatePartialSpecializationDecl *
spec = llvm::dyn_cast<clang::ClassTemplatePartialSpecializationDecl>(
decl);
4714 unsigned int depth =
substType->getReplacedParameter()->getDepth();
4730 const clang::SubstTemplateTypeParmType *
argType
4731 = llvm::dyn_cast<clang::SubstTemplateTypeParmType>(
argQualType);
4756 llvm::raw_string_ostream ostream(
astDump);
4759 ROOT::TMetaUtils::Warning(
"ReSubstTemplateArg",
"Unexpected type of declaration context for template parameter: %s.\n\tThe responsible class is:\n\t%s\n",
4767 ==
TSTdecl->getSpecializedTemplate ()->getTemplateParameters()->getParam(
index))
4769 const auto &
TAs =
TST->template_arguments();
4786 const clang::TemplateSpecializationType*
inputTST
4787 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
input.getTypePtr());
4792 llvm::SmallVector<clang::TemplateArgument, 4>
desArgs;
4793 for (
const clang::TemplateArgument &
TA :
inputTST->template_arguments()) {
4794 if (
TA.getKind() != clang::TemplateArgument::Type) {
4799 clang::QualType
SubTy =
TA.getAsType();
4801 if (llvm::isa<clang::ElaboratedType>(
SubTy)
4802 || llvm::isa<clang::SubstTemplateTypeParmType>(
SubTy)
4803 || llvm::isa<clang::TemplateSpecializationType>(
SubTy)) {
4818 inputTST->getCanonicalTypeInternal());
4859 static const char *
stls[] =
4860 {
"any",
"vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset",
4861 "forward_list",
"unordered_set",
"unordered_multiset",
"unordered_map",
"unordered_multimap",
"RVec",
nullptr};
4875 for(
int k=1;
stls[k];k++) {
if (
type.equals(
stls[k]))
return values[k];}
4886 TND =
TND->getMostRecentDecl();
4887 while (
TND && !(
TND->hasAttrs()))
4888 TND =
TND->getPreviousDecl();
4900 TD =
TD->getMostRecentDecl();
4901 while (
TD && !(
TD->hasAttrs() &&
TD->isThisDeclarationADefinition()))
4902 TD =
TD->getPreviousDecl();
4958 std::list<std::pair<std::string,unsigned int> >&
enclosingSc)
4986 std::string::size_type
beginVar = 0;
4987 std::string::size_type
endVar = 0;
4991 std::string::size_type
endVarName = std::string::npos;
5128 return llvm::sys::path::extension(
filename) ==
".h" ||
5129 llvm::sys::path::extension(
filename) ==
".hh" ||
5130 llvm::sys::path::extension(
filename) ==
".hpp" ||
5131 llvm::sys::path::extension(
filename) ==
".H" ||
5132 llvm::sys::path::extension(
filename) ==
".h++" ||
5133 llvm::sys::path::extension(
filename) ==
"hxx" ||
5134 llvm::sys::path::extension(
filename) ==
"Hxx" ||
5135 llvm::sys::path::extension(
filename) ==
"HXX";
5141 cling::Interpreter::IgnoreFilesFunc_t
ignoreFiles,
5142 const cling::Interpreter &
interp,
5150 clang::Decl *
ncDecl =
const_cast<clang::Decl *
>(
decl);
5195 static const std::string
scopeType [] = {
"namespace ",
"inline namespace ",
"class "};
5237 std::string typeName;
5240 if (llvm::isa<clang::TemplateTypeParmDecl>(
nDecl)){
5241 typeName =
"typename ";
5242 if (
nDecl->isParameterPack())
5244 typeName += (*prmIt)->getNameAsString();
5247 else if (
auto nttpd = llvm::dyn_cast<clang::NonTypeTemplateParmDecl>(
nDecl)){
5251 if (
theType.getAsString().find(
"enum") != std::string::npos){
5253 llvm::raw_string_ostream ostream(
astDump);
5254 nttpd->dump(ostream);
5265 else if (
auto ttpd = llvm::dyn_cast<clang::TemplateTemplateParmDecl>(
nDecl)){
5269 llvm::raw_string_ostream ostream(
astDump);
5270 ttpd->dump(ostream);
5295 "Cannot extract template parameter list for %s",
5303 "Problems with arguments for forward declaration of class %s\n",
5313 if (llvm::isa<clang::TemplateTemplateParmDecl>(&
templDecl)) {
5335 if (clang::TemplateArgument::Type != arg.getKind())
return 0;
5350 if (llvm::isa<clang::BuiltinType>(
argTypePtr)){
5383 if (
specDef->getTemplateSpecializationKind() != clang::TSK_ExplicitSpecialization)
5387 std::cout <<
" Forward declaring template spec " <<
normalizedName <<
":\n";
5392 std::cout <<
" o Template argument ";
5394 std::cout <<
"successfully treated. Arg fwd decl: " <<
argFwdDecl << std::endl;
5396 std::cout <<
"could not be treated. Abort fwd declaration generation.\n";
5437 std::cout <<
"Class " <<
recordDecl.getNameAsString()
5438 <<
" is a template specialisation. Treating its arguments.\n";
5442 std::cout <<
" o Template argument ";
5444 std::cout <<
"successfully treated. Arg fwd decl: " <<
argFwdDecl << std::endl;
5446 std::cout <<
"could not be treated. Abort fwd declaration generation.\n";
5494 std::string buffer =
tdnDecl.getNameAsString();
5497 if (
const clang::TagType* TT
5499 if (clang::NamedDecl*
ND = TT->getDecl()) {
5500 if (!
ND->getIdentifier()) {
5544 std::cout <<
"Typedef " <<
tdnDecl.getNameAsString() <<
" hides a class: "
5571 const clang::PrintingPolicy&
ppolicy)
5574 auto&
ctxt = par.getASTContext();
5595 if (
result.isNegative()){
The file contains utilities which are foundational and could be used across the core component of ROO...
#define R(a, b, c, d, e, f, g, h, i)
static Roo_reg_AGKInteg1D instance
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
static void indent(ostringstream &buf, int indent_level)
static bool RecurseKeepNParams(clang::TemplateArgument &normTArg, const clang::TemplateArgument &tArg, const cling::Interpreter &interp, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt, const clang::ASTContext &astCtxt)
static clang::SourceLocation getFinalSpellingLoc(clang::SourceManager &sourceManager, clang::SourceLocation sourceLoc)
const clang::DeclContext * GetEnclosingSpace(const clang::RecordDecl &cl)
bool IsTemplate(const clang::Decl &cl)
static void KeepNParams(clang::QualType &normalizedType, const clang::QualType &vanillaType, const cling::Interpreter &interp, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt)
This function allows to manipulate the number of arguments in the type of a template specialisation.
static void CreateNameTypeMap(const clang::CXXRecordDecl &cl, ROOT::MembersTypeMap_t &nameType)
Create the data member name-type map for given class.
const clang::CXXMethodDecl * GetMethodWithProto(const clang::Decl *cinfo, const char *method, const char *proto, const cling::Interpreter &interp, bool diagnose)
int dumpDeclForAssert(const clang::Decl &D, const char *commentStart)
static void replaceEnvVars(const char *varname, std::string &txt)
Reimplementation of TSystem::ExpandPathName() that cannot be used from TMetaUtils.
static bool areEqualValues(const clang::TemplateArgument &tArg, const clang::NamedDecl &tPar)
std::cout << "Are equal values?\n";
static bool isTypeWithDefault(const clang::NamedDecl *nDecl)
Check if this NamedDecl is a template parameter with a default argument.
static int TreatSingleTemplateArg(const clang::TemplateArgument &arg, std::string &argFwdDecl, const cling::Interpreter &interpreter, bool acceptStl=false)
static bool areEqualTypes(const clang::TemplateArgument &tArg, llvm::SmallVectorImpl< clang::TemplateArgument > &preceedingTArgs, const clang::NamedDecl &tPar, const cling::Interpreter &interp, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt)
static bool hasSomeTypedefSomewhere(const clang::Type *T)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
const_iterator begin() const
const_iterator end() const
const std::string & GetPathSeparator()
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
void WriteSchemaList(std::list< SchemaRuleMap_t > &rules, const std::string &listName, std::ostream &output)
Write schema rules.
std::map< std::string, ROOT::Internal::TSchemaType > MembersTypeMap_t
void WriteReadRuleFunc(SchemaRuleMap_t &rule, int index, std::string &mappedName, MembersTypeMap_t &members, std::ostream &output)
Write the conversion function for Read rule, the function name is being written to rule["funcname"].
R__EXTERN SchemaRuleClassMap_t gReadRules
bool HasValidDataMembers(SchemaRuleMap_t &rule, MembersTypeMap_t &members, std::string &error_string)
Check if given rule contains references to valid data members.
void WriteReadRawRuleFunc(SchemaRuleMap_t &rule, int index, std::string &mappedName, MembersTypeMap_t &members, std::ostream &output)
Write the conversion function for ReadRaw rule, the function name is being written to rule["funcname"...
R__EXTERN SchemaRuleClassMap_t gReadRawRules
ROOT::ESTLType STLKind(std::string_view type)
Converts STL container name to number.
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
std::string GetLong64_Name(const char *original)
Replace 'long long' and 'unsigned long long' by 'Long64_t' and 'ULong64_t'.
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
char * DemangleName(const char *mangled_name, int &errorCode)
std::string GetNameForIO(const std::string &templateInstanceName, TClassEdit::EModType mode=TClassEdit::kNone, bool *hasChanged=nullptr)
bool IsSTLBitset(const char *type)
Return true is the name is std::bitset<number> or bitset<number>
constexpr Double_t C()
Velocity of light in .