24#include <unordered_set>
27#include "RConfigure.h"
36#include "clang/AST/ASTContext.h"
37#include "clang/AST/Attr.h"
38#include "clang/AST/CXXInheritance.h"
39#include "clang/AST/Decl.h"
40#include "clang/AST/DeclTemplate.h"
41#include "clang/AST/Mangle.h"
42#include "clang/AST/Type.h"
43#include "clang/AST/TypeVisitor.h"
44#include "clang/Frontend/CompilerInstance.h"
45#include "clang/Lex/HeaderSearch.h"
46#include "clang/Lex/ModuleMap.h"
47#include "clang/Lex/Preprocessor.h"
48#include "clang/Lex/PreprocessorOptions.h"
50#include "clang/Sema/Lookup.h"
51#include "clang/Sema/Sema.h"
52#include "clang/Sema/SemaDiagnostic.h"
54#include "cling/Interpreter/LookupHelper.h"
55#include "cling/Interpreter/Transaction.h"
56#include "cling/Interpreter/Interpreter.h"
57#include "cling/Utils/AST.h"
58#include "cling/Interpreter/InterpreterAccessRAII.h"
60#include "llvm/Support/Path.h"
61#include "llvm/Support/FileSystem.h"
66#define strncasecmp _strnicmp
86 using DeclsCont_t = TNormalizedCtxt::Config_t::SkipCollection;
103 bool replace =
false);
114 clang::NestedNameSpecifier*
scope,
117 if (!
scope)
return nullptr;
140static bool CheckDefinition(
const clang::CXXRecordDecl *cl,
const clang::CXXRecordDecl *context)
142 if (!cl->hasDefinition()) {
145 "Missing definition for class %s, please #include its header in the header of %s\n",
146 cl->getName().str().c_str(), context->getName().str().c_str());
149 "Missing definition for class %s\n",
150 cl->getName().str().c_str());
163 clang::NestedNameSpecifier *
scope,
166 if (!
scope)
return nullptr;
188 const clang::BuiltinType *
builtin = llvm::dyn_cast<clang::BuiltinType>(
type->getCanonicalTypeInternal().getTypePtr());
208 clang::ASTContext &
C = cl.getASTContext();
209 clang::DeclarationName
DName = &
C.Idents.get(
what);
210 auto R = cl.lookup(
DName);
211 for (
const clang::NamedDecl *D :
R)
223 clang::LookupResult
R(
SemaR,
DName, clang::SourceLocation(),
224 clang::Sema::LookupOrdinaryName,
225 clang::Sema::ForExternalRedeclaration);
226 SemaR.LookupInSuper(
R, &
const_cast<clang::CXXRecordDecl&
>(cl));
229 return llvm::dyn_cast<const clang::FieldDecl>(
R.getFoundDecl());
235 ? cling::LookupHelper::WithDiagnostics
236 : cling::LookupHelper::NoDiagnostics;
243namespace TMetaUtils {
252 Error(
"TNormalizedCtxt::AddTemplAndNargsToKeep",
253 "Tring to specify a number of template arguments to keep for a null pointer. Exiting without assigning any value.\n");
257 const clang::ClassTemplateDecl*
canTempl =
templ->getCanonicalDecl();
262 const std::string
i_str (std::to_string(i));
264 Error(
"TNormalizedCtxt::AddTemplAndNargsToKeep",
265 "Tring to specify for template %s %s arguments to keep, while before this number was %s\n",
266 canTempl->getNameAsString().c_str(),
279 const clang::ClassTemplateDecl*
constTempl =
templ->getCanonicalDecl();
330 std::unique_ptr<clang::MangleContext>
mangleCtx(
rDecl->getASTContext().createMangleContext());
334 if (
const clang::TypeDecl*
TD = llvm::dyn_cast<clang::TypeDecl>(
rDecl)) {
335 mangleCtx->mangleCXXRTTI(clang::QualType(
TD->getTypeForDecl(), 0),
sstr);
361 "Demangled typeinfo name '%s' does not contain `RTTI Type Descriptor'\n",
365 "Demangled typeinfo name '%s' does not start with 'typeinfo for'\n",
382 const clang::RecordDecl *
decl,
411 const clang::RecordDecl *
decl,
440 "Could not remove the requested template arguments.\n");
451 const clang::RecordDecl *
decl,
485 const clang::RecordDecl *
decl,
532 fCheckInClassTable(CheckInClassTable),
546 if (
tname.empty())
return false;
571 if (!
dest.isNull() && (
dest != t)) {
591 if (!
dest.isNull() && (
dest != t) &&
613 const clang::NamespaceDecl *
nsdecl = llvm::dyn_cast<clang::NamespaceDecl>(
scope);
626 if (
tname.empty())
return false;
658 clang::PrintingPolicy
policy(
fInterpreter->getCI()->getASTContext().getPrintingPolicy());
659 policy.SuppressTagKeyword =
true;
660 policy.SuppressScope =
true;
675 for(
unsigned int i = 1; i<
result.length(); ++i) {
687 }
else if ( (i+1) <
result.length() &&
725 clang::QualType
toSkip =
lh.findType(
name, cling::LookupHelper::WithDiagnostics);
726 if (
const clang::Type* T =
toSkip.getTypePtr()) {
727 const clang::TypedefType *
tt = llvm::dyn_cast<clang::TypedefType>(T);
729 clang::Decl* D =
tt->getDecl();
730 fConfig.m_toSkip.insert(D);
732 clang::QualType
canon =
toSkip->getCanonicalTypeInternal();
733 fConfig.m_toReplace.insert(std::make_pair(
canon.getTypePtr(),T));
735 fTypeWithAlternative.insert(T);
748 keepTypedef(
lh,
"Double32_t");
749 keepTypedef(
lh,
"Float16_t");
750 keepTypedef(
lh,
"Long64_t",
true);
751 keepTypedef(
lh,
"ULong64_t",
true);
753 clang::QualType
toSkip =
lh.findType(
"string", cling::LookupHelper::WithDiagnostics);
755 if (
const clang::TypedefType* TT
756 = llvm::dyn_cast_or_null<clang::TypedefType>(
toSkip.getTypePtr()))
757 fConfig.m_toSkip.insert(TT->getDecl());
759 toSkip =
lh.findType(
"std::string", cling::LookupHelper::WithDiagnostics);
761 if (
const clang::TypedefType* TT
762 = llvm::dyn_cast_or_null<clang::TypedefType>(
toSkip.getTypePtr()))
763 fConfig.m_toSkip.insert(TT->getDecl());
765 clang::QualType
canon =
toSkip->getCanonicalTypeInternal();
766 fConfig.m_toReplace.insert(std::make_pair(
canon.getTypePtr(),
toSkip.getTypePtr()));
777 return (cl.getKind() == clang::Decl::ClassTemplatePartialSpecialization
778 || cl.getKind() == clang::Decl::ClassTemplateSpecialization);
785 const cling::Interpreter&
interp)
787 clang::Sema* S = &
interp.getSema();
788 const clang::NamedDecl*
ND = cling::utils::Lookup::Named(S,
name, cl);
789 if (
ND == (clang::NamedDecl*)-1)
790 return (clang::FunctionDecl*)-1;
791 return llvm::dyn_cast_or_null<clang::FunctionDecl>(
ND);
797const clang::CXXRecordDecl *
801 const cling::LookupHelper&
lh =
interp.getLookupHelper();
804 const clang::CXXRecordDecl *
result
805 = llvm::dyn_cast_or_null<clang::CXXRecordDecl>
812 result = llvm::dyn_cast_or_null<clang::CXXRecordDecl>
823 clang::QualType
qType(cl->getTypeForDecl(),0);
831 clang::Sema& S =
interp.getCI()->getSema();
834 cling::Interpreter::PushTransactionRAII
RAII(
const_cast<cling::Interpreter*
>(&
interp));
835 return S.RequireCompleteType(
Loc, Type, clang::diag::err_incomplete_type);
841 const clang::CXXRecordDecl *context,
const cling::Interpreter &
interp)
847 if (!cl->getDefinition() || !cl->isCompleteDefinition()) {
855 if (!base->hasDefinition()) {
859 return cl->isDerivedFrom(base);
871 const clang::NamedDecl *base
875 return IsBase(
CRD, llvm::dyn_cast<clang::CXXRecordDecl>( base ),
876 llvm::dyn_cast<clang::CXXRecordDecl>(
m.getDeclContext()),
interp);
885 const clang::QualType &
qti,
887 const cling::Interpreter &
interp,
895 kBIT_ISSTRING = 0x40000000,
902 const clang::Type &
ti( *
qti.getTypePtr() );
925 if (
tiName ==
"string")
kase |= kBIT_ISSTRING;
926 if (
tiName ==
"string*")
kase |= kBIT_ISSTRING;
930 tcl =
" internal error in rootcling ";
955 <<
" R__b >> readtemp;" << std::endl
956 <<
" " <<
R__t <<
" = static_cast<" <<
tiName <<
">(readtemp);" << std::endl;
968 finalString <<
" if (R__b.GetInfo() && R__b.GetInfo()->GetOldVersion()<=3) {" << std::endl;
970 finalString <<
" R__ASSERT(0);// " <<
objType <<
" is abstract. We assume that older file could not be produced using this streaming method." << std::endl;
973 <<
" " <<
R__t <<
"->Streamer(R__b);" << std::endl;
976 <<
" " <<
R__t <<
" = (" <<
tiName <<
")R__b.ReadObjectAny(" <<
tcl <<
");" << std::endl
977 <<
" }" << std::endl;
983 <<
" R__str.Streamer(R__b);" << std::endl
984 <<
" " <<
R__t <<
" = R__str.Data();}" << std::endl;
990 <<
" R__str.Streamer(R__b);" << std::endl
991 <<
" " <<
R__t <<
" = new string(R__str.Data());}" << std::endl;
1000 if (!
R__t)
return 1;
1011 if (!
R__t)
return 0;
1016 if (!
R__t)
return 0;
1018 finalString <<
" R__b >> *reinterpret_cast<Int_t*>(ptr_enum); }" << std::endl;
1023 if (!
R__t)
return 0;
1028 if (!
R__t)
return 1;
1033 if (!
R__t)
return 0;
1034 finalString <<
" {TString R__str(" <<
R__t <<
".c_str());" << std::endl
1035 <<
" R__str.Streamer(R__b);};" << std::endl;
1039 if (!
R__t)
return 0;
1040 finalString <<
" {TString R__str(" <<
R__t <<
"->c_str());" << std::endl
1041 <<
" R__str.Streamer(R__b);}" << std::endl;
1045 if (!
R__t)
return 1;
1050 if (!
R__t)
return 1;
1063 clang::CXXRecordDecl*
ncCl =
const_cast<clang::CXXRecordDecl*
>(cl);
1066 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
1069 if (
Ctor->getAccess() == clang::AS_public && !
Ctor->isDeleted()) {
1087 const cling::LookupHelper&
lh =
interpreter.getLookupHelper();
1096 return EIOCtorCategory::kAbsent;
1099 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
1100 for (
auto iter = cl->ctor_begin(), end = cl->ctor_end(); iter != end; ++iter)
1102 if ((iter->getAccess() != clang::AS_public) || (iter->getNumParams() != 1))
1106 clang::QualType
argType((*iter->param_begin())->getType());
1110 if (
argType->isPointerType()) {
1113 }
else if (
argType->isReferenceType()) {
1120 const clang::CXXRecordDecl *
argDecl =
argType->getAsCXXRecordDecl();
1127 std::string
clarg(
"class ");
1134 return EIOCtorCategory::kAbsent;
1147 if (!
ioctortype.GetType() && (!arg || !arg[0])) {
1161 const cling::Interpreter &
interp,
1164 const clang::FunctionDecl*
funcD
1166 diagnose ? cling::LookupHelper::WithDiagnostics
1167 : cling::LookupHelper::NoDiagnostics);
1169 return llvm::dyn_cast<const clang::CXXMethodDecl>(
funcD);
1178 namespace TMetaUtils {
1181 const cling::LookupHelper&
lh =
interp.getLookupHelper();
1200 const cling::Interpreter &
interp)
1202 if (cl->isAbstract())
return false;
1208 if (EIOCtorCategory::kAbsent ==
ioCtorCat)
1218 if (EIOCtorCategory::kIOPtrType ==
ioCtorCat) {
1220 }
else if (EIOCtorCategory::kIORefType ==
ioCtorCat) {
1224 arg +=
")nullptr )";
1227 const clang::CXXMethodDecl *
method
1229 cling::LookupHelper::NoDiagnostics);
1230 if (
method &&
method->getAccess() != clang::AS_public) {
1244 const cling::Interpreter&
interp)
1246 if (!cl)
return false;
1248 if (cl->hasUserDeclaredDestructor()) {
1250 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interp));
1251 clang::CXXDestructorDecl *
dest = cl->getDestructor();
1253 return (
dest->getAccess() == clang::AS_public);
1267 const cling::Interpreter &
interp,
1270 const clang::CXXMethodDecl *
method
1272 diagnose ? cling::LookupHelper::WithDiagnostics
1273 : cling::LookupHelper::NoDiagnostics);
1274 return (
method &&
method->getAccess() == clang::AS_public);
1285 const char *
proto =
"TDirectory*";
1286 const char *
name =
"DirectoryAutoAdd";
1300 const char *
proto =
"TCollection*,TFileMergeInfo*";
1301 const char *
name =
"Merge";
1314 const char *
proto =
"TCollection*";
1315 const char *
name =
"Merge";
1330 const char *
proto =
"TFileMergeInfo*";
1331 const char *
name =
"ResetAfterMerge";
1341 const clang::CXXRecordDecl*
clxx,
1342 const cling::Interpreter &
interp,
1345 static const char *
proto =
"TBuffer&";
1347 const clang::CXXMethodDecl *
method
1349 cling::LookupHelper::NoDiagnostics);
1360 const clang::CXXRecordDecl*
clxx,
1361 const cling::Interpreter &
interp,
1364 static const char *
proto =
"TBuffer&,TClass*";
1366 const clang::CXXMethodDecl *
method
1368 cling::LookupHelper::NoDiagnostics);
1433 llvm::raw_string_ostream stream(
qual_name);
1434 clang::PrintingPolicy
policy( cl.getASTContext().getPrintingPolicy() );
1435 policy.SuppressTagKeyword =
true;
1436 policy.SuppressUnwrittenScope =
true;
1438 cl.getNameForDiagnostic(stream,
policy,
true);
1494 std::stringstream
dims;
1497 const clang::ASTContext&
astContext = cl.getASTContext();
1500 for(clang::RecordDecl::field_iterator
field_iter = cl.field_begin(), end = cl.field_end();
1514 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
fieldType.getTypePtr());
1516 dims <<
"[" <<
arrayType->getSize().getLimitedValue() <<
"]";
1518 arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual());
1528 for(clang::CXXRecordDecl::base_class_const_iterator iter = cl.bases_begin(), end = cl.bases_end();
1531 std::string
basename( iter->getType()->getAsCXXRecordDecl()->getNameAsString() );
1541 const cling::Interpreter &
interp,
1545 diagnose ? cling::LookupHelper::WithDiagnostics
1546 : cling::LookupHelper::NoDiagnostics);
1605 while (llvm::isa<clang::PointerType>(
instanceType.getTypePtr())
1606 || llvm::isa<clang::ReferenceType>(
instanceType.getTypePtr()))
1611 const clang::ElaboratedType* etype
1612 = llvm::dyn_cast<clang::ElaboratedType>(
instanceType.getTypePtr());
1614 instanceType = clang::QualType(etype->getNamedType().getTypePtr(),0);
1628 if (
clxx &&
clxx->getTemplateSpecializationKind() != clang::TSK_Undeclared) {
1630 const clang::TemplateSpecializationType*
TST
1631 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instanceType.getTypePtr());
1638 for (
const clang::TemplateArgument &
TA :
TST->template_arguments()) {
1639 if (
TA.getKind() == clang::TemplateArgument::Type) {
1651 const cling::Interpreter &
interp,
1654 const clang::CXXRecordDecl *
clxx = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
1655 if (!
clxx ||
clxx->getTemplateSpecializationKind() == clang::TSK_Undeclared)
return false;
1658 cling::LookupHelper::WithDiagnostics);
1672 clang::AnnotateAttr*
annAttr = clang::dyn_cast<clang::AnnotateAttr>(
attribute);
1715 for (clang::Decl::attr_iterator
attrIt =
decl.attr_begin();
1717 clang::AnnotateAttr*
annAttr = clang::dyn_cast<clang::AnnotateAttr>(*
attrIt);
1721 std::pair<llvm::StringRef,llvm::StringRef> split =
attribute.split(propNames::separator.c_str());
1722 if (split.first !=
propName.c_str())
continue;
1738 for (clang::Decl::attr_iterator
attrIt =
decl.attr_begin();
1740 clang::AnnotateAttr*
annAttr = clang::dyn_cast<clang::AnnotateAttr>(*
attrIt);
1744 std::pair<llvm::StringRef,llvm::StringRef> split =
attribute.split(propNames::separator.c_str());
1745 if (split.first !=
propName.c_str())
continue;
1747 return split.second.getAsInteger(10,
propValue);
1758 const clang::CXXRecordDecl *
decl,
1759 const cling::Interpreter &
interp,
1768 std::string
csymbol = classname;
1782 bool isStd = TMetaUtils::IsStdClass(*
decl);
1783 const cling::LookupHelper&
lh =
interp.getLookupHelper();
1793 <<
" static void " <<
mappedname.c_str() <<
"_TClassManip(TClass*);\n";
1811 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";
1814 finalString <<
" static void directoryAutoAdd_" <<
mappedname.c_str() <<
"(void *obj, TDirectory *dir);" <<
"\n";
1817 finalString <<
" static void streamer_" <<
mappedname.c_str() <<
"(TBuffer &buf, void *obj);" <<
"\n";
1820 finalString <<
" static void conv_streamer_" <<
mappedname.c_str() <<
"(TBuffer &buf, void *obj, const TClass*);" <<
"\n";
1823 finalString <<
" static Long64_t merge_" <<
mappedname.c_str() <<
"(void *obj, TCollection *coll,TFileMergeInfo *info);" <<
"\n";
1826 finalString <<
" static void reset_" <<
mappedname.c_str() <<
"(void *obj, TFileMergeInfo *info);" <<
"\n";
1845 finalString <<
"\n // Schema evolution read functions\n";
1846 std::list<ROOT::SchemaRuleMap_t>::iterator
rIt =
rulesIt1->second.fRules.
begin();
1864 if(
rIt->find(
"code" ) !=
rIt->
end() ) {
1880 finalString <<
"\n // Schema evolution read raw functions\n";
1881 std::list<ROOT::SchemaRuleMap_t>::iterator
rIt =
rulesIt2->second.fRules.
begin();
1907 finalString <<
"\n" <<
" // Function generating the singleton type initializer" <<
"\n";
1909 finalString <<
" static TGenericClassInfo *GenerateInitInstanceLocal(const " <<
csymbol <<
"*)" <<
"\n" <<
" {" <<
"\n";
1915 finalString <<
" static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< " <<
csymbol <<
" >(nullptr);" <<
"\n";
1918 finalString <<
" static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(" <<
csymbol <<
"));" <<
"\n";
1920 finalString <<
" static ::ROOT::TGenericClassInfo " <<
"\n" <<
" instance(\"" << classname.c_str() <<
"\", ";
1933 static const char *
versionFunc =
"GetClassVersion";
1937 std::string
proto = classname +
"*";
1938 const clang::Decl*
ctxt = llvm::dyn_cast<clang::Decl>((*cl).getDeclContext());
1941 interp, cling::LookupHelper::NoDiagnostics);
1960 for (
unsigned int i=0; i<
filename.length(); i++) {
1965 <<
"," <<
"\n" <<
" typeid(" <<
csymbol
1966 <<
"), ::ROOT::Internal::DefineBehavior(ptr, ptr)," <<
"\n" <<
" ";
1989 finalString <<
" instance.SetDelete(&delete_" <<
mappedname.c_str() <<
");" <<
"\n" <<
" instance.SetDeleteArray(&deleteArray_" <<
mappedname.c_str() <<
");" <<
"\n" <<
" instance.SetDestructor(&destruct_" <<
mappedname.c_str() <<
");" <<
"\n";
1992 finalString <<
" instance.SetDirectoryAutoAdd(&directoryAutoAdd_" <<
mappedname.c_str() <<
");" <<
"\n";
2000 finalString <<
" instance.SetConvStreamerFunc(&conv_streamer_" <<
mappedname.c_str() <<
");" <<
"\n";
2009 finalString <<
" instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" <<
"Pushback" <<
"<Internal::TStdBitsetHelper< " << classname.c_str() <<
" > >()));" <<
"\n";
2012 }
else if (
stl != 0 &&
2015 int idx = classname.find(
"<");
2044 finalString <<
" instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" <<
methodTCP <<
"< " <<
classNameForIO.c_str() <<
" >()));" <<
"\n";
2054 finalString <<
"\n" <<
" instance.AdoptAlternate(::ROOT::AddClassAlternate(\""
2061 finalString <<
"\n" <<
" instance.AdoptAlternate(::ROOT::AddClassAlternate(\""
2071 finalString <<
"\n" <<
" ::ROOT::Internal::TSchemaHelper* rule;" <<
"\n";
2075 finalString <<
"\n" <<
" // the io read rules" <<
"\n" <<
" std::vector<::ROOT::Internal::TSchemaHelper> readrules(" <<
rulesIt1->second.size() <<
");" <<
"\n";
2077 finalString <<
" instance.SetReadRules( readrules );" <<
"\n";
2078 rulesIt1->second.fGenerated =
true;
2082 finalString <<
"\n" <<
" // the io read raw rules" <<
"\n" <<
" std::vector<::ROOT::Internal::TSchemaHelper> readrawrules(" <<
rulesIt2->second.size() <<
");" <<
"\n";
2084 finalString <<
" instance.SetReadRawRules( readrawrules );" <<
"\n";
2085 rulesIt2->second.fGenerated =
true;
2088 finalString <<
" return &instance;" <<
"\n" <<
" }" <<
"\n";
2092 finalString <<
" TGenericClassInfo *GenerateInitInstance(const " <<
csymbol <<
"*)" <<
"\n" <<
" {\n return GenerateInitInstanceLocal(static_cast<" <<
csymbol <<
"*>(nullptr));\n }" <<
"\n";
2095 finalString <<
" // Static variable to force the class initialization" <<
"\n";
2099 finalString <<
" static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal(static_cast<const " <<
csymbol <<
"*>(nullptr)); R__UseDummy(_R__UNIQUE_DICT_(Init));" <<
"\n";
2102 finalString <<
"\n" <<
" // Dictionary for non-ClassDef classes" <<
"\n"
2103 <<
" static TClass *" <<
mappedname <<
"_Dictionary() {\n"
2104 <<
" TClass* theClass ="
2105 <<
"::ROOT::GenerateInitInstanceLocal(static_cast<const " <<
csymbol <<
"*>(nullptr))->GetClass();\n"
2106 <<
" " <<
mappedname <<
"_TClassManip(theClass);\n";
2117 if (
decl->hasAttrs()){
2119 for (clang::Decl::attr_iterator
attrIt =
decl->attr_begin();
2136 manipString+=
" theClass->CreateAttributeMap();\n";
2137 manipString+=
" TDictAttributeMap* attrMap( theClass->GetAttributeMap() );\n";
2148 if (!(!(*internalDeclIt)->isImplicit()
2169 TMetaUtils::Error(
nullptr,
"Cannot convert field declaration to clang::NamedDecl");
2185 if (
attrName == propNames::comment ||
2187 attrName == propNames::ioname )
continue;
2212 finalString <<
"} // end of namespace ROOT" <<
"\n" <<
"\n";
2217 const cling::Interpreter &
interp)
2221 const clang::Type *
typeptr =
nullptr;
2222 const clang::CXXRecordDecl *
target =
2227 std::string
rule{
nRules > 1 ?
"rules" :
"rule"};
2228 std::string
verb{
nRules > 1 ?
"were" :
"was"};
2246 finalString <<
"\n // Schema evolution read functions\n";
2247 std::list<ROOT::SchemaRuleMap_t>::iterator
rIt =
rulesIt1.second.fRules.
begin();
2288 finalString <<
" // Registration Schema evolution read functions\n";
2292 <<
" ::ROOT::Internal::TSchemaHelper* rule;" <<
"\n";
2301 finalString <<
" std::vector<::ROOT::Internal::TSchemaHelper> readrules(" <<
rulesIt1->second.size()
2304 finalString <<
" TClass::RegisterReadRules(TSchemaRule::kReadRule, \"" <<
name
2305 <<
"\", std::move(readrules));\n";
2306 rulesIt1->second.fGenerated =
true;
2311 finalString <<
" std::vector<::ROOT::Internal::TSchemaHelper> readrawrules(" <<
rulesIt2->second.size()
2314 finalString <<
" TClass::RegisterReadRules(TSchemaRule::kReadRawRule, \"" <<
name
2315 <<
"\", std::move(readrawrules));\n";
2316 rulesIt2->second.fGenerated =
true;
2336 const clang::CXXRecordDecl *cl)
2346 auto ctxt = cl->getEnclosingNamespaceContext();
2351 const clang::NamedDecl *
namedCtxt = llvm::dyn_cast<clang::NamedDecl>(
ctxt);
2353 const clang::NamespaceDecl *
nsdecl = llvm::dyn_cast<clang::NamespaceDecl>(
namedCtxt);
2368 const clang::DeclContext *
ctxt = cl.getDeclContext();
2369 while(
ctxt && !
ctxt->isNamespace()) {
2390 const clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(
ctxt);
2396 out <<
"namespace " << ns->getNameAsString() <<
" {" << std::endl;
2415 clang::TemplateSpecializationKind kind = cl->getTemplateSpecializationKind();
2416 if (kind == clang::TSK_Undeclared ) {
2419 }
else if (kind == clang::TSK_ExplicitSpecialization) {
2434 const char *
proto =
"size_t";
2441 cling::LookupHelper::NoDiagnostics);
2445 cling::LookupHelper::NoDiagnostics);
2447 const clang::DeclContext *
ctxtnew =
nullptr;
2483 const clang::CXXRecordDecl*
clnew = llvm::dyn_cast<clang::CXXRecordDecl>(
ctxtnew);
2530 const clang::CXXRecordDecl *
decl,
2531 const cling::Interpreter &
interp,
2555 classname.insert(0,
"::");
2563 finalString <<
" // Wrappers around operator new" <<
"\n";
2564 finalString <<
" static void *new_" <<
mappedname.c_str() <<
"(void *p) {" <<
"\n" <<
" return p ? ";
2571 finalString <<
"::new(static_cast<::ROOT::Internal::TOperatorNewHelper*>(p)) ";
2576 finalString <<
"new " << classname.c_str() << args <<
";" <<
"\n";
2591 finalString <<
"::new(static_cast<::ROOT::Internal::TOperatorNewHelper*>(p)) ";
2605 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";
2609 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";
2613 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";
2617 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";
2621 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";
2623 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";
2627 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";
2629 finalString <<
"} // end of namespace ROOT for class " << classname.c_str() <<
"\n" <<
"\n";
2636 const cling::Interpreter &
interp,
2647 const clang::CXXRecordDecl *
clxx = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
2651 for(clang::CXXRecordDecl::base_class_const_iterator iter =
clxx->bases_begin(), end =
clxx->bases_end();
2657 Internal::RStl::Instance().GenerateTClassFor( iter->getType(),
interp,
normCtxt);
2662 for(clang::RecordDecl::field_iterator
field_iter =
clxx->field_begin(), end =
clxx->field_end();
2694 const clang::Type *
rawtype =
m.getType()->getCanonicalTypeInternal().getTypePtr();
2710 const clang::CXXRecordDecl*
CRD = llvm::dyn_cast<clang::CXXRecordDecl>(cl);
2722 if (
funcCV == (clang::FunctionDecl*)-1)
return 1;
2737 using res_t = std::pair<bool, int>;
2739 const clang::CompoundStmt*
FuncBody
2740 = llvm::dyn_cast_or_null<clang::CompoundStmt>(
funcCV->getBody());
2742 return res_t{
false, -1};
2747 return res_t{
false, -1};
2749 const clang::ReturnStmt*
RetStmt
2750 = llvm::dyn_cast<clang::ReturnStmt>(
FuncBody->body_back());
2752 return res_t{
false, -1};
2764 return res_t{
false, -1};
2772 return TMetaUtils::IsSTLCont(*
annotated.GetRecordDecl());
2780 clang::QualType
type =
m.getType();
2783 if (
decl)
return TMetaUtils::IsSTLCont(*
decl);
2792 clang::QualType
type = base.getType();
2795 if (
decl)
return TMetaUtils::IsSTLCont(*
decl);
2805 const std::function<
void(
const clang::Module::Header &)> &
closure,
2813 llvm::SetVector<const clang::Module *>
modules;
2815 for (
size_t i = 0; i <
modules.size(); ++i) {
2816 const clang::Module *M =
modules[i];
2817 for (
const clang::Module *
subModule : M->submodules())
2821 for (
const clang::Module *
m :
modules) {
2823 for (clang::Module *
used :
m->DirectUses) {
2829 for (
auto HK : {clang::Module::HK_Normal, clang::Module::HK_Textual, clang::Module::HK_Private,
2830 clang::Module::HK_PrivateTextual}) {
2847 static char t[4096];
2848 static const char*
constwd =
"const ";
2857 if (
lev==0 && *s==
'*')
continue;
2863 if (
lev==0 && *s==
' ' && *(s+1)!=
'*') {
p = t;
continue;}
2864 if (
p - t > (
long)
sizeof(t)) {
2865 printf(
"ERROR (rootcling): type name too long for StortTypeName: %s\n",
2878 const cling::Interpreter&
interp)
2883 if (!comment.empty() && comment[0] ==
'!')
2886 clang::QualType
type =
m.getType();
2888 if (
type->isReferenceType()) {
2893 std::string
mTypeName =
type.getAsString(
m.getASTContext().getPrintingPolicy());
2905 const clang::Type *
rawtype =
type.getTypePtr()->getBaseElementTypeUnsafe ();
2907 if (
rawtype->isPointerType()) {
2921 const clang::CXXRecordDecl *
cxxdecl =
rawtype->getAsCXXRecordDecl();
2938 const clang::Type *
rawtype =
m.getType().getTypePtr();
2962 return rawtype->getAsCXXRecordDecl();
2971 const cling::Interpreter &
interp,
2977 const clang::CXXRecordDecl*
decl = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
2979 if (!
decl || !
decl->isCompleteDefinition()) {
2983 std::string fullname;
2997 ROOT::TMetaUtils::Info(
nullptr,
"Class %s: Do not generate Streamer() [*** custom streamer ***]\n",fullname.c_str());
3022 const clang::ASTContext&
Ctx =
interpreter.getCI()->getASTContext();
3028 if (llvm::isa<clang::PointerType>(
instanceType.getTypePtr())) {
3042 if (llvm::isa<clang::ReferenceType>(
instanceType.getTypePtr())) {
3062 clang::NestedNameSpecifier *prefix =
nullptr;
3064 const clang::ElaboratedType* etype
3065 = llvm::dyn_cast<clang::ElaboratedType>(
instanceType.getTypePtr());
3070 instanceType = clang::QualType(etype->getNamedType().getTypePtr(),0);
3076 const clang::TemplateSpecializationType*
TST
3077 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instanceType.getTypePtr());
3079 const clang::ClassTemplateSpecializationDecl*
TSTdecl
3080 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
instanceType.getTypePtr()->getAsCXXRecordDecl());
3096 clang::TemplateDecl *Template =
TSTdecl->getSpecializedTemplate()->getMostRecentDecl();
3097 clang::TemplateParameterList *Params = Template->getTemplateParameters();
3104 llvm::SmallVector<clang::TemplateArgument, 4>
desArgs;
3105 llvm::SmallVector<clang::TemplateArgument, 4>
canonArgs;
3114 if (
I->getKind() == clang::TemplateArgument::Template) {
3121 clang::NamespaceDecl* ns = clang::dyn_cast<clang::NamespaceDecl>(
declCtxt);
3122 clang::NestedNameSpecifier*
nns;
3124 nns = cling::utils::TypeName::CreateNestedNameSpecifier(
Ctx, ns);
3125 }
else if (clang::TagDecl*
TD = llvm::dyn_cast<clang::TagDecl>(
declCtxt)) {
3126 nns = cling::utils::TypeName::CreateNestedNameSpecifier(
Ctx,
TD,
false );
3133 if (clang::UsingShadowDecl *
USD =
templateName.getAsUsingShadowDecl())
3143 if (
I->getKind() != clang::TemplateArgument::Type) {
3148 clang::QualType
SubTy =
I->getAsType();
3170 if (
templateArg.getKind() != clang::TemplateArgument::Type) {
3176 clang::SourceLocation
TemplateLoc = Template->getSourceRange ().getBegin();
3179 clang::TemplateTypeParmDecl *
TTP = llvm::dyn_cast<clang::TemplateTypeParmDecl>(*
Param);
3182 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
3184 clang::TemplateArgumentLoc
ArgType = S.SubstDefaultTemplateArgumentIfAvailable(
3194 if (
ArgType.getArgument().isNull()
3195 ||
ArgType.getArgument().getKind() != clang::TemplateArgument::Type) {
3197 "Template parameter substitution failed for %s around %s\n",
3217 TST->getCanonicalTypeInternal());
3246 llvm::StringRef title;
3249 if (clang::AnnotateAttr *A =
m.getAttr<clang::AnnotateAttr>())
3250 title = A->getAnnotation();
3264 if (title.size() == 0 || (title[0] !=
'['))
return llvm::StringRef();
3266 if (
rightbracket == llvm::StringRef::npos)
return llvm::StringRef();
3285 char *current =
const_cast<char*
>(
working.c_str());
3291 for(i=0;i<
strlen(current);i++) {
3299 return llvm::StringRef();
3304 const clang::CXXRecordDecl *
parent_clxx = llvm::dyn_cast<clang::CXXRecordDecl>(
m.getDeclContext());
3305 const clang::FieldDecl *
index1 =
nullptr;
3318 if (
field_iter->getNameAsString() ==
m.getNameAsString() ) {
3326 return llvm::StringRef();
3338 return llvm::StringRef();
3363 return llvm::StringRef();
3365 if ( found && (
index1->getAccess() == clang::AS_private) ) {
3370 return llvm::StringRef();
3379 return llvm::StringRef();
3400 while((
c = in[i++])) {
3401 const char *
repl =
nullptr;
3403 case '+':
repl =
"pL";
break;
3404 case '-':
repl =
"mI";
break;
3405 case '*':
repl =
"mU";
break;
3406 case '/':
repl =
"dI";
break;
3407 case '&':
repl =
"aN";
break;
3408 case '%':
repl =
"pE";
break;
3409 case '|':
repl =
"oR";
break;
3410 case '^':
repl =
"hA";
break;
3411 case '>':
repl =
"gR";
break;
3412 case '<':
repl =
"lE";
break;
3413 case '=':
repl =
"eQ";
break;
3414 case '~':
repl =
"wA";
break;
3415 case '.':
repl =
"dO";
break;
3416 case '(':
repl =
"oP";
break;
3417 case ')':
repl =
"cP";
break;
3418 case '[':
repl =
"oB";
break;
3419 case ']':
repl =
"cB";
break;
3420 case '{':
repl =
"lB";
break;
3421 case '}':
repl =
"rB";
break;
3422 case ';':
repl =
"sC";
break;
3423 case '#':
repl =
"hS";
break;
3424 case '?':
repl =
"qM";
break;
3425 case '`':
repl =
"bT";
break;
3426 case '!':
repl =
"nO";
break;
3427 case ',':
repl =
"cO";
break;
3428 case '$':
repl =
"dA";
break;
3429 case ' ':
repl =
"sP";
break;
3430 case ':':
repl =
"cL";
break;
3431 case '"':
repl =
"dQ";
break;
3432 case '@':
repl =
"aT";
break;
3433 case '\'':
repl =
"sQ";
break;
3434 case '\\':
repl =
"fI";
break;
3443 if (out.empty() ||
isdigit(out[0]))
3444 out.insert(out.begin(),
'_');
3447static clang::SourceLocation
3461 const cling::Interpreter&
interp)
3491 using namespace clang;
3516 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>>(),
3531 assert(
decl.isFirstDecl() &&
"Couldn't trace back include from a decl"
3532 " that is not from an AST file");
3557 clang::OptionalFileEntryRef
FELong;
3559 for (llvm::sys::path::const_iterator
3572 &&
"Mismatched partitioning of file name!");
3576 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>>(),
3588 for (llvm::sys::path::reverse_iterator
3596 &&
"Mismatched partitioning of file name!");
3602 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>>(),
3605 nullptr,
nullptr ) ==
FELong) {
3616 const clang::QualType &
qtype,
3628 const clang::QualType &
qtype,
3634 cling::Interpreter::PushTransactionRAII
RAII(
const_cast<cling::Interpreter*
>(&
interpreter));
3646 clang::ClassTemplateDecl*&
ctd,
3647 clang::ClassTemplateSpecializationDecl*&
ctsd)
3649 using namespace clang;
3657 if (
theType->isPointerType()) {
3662 ctsd = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
rType->getDecl());
3664 ctd =
ctsd->getSpecializedTemplate();
3674 ctsd = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
qt->getAsCXXRecordDecl());
3676 ctd =
ctsd->getSpecializedTemplate();
3691 using namespace clang;
3707 using namespace clang;
3726 const clang::NamedDecl&
tPar,
3727 const cling::Interpreter&
interp,
3731 using namespace clang;
3736 if (!
ttpdPtr->hasDefaultArgument())
return false;
3758 const clang::ElaboratedType* etype
3759 = llvm::dyn_cast<clang::ElaboratedType>(
tParQualType.getTypePtr());
3761 tParQualType = clang::QualType(etype->getNamedType().getTypePtr(),0);
3762 etype = llvm::dyn_cast<clang::ElaboratedType>(
tParQualType.getTypePtr());
3766 llvm::dyn_cast<TemplateSpecializationType>(
tParQualType.getTypePtr());
3772 = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
tArgQualType->getAsCXXRecordDecl());
3790 clang::Sema& S =
interp.getCI()->getSema();
3791 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interp));
3792 llvm::SmallVector<clang::TemplateArgument, 4>
canonArgs;
3805 newArg.getKind() != clang::TemplateArgument::Type) {
3807 "Template parameter substitution failed!");
3811 = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
newArg.getAsType()->getAsCXXRecordDecl());
3827 const clang::NamedDecl&
tPar)
3829 using namespace clang;
3834 if (!
nttpd.hasDefaultArgument())
3845 const int value =
tArg.getAsIntegral().getLimitedValue();
3858 using namespace clang;
3859 if (!
nDecl)
return false;
3861 return ttpd->hasDefaultArgument();
3863 return nttpd->hasDefaultArgument();
3870 const cling::Interpreter&
interp,
3875 const clang::TemplateArgument &
tArg,
3876 const cling::Interpreter&
interp,
3878 const clang::ASTContext&
astCtxt)
3881 using namespace clang;
3888 if (
tArg.getKind() == clang::TemplateArgument::Type) {
3897 }
else if (
normTArg.getKind() == clang::TemplateArgument::Pack) {
3898 assert(
tArg.getKind() == clang::TemplateArgument::Pack );
3926 const cling::Interpreter&
interp,
3930 using namespace clang;
3939 const int nArgsToKeep =
normCtxt.GetNargsToKeep(
ctd);
3949 if (llvm::isa<clang::PointerType>(
normalizedType.getTypePtr())) {
3962 if (llvm::isa<clang::ReferenceType>(
normalizedType.getTypePtr())) {
3981 clang::NestedNameSpecifier* prefix =
nullptr;
3983 const clang::ElaboratedType* etype
3984 = llvm::dyn_cast<clang::ElaboratedType>(
normalizedType.getTypePtr());
3990 normalizedType = clang::QualType(etype->getNamedType().getTypePtr(),0);
3998 clang::TemplateParameterList*
tpl =
rd->getTemplateParameters();
3999 if (
tpl->getMinRequiredArguments () <
tpl->size()) {
4006 Error(
"KeepNParams",
"Not found template default arguments\n");
4023 llvm::dyn_cast<TemplateSpecializationType>(
normalizedType.getTypePtr());
4029 const clang::ClassTemplateSpecializationDecl*
TSTdecl
4030 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
normalizedType.getTypePtr()->getAsCXXRecordDecl());
4038 llvm::SmallVector<TemplateArgument, 4>
argsToKeep;
4050 Error(
"KeepNParams",
"The parameter number %s is null.\n",
formal);
4072 if (
tParPtr->isTemplateParameterPack() ) {
4102 if (
argKind == clang::TemplateArgument::Type){
4105 }
else if (
argKind == clang::TemplateArgument::Integral){
4153 cling::Interpreter::PushTransactionRAII
RAII(
const_cast<cling::Interpreter*
>(&
interpreter));
4176 if (
type.isNull()) {
4184 clang::PrintingPolicy
policy(
ctxt.getPrintingPolicy());
4185 policy.SuppressTagKeyword =
true;
4186 policy.SuppressScope =
true;
4187 policy.AnonymousTagLocations =
false;
4195 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
4228 clang::ASTContext&
astCtxt =
sema.getASTContext();
4238std::pair<std::string,clang::QualType>
4259 cling::LookupHelper::DiagSetting::NoDiagnostics,
4278 "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());
4306 llvm::errs() << llvm::StringRef(
commentStart, 80) <<
'\n';
4355 if (
const clang::FunctionDecl*
FD = clang::dyn_cast<clang::FunctionDecl>(&
decl)) {
4356 if (
FD->isImplicit()) {
4360 if (
FD->isExplicitlyDefaulted() ||
FD->isDeletedAsWritten()) {
4364 }
else if (
FD->doesThisDeclarationHaveABody()) {
4369 &&
"Expected macro or end of body at '}'");
4381 }
else if (
const clang::EnumConstantDecl*
ECD
4382 = clang::dyn_cast<clang::EnumConstantDecl>(&
decl)) {
4384 if (
ECD->getNextDeclInContext())
4461 if (!
decl)
return false;
4468 static const std::vector<std::string>
signatures =
4469 {
"ClassDef",
"ClassDefOverride",
"ClassDefNV",
"ClassDefInline",
"ClassDefInlineOverride",
"ClassDefInlineNV" };
4486 clang::SourceLocation *
loc,
4489 using namespace clang;
4492 =
interpreter.getLookupHelper().findFunctionProto(&
decl,
"DeclFileLine",
"",
4493 cling::LookupHelper::NoDiagnostics);
4499 if (comment.size()) {
4506 return llvm::StringRef();
4518 if (
rawtype->isElaboratedTypeSpecifier() ) {
4522 rawtype =
type.getTypePtr()->getBaseElementTypeUnsafe ();
4531 if (
rawtype->isElaboratedTypeSpecifier() ) {
4551 if (
ctxt.isNamespace() ||
ctxt.isTranslationUnit())
4553 else if(
const auto parentdecl = llvm::dyn_cast<clang::CXXRecordDecl>(&
ctxt))
4566 const clang::DeclContext *
ctxt =
decl.getDeclContext();
4567 switch (
decl.getAccess()) {
4568 case clang::AS_public:
4570 case clang::AS_protected:
4572 case clang::AS_private:
4574 case clang::AS_none:
4578 assert(
false &&
"Unexpected value for the access property value in Clang");
4588 return cling::utils::Analyze::IsStdClass(cl);
4598 if (cling::utils::Analyze::IsStdClass(cl)) {
4599 static const char *names[] =
4600 {
"shared_ptr",
"__shared_ptr",
4601 "vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset"};
4602 llvm::StringRef
clname(cl.getName());
4603 for(
auto &&
name : names) {
4641 const clang::CXXRecordDecl *
thisDecl =
4642 llvm::dyn_cast_or_null<clang::CXXRecordDecl>(
lh.findScope(
typ, cling::LookupHelper::WithDiagnostics));
4646 Error(
"IsOfType",
"Record decl of type %s not found in the AST.",
typ.c_str());
4676 if (!IsStdClass(cl)) {
4677 auto *
nsDecl = llvm::dyn_cast<clang::NamespaceDecl>(cl.getDeclContext());
4678 if (cl.getName() !=
"RVec" ||
nsDecl ==
nullptr ||
nsDecl->getName() !=
"VecOps")
4681 auto *
parentNsDecl = llvm::dyn_cast<clang::NamespaceDecl>(cl.getDeclContext()->getParent());
4686 return STLKind(cl.getName());
4690 using namespace clang;
4691 struct SearchTypedef:
public TypeVisitor<SearchTypedef, bool> {
4696 return Visit(
AT->getElementType().getTypePtr());
4699 return Visit(
DT->getUnderlyingType().getTypePtr());
4702 return Visit(
PT->getPointeeType().getTypePtr());
4705 return Visit(
RT->getPointeeType().getTypePtr());
4708 return Visit(
STST->getReplacementType().getTypePtr());
4712 if (
TA.getKind() == TemplateArgument::Type && Visit(
TA.getAsType().getTypePtr()))
4721 return TOT->getUnmodifiedType().getTypePtr();
4726 if (
NNS->getKind() == NestedNameSpecifier::TypeSpec) {
4727 if (Visit(
NNS->getAsType()))
4732 return Visit(
ET->getNamedType().getTypePtr());
4753 using namespace llvm;
4754 using namespace clang;
4755 const clang::ASTContext &
Ctxt =
instance->getAsCXXRecordDecl()->getASTContext();
4758 const clang::ElaboratedType* etype
4759 = llvm::dyn_cast<clang::ElaboratedType>(
input.getTypePtr());
4764 assert(
instance->getAsCXXRecordDecl() !=
nullptr &&
"ReSubstTemplateArg only makes sense with a type representing a class.");
4784 if (
nQT ==
QT->getPointeeType())
return QT;
4800 if (
nQT ==
QT->getPointeeType())
return QT;
4821 if (
newQT ==
arr->getElementType())
return QT;
4825 arr->getSizeModifier(),
4826 arr->getIndexTypeCVRQualifiers());
4834 arr->getSizeModifier(),
4835 arr->getIndexTypeCVRQualifiers(),
4836 arr->getBracketsRange());
4841 if (
newQT ==
arr->getElementType())
return QT;
4843 arr->getSizeModifier(),
4844 arr->getIndexTypeCVRQualifiers());
4849 if (
newQT ==
arr->getElementType())
return QT;
4852 arr->getSizeModifier(),
4853 arr->getIndexTypeCVRQualifiers(),
4854 arr->getBracketsRange());
4863 etype = llvm::dyn_cast<clang::ElaboratedType>(
instance);
4865 instance = etype->getNamedType().getTypePtr();
4869 const clang::TemplateSpecializationType*
TST
4870 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instance);
4874 const clang::ClassTemplateSpecializationDecl*
TSTdecl
4875 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
instance->getAsCXXRecordDecl());
4879 const clang::SubstTemplateTypeParmType *
substType
4880 = llvm::dyn_cast<clang::SubstTemplateTypeParmType>(
input.getTypePtr());
4884 const clang::ClassTemplateDecl *
replacedCtxt =
nullptr;
4888 unsigned int index =
substType->getReplacedParameter()->getIndex();
4891 if (
decl->getKind() == clang::Decl::ClassTemplatePartialSpecialization) {
4892 const clang::ClassTemplatePartialSpecializationDecl *
spec = llvm::dyn_cast<clang::ClassTemplatePartialSpecializationDecl>(
decl);
4894 unsigned int depth =
substType->getReplacedParameter()->getDepth();
4910 const clang::SubstTemplateTypeParmType *
argType
4911 = llvm::dyn_cast<clang::SubstTemplateTypeParmType>(
argQualType);
4936 llvm::raw_string_ostream ostream(
astDump);
4939 ROOT::TMetaUtils::Warning(
"ReSubstTemplateArg",
"Unexpected type of declaration context for template parameter: %s.\n\tThe responsible class is:\n\t%s\n",
4946 const auto &
TAs =
TST->template_arguments();
4963 const clang::TemplateSpecializationType*
inputTST
4964 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
input.getTypePtr());
4969 llvm::SmallVector<clang::TemplateArgument, 4>
desArgs;
4970 for (
const clang::TemplateArgument &
TA :
inputTST->template_arguments()) {
4971 if (
TA.getKind() != clang::TemplateArgument::Type) {
4976 clang::QualType
SubTy =
TA.getAsType();
4978 if (llvm::isa<clang::ElaboratedType>(
SubTy)
4979 || llvm::isa<clang::SubstTemplateTypeParmType>(
SubTy)
4980 || llvm::isa<clang::TemplateSpecializationType>(
SubTy)) {
4995 inputTST->getCanonicalTypeInternal());
5036 static const char *
stls[] =
5037 {
"any",
"vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset",
5038 "forward_list",
"unordered_set",
"unordered_multiset",
"unordered_map",
"unordered_multimap",
"RVec",
nullptr};
5052 for (
int k = 1;
stls[k]; k++) {
5066 TND =
TND->getMostRecentDecl();
5067 while (
TND && !(
TND->hasAttrs()))
5068 TND =
TND->getPreviousDecl();
5080 TD =
TD->getMostRecentDecl();
5081 while (
TD && !(
TD->hasAttrs() &&
TD->isThisDeclarationADefinition()))
5082 TD =
TD->getPreviousDecl();
5138 std::list<std::pair<std::string,unsigned int> >&
enclosingSc)
5166 std::string::size_type
beginVar = 0;
5167 std::string::size_type
endVar = 0;
5171 std::string::size_type
endVarName = std::string::npos;
5241 str.replace(
start_pos, from.length(), to);
5308 return llvm::sys::path::extension(
filename) ==
".h" ||
5309 llvm::sys::path::extension(
filename) ==
".hh" ||
5310 llvm::sys::path::extension(
filename) ==
".hpp" ||
5311 llvm::sys::path::extension(
filename) ==
".H" ||
5312 llvm::sys::path::extension(
filename) ==
".h++" ||
5313 llvm::sys::path::extension(
filename) ==
"hxx" ||
5314 llvm::sys::path::extension(
filename) ==
"Hxx" ||
5315 llvm::sys::path::extension(
filename) ==
"HXX";
5321 cling::Interpreter::IgnoreFilesFunc_t
ignoreFiles,
5322 const cling::Interpreter &
interp,
5330 clang::Decl *
ncDecl =
const_cast<clang::Decl *
>(
decl);
5375 static const std::string
scopeType [] = {
"namespace ",
"inline namespace ",
"class "};
5417 std::string typeName;
5420 if (llvm::isa<clang::TemplateTypeParmDecl>(
nDecl)){
5421 typeName =
"typename ";
5422 if (
nDecl->isParameterPack())
5424 typeName += (*prmIt)->getNameAsString();
5427 else if (
auto nttpd = llvm::dyn_cast<clang::NonTypeTemplateParmDecl>(
nDecl)){
5431 if (
theType.getAsString().find(
"enum") != std::string::npos){
5433 llvm::raw_string_ostream ostream(
astDump);
5434 nttpd->dump(ostream);
5445 else if (
auto ttpd = llvm::dyn_cast<clang::TemplateTemplateParmDecl>(
nDecl)){
5449 llvm::raw_string_ostream ostream(
astDump);
5450 ttpd->dump(ostream);
5475 "Cannot extract template parameter list for %s",
5483 "Problems with arguments for forward declaration of class %s\n",
5493 if (llvm::isa<clang::TemplateTemplateParmDecl>(&
templDecl)) {
5515 if (clang::TemplateArgument::Type != arg.getKind())
return 0;
5530 if (llvm::isa<clang::BuiltinType>(
argTypePtr)){
5563 if (
specDef->getTemplateSpecializationKind() != clang::TSK_ExplicitSpecialization)
5567 std::cout <<
" Forward declaring template spec " <<
normalizedName <<
":\n";
5572 std::cout <<
" o Template argument ";
5574 std::cout <<
"successfully treated. Arg fwd decl: " <<
argFwdDecl << std::endl;
5576 std::cout <<
"could not be treated. Abort fwd declaration generation.\n";
5617 std::cout <<
"Class " <<
recordDecl.getNameAsString()
5618 <<
" is a template specialisation. Treating its arguments.\n";
5622 std::cout <<
" o Template argument ";
5624 std::cout <<
"successfully treated. Arg fwd decl: " <<
argFwdDecl << std::endl;
5626 std::cout <<
"could not be treated. Abort fwd declaration generation.\n";
5674 std::string buffer =
tdnDecl.getNameAsString();
5677 if (
const clang::TagType* TT
5679 if (clang::NamedDecl*
ND = TT->getDecl()) {
5680 if (!
ND->getIdentifier()) {
5724 std::cout <<
"Typedef " <<
tdnDecl.getNameAsString() <<
" hides a class: "
5751 const clang::PrintingPolicy&
ppolicy)
5754 auto&
ctxt = par.getASTContext();
5775 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
short Version_t
Class version identifier (short)
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 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 target
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
A RAII helper to remove and readd enclosing _Atomic() It expects no spaces at the beginning or end of...
const std::string & GetPathSeparator()
Namespace for new ROOT classes and functions.
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)
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
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 .