24#include <unordered_set>
27#include "RConfigure.h"
35#include "clang/AST/ASTContext.h"
36#include "clang/AST/Attr.h"
37#include "clang/AST/CXXInheritance.h"
38#include "clang/AST/Decl.h"
39#include "clang/AST/DeclTemplate.h"
40#include "clang/AST/Mangle.h"
41#include "clang/AST/Type.h"
42#include "clang/AST/TypeVisitor.h"
43#include "clang/Frontend/CompilerInstance.h"
44#include "clang/Lex/HeaderSearch.h"
45#include "clang/Lex/ModuleMap.h"
46#include "clang/Lex/Preprocessor.h"
47#include "clang/Lex/PreprocessorOptions.h"
49#include "clang/Sema/Lookup.h"
50#include "clang/Sema/Sema.h"
51#include "clang/Sema/SemaDiagnostic.h"
53#include "cling/Interpreter/LookupHelper.h"
54#include "cling/Interpreter/Transaction.h"
55#include "cling/Interpreter/Interpreter.h"
56#include "cling/Utils/AST.h"
58#include "llvm/Support/Path.h"
59#include "llvm/Support/FileSystem.h"
64#define strncasecmp _strnicmp
84 using DeclsCont_t = TNormalizedCtxt::Config_t::SkipCollection;
101 bool replace =
false);
112 clang::NestedNameSpecifier*
scope,
115 if (!
scope)
return nullptr;
138static bool CheckDefinition(
const clang::CXXRecordDecl *cl,
const clang::CXXRecordDecl *context)
140 if (!cl->hasDefinition()) {
143 "Missing definition for class %s, please #include its header in the header of %s\n",
144 cl->getName().str().c_str(), context->getName().str().c_str());
147 "Missing definition for class %s\n",
148 cl->getName().str().c_str());
161 clang::NestedNameSpecifier *
scope,
164 if (!
scope)
return nullptr;
186 const clang::BuiltinType *
builtin = llvm::dyn_cast<clang::BuiltinType>(
type->getCanonicalTypeInternal().getTypePtr());
206 clang::ASTContext &
C = cl.getASTContext();
207 clang::DeclarationName
DName = &
C.Idents.get(
what);
208 auto R = cl.lookup(
DName);
209 for (
const clang::NamedDecl *D :
R)
221 clang::LookupResult
R(
SemaR,
DName, clang::SourceLocation(),
222 clang::Sema::LookupOrdinaryName,
223 clang::Sema::ForExternalRedeclaration);
224 SemaR.LookupInSuper(
R, &
const_cast<clang::CXXRecordDecl&
>(cl));
227 return llvm::dyn_cast<const clang::FieldDecl>(
R.getFoundDecl());
233 ? cling::LookupHelper::WithDiagnostics
234 : cling::LookupHelper::NoDiagnostics;
241namespace TMetaUtils {
250 Error(
"TNormalizedCtxt::AddTemplAndNargsToKeep",
251 "Tring to specify a number of template arguments to keep for a null pointer. Exiting without assigning any value.\n");
255 const clang::ClassTemplateDecl*
canTempl =
templ->getCanonicalDecl();
260 const std::string
i_str (std::to_string(i));
262 Error(
"TNormalizedCtxt::AddTemplAndNargsToKeep",
263 "Tring to specify for template %s %s arguments to keep, while before this number was %s\n",
264 canTempl->getNameAsString().c_str(),
277 const clang::ClassTemplateDecl*
constTempl =
templ->getCanonicalDecl();
328 std::unique_ptr<clang::MangleContext>
mangleCtx(
rDecl->getASTContext().createMangleContext());
332 if (
const clang::TypeDecl*
TD = llvm::dyn_cast<clang::TypeDecl>(
rDecl)) {
333 mangleCtx->mangleCXXRTTI(clang::QualType(
TD->getTypeForDecl(), 0),
sstr);
359 "Demangled typeinfo name '%s' does not contain `RTTI Type Descriptor'\n",
363 "Demangled typeinfo name '%s' does not start with 'typeinfo for'\n",
380 const clang::RecordDecl *
decl,
409 const clang::RecordDecl *
decl,
438 "Could not remove the requested template arguments.\n");
449 const clang::RecordDecl *
decl,
483 const clang::RecordDecl *
decl,
545 if (
tname.empty())
return false;
559 if (!
dest.isNull() && (
dest != t)) {
576 if (!
dest.isNull() && (
dest != t) &&
595 const clang::NamespaceDecl *
nsdecl = llvm::dyn_cast<clang::NamespaceDecl>(
scope);
608 if (
tname.empty())
return false;
637 clang::PrintingPolicy
policy(
fInterpreter->getCI()->getASTContext().getPrintingPolicy());
638 policy.SuppressTagKeyword =
true;
639 policy.SuppressScope =
true;
654 for(
unsigned int i = 1; i<
result.length(); ++i) {
666 }
else if ( (i+1) <
result.length() &&
704 clang::QualType
toSkip =
lh.findType(
name, cling::LookupHelper::WithDiagnostics);
705 if (
const clang::Type* T =
toSkip.getTypePtr()) {
706 const clang::TypedefType *
tt = llvm::dyn_cast<clang::TypedefType>(T);
708 clang::Decl* D =
tt->getDecl();
709 fConfig.m_toSkip.insert(D);
711 clang::QualType
canon =
toSkip->getCanonicalTypeInternal();
712 fConfig.m_toReplace.insert(std::make_pair(
canon.getTypePtr(),T));
714 fTypeWithAlternative.insert(T);
727 keepTypedef(
lh,
"Double32_t");
728 keepTypedef(
lh,
"Float16_t");
729 keepTypedef(
lh,
"Long64_t",
true);
730 keepTypedef(
lh,
"ULong64_t",
true);
732 clang::QualType
toSkip =
lh.findType(
"string", cling::LookupHelper::WithDiagnostics);
734 if (
const clang::TypedefType* TT
735 = llvm::dyn_cast_or_null<clang::TypedefType>(
toSkip.getTypePtr()))
736 fConfig.m_toSkip.insert(TT->getDecl());
738 toSkip =
lh.findType(
"std::string", cling::LookupHelper::WithDiagnostics);
740 if (
const clang::TypedefType* TT
741 = llvm::dyn_cast_or_null<clang::TypedefType>(
toSkip.getTypePtr()))
742 fConfig.m_toSkip.insert(TT->getDecl());
744 clang::QualType
canon =
toSkip->getCanonicalTypeInternal();
745 fConfig.m_toReplace.insert(std::make_pair(
canon.getTypePtr(),
toSkip.getTypePtr()));
756 return (cl.getKind() == clang::Decl::ClassTemplatePartialSpecialization
757 || cl.getKind() == clang::Decl::ClassTemplateSpecialization);
764 const cling::Interpreter&
interp)
766 clang::Sema* S = &
interp.getSema();
767 const clang::NamedDecl*
ND = cling::utils::Lookup::Named(S,
name, cl);
768 if (
ND == (clang::NamedDecl*)-1)
769 return (clang::FunctionDecl*)-1;
770 return llvm::dyn_cast_or_null<clang::FunctionDecl>(
ND);
776const clang::CXXRecordDecl *
780 const cling::LookupHelper&
lh =
interp.getLookupHelper();
783 const clang::CXXRecordDecl *
result
784 = llvm::dyn_cast_or_null<clang::CXXRecordDecl>
791 result = llvm::dyn_cast_or_null<clang::CXXRecordDecl>
802 clang::QualType
qType(cl->getTypeForDecl(),0);
810 clang::Sema& S =
interp.getCI()->getSema();
813 cling::Interpreter::PushTransactionRAII
RAII(
const_cast<cling::Interpreter*
>(&
interp));
814 return S.RequireCompleteType(
Loc, Type, clang::diag::err_incomplete_type);
820 const clang::CXXRecordDecl *context,
const cling::Interpreter &
interp)
826 if (!cl->getDefinition() || !cl->isCompleteDefinition()) {
834 if (!base->hasDefinition()) {
838 return cl->isDerivedFrom(base);
850 const clang::NamedDecl *base
854 return IsBase(
CRD, llvm::dyn_cast<clang::CXXRecordDecl>( base ),
855 llvm::dyn_cast<clang::CXXRecordDecl>(
m.getDeclContext()),
interp);
864 const clang::QualType &
qti,
866 const cling::Interpreter &
interp,
874 kBIT_ISSTRING = 0x40000000,
881 const clang::Type &
ti( *
qti.getTypePtr() );
904 if (
tiName ==
"string")
kase |= kBIT_ISSTRING;
905 if (
tiName ==
"string*")
kase |= kBIT_ISSTRING;
909 tcl =
" internal error in rootcling ";
934 <<
" R__b >> readtemp;" << std::endl
935 <<
" " <<
R__t <<
" = static_cast<" <<
tiName <<
">(readtemp);" << std::endl;
947 finalString <<
" if (R__b.GetInfo() && R__b.GetInfo()->GetOldVersion()<=3) {" << std::endl;
949 finalString <<
" R__ASSERT(0);// " <<
objType <<
" is abstract. We assume that older file could not be produced using this streaming method." << std::endl;
952 <<
" " <<
R__t <<
"->Streamer(R__b);" << std::endl;
955 <<
" " <<
R__t <<
" = (" <<
tiName <<
")R__b.ReadObjectAny(" <<
tcl <<
");" << std::endl
956 <<
" }" << std::endl;
962 <<
" R__str.Streamer(R__b);" << std::endl
963 <<
" " <<
R__t <<
" = R__str.Data();}" << std::endl;
969 <<
" R__str.Streamer(R__b);" << std::endl
970 <<
" " <<
R__t <<
" = new string(R__str.Data());}" << std::endl;
997 finalString <<
" R__b >> *reinterpret_cast<Int_t*>(ptr_enum); }" << std::endl;
1002 if (!
R__t)
return 0;
1007 if (!
R__t)
return 1;
1012 if (!
R__t)
return 0;
1013 finalString <<
" {TString R__str(" <<
R__t <<
".c_str());" << std::endl
1014 <<
" R__str.Streamer(R__b);};" << std::endl;
1018 if (!
R__t)
return 0;
1019 finalString <<
" {TString R__str(" <<
R__t <<
"->c_str());" << std::endl
1020 <<
" R__str.Streamer(R__b);}" << std::endl;
1024 if (!
R__t)
return 1;
1029 if (!
R__t)
return 1;
1042 clang::CXXRecordDecl*
ncCl =
const_cast<clang::CXXRecordDecl*
>(cl);
1045 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
1048 if (
Ctor->getAccess() == clang::AS_public && !
Ctor->isDeleted()) {
1066 const cling::LookupHelper&
lh =
interpreter.getLookupHelper();
1075 return EIOCtorCategory::kAbsent;
1078 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
1079 for (
auto iter = cl->ctor_begin(), end = cl->ctor_end(); iter != end; ++iter)
1081 if ((iter->getAccess() != clang::AS_public) || (iter->getNumParams() != 1))
1085 clang::QualType
argType((*iter->param_begin())->getType());
1089 if (
argType->isPointerType()) {
1092 }
else if (
argType->isReferenceType()) {
1099 const clang::CXXRecordDecl *
argDecl =
argType->getAsCXXRecordDecl();
1106 std::string
clarg(
"class ");
1113 return EIOCtorCategory::kAbsent;
1126 if (!
ioctortype.GetType() && (!arg || !arg[0])) {
1140 const cling::Interpreter &
interp,
1143 const clang::FunctionDecl*
funcD
1145 diagnose ? cling::LookupHelper::WithDiagnostics
1146 : cling::LookupHelper::NoDiagnostics);
1148 return llvm::dyn_cast<const clang::CXXMethodDecl>(
funcD);
1157 namespace TMetaUtils {
1160 const cling::LookupHelper&
lh =
interp.getLookupHelper();
1179 const cling::Interpreter &
interp)
1181 if (cl->isAbstract())
return false;
1187 if (EIOCtorCategory::kAbsent ==
ioCtorCat)
1197 if (EIOCtorCategory::kIOPtrType ==
ioCtorCat) {
1199 }
else if (EIOCtorCategory::kIORefType ==
ioCtorCat) {
1203 arg +=
")nullptr )";
1206 const clang::CXXMethodDecl *
method
1208 cling::LookupHelper::NoDiagnostics);
1209 if (
method &&
method->getAccess() != clang::AS_public) {
1223 const cling::Interpreter&
interp)
1225 if (!cl)
return false;
1227 if (cl->hasUserDeclaredDestructor()) {
1229 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interp));
1230 clang::CXXDestructorDecl *
dest = cl->getDestructor();
1232 return (
dest->getAccess() == clang::AS_public);
1246 const cling::Interpreter &
interp,
1249 const clang::CXXMethodDecl *
method
1251 diagnose ? cling::LookupHelper::WithDiagnostics
1252 : cling::LookupHelper::NoDiagnostics);
1253 return (
method &&
method->getAccess() == clang::AS_public);
1264 const char *
proto =
"TDirectory*";
1265 const char *
name =
"DirectoryAutoAdd";
1279 const char *
proto =
"TCollection*,TFileMergeInfo*";
1280 const char *
name =
"Merge";
1293 const char *
proto =
"TCollection*";
1294 const char *
name =
"Merge";
1309 const char *
proto =
"TFileMergeInfo*";
1310 const char *
name =
"ResetAfterMerge";
1320 const clang::CXXRecordDecl*
clxx,
1321 const cling::Interpreter &
interp,
1324 static const char *
proto =
"TBuffer&";
1326 const clang::CXXMethodDecl *
method
1328 cling::LookupHelper::NoDiagnostics);
1339 const clang::CXXRecordDecl*
clxx,
1340 const cling::Interpreter &
interp,
1343 static const char *
proto =
"TBuffer&,TClass*";
1345 const clang::CXXMethodDecl *
method
1347 cling::LookupHelper::NoDiagnostics);
1412 llvm::raw_string_ostream stream(
qual_name);
1413 clang::PrintingPolicy
policy( cl.getASTContext().getPrintingPolicy() );
1414 policy.SuppressTagKeyword =
true;
1415 policy.SuppressUnwrittenScope =
true;
1417 cl.getNameForDiagnostic(stream,
policy,
true);
1473 std::stringstream
dims;
1476 const clang::ASTContext&
astContext = cl.getASTContext();
1479 for(clang::RecordDecl::field_iterator
field_iter = cl.field_begin(), end = cl.field_end();
1493 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
fieldType.getTypePtr());
1495 dims <<
"[" <<
arrayType->getSize().getLimitedValue() <<
"]";
1497 arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual());
1507 for(clang::CXXRecordDecl::base_class_const_iterator iter = cl.bases_begin(), end = cl.bases_end();
1510 std::string
basename( iter->getType()->getAsCXXRecordDecl()->getNameAsString() );
1520 const cling::Interpreter &
interp,
1524 diagnose ? cling::LookupHelper::WithDiagnostics
1525 : cling::LookupHelper::NoDiagnostics);
1584 while (llvm::isa<clang::PointerType>(
instanceType.getTypePtr())
1585 || llvm::isa<clang::ReferenceType>(
instanceType.getTypePtr()))
1590 const clang::ElaboratedType* etype
1591 = llvm::dyn_cast<clang::ElaboratedType>(
instanceType.getTypePtr());
1593 instanceType = clang::QualType(etype->getNamedType().getTypePtr(),0);
1607 if (
clxx &&
clxx->getTemplateSpecializationKind() != clang::TSK_Undeclared) {
1609 const clang::TemplateSpecializationType*
TST
1610 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instanceType.getTypePtr());
1617 for (
const clang::TemplateArgument &
TA :
TST->template_arguments()) {
1618 if (
TA.getKind() == clang::TemplateArgument::Type) {
1630 const cling::Interpreter &
interp,
1633 const clang::CXXRecordDecl *
clxx = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
1634 if (!
clxx ||
clxx->getTemplateSpecializationKind() == clang::TSK_Undeclared)
return false;
1637 cling::LookupHelper::WithDiagnostics);
1651 clang::AnnotateAttr*
annAttr = clang::dyn_cast<clang::AnnotateAttr>(
attribute);
1694 for (clang::Decl::attr_iterator
attrIt =
decl.attr_begin();
1696 clang::AnnotateAttr*
annAttr = clang::dyn_cast<clang::AnnotateAttr>(*
attrIt);
1700 std::pair<llvm::StringRef,llvm::StringRef> split =
attribute.split(propNames::separator.c_str());
1701 if (split.first !=
propName.c_str())
continue;
1717 for (clang::Decl::attr_iterator
attrIt =
decl.attr_begin();
1719 clang::AnnotateAttr*
annAttr = clang::dyn_cast<clang::AnnotateAttr>(*
attrIt);
1723 std::pair<llvm::StringRef,llvm::StringRef> split =
attribute.split(propNames::separator.c_str());
1724 if (split.first !=
propName.c_str())
continue;
1726 return split.second.getAsInteger(10,
propValue);
1737 const clang::CXXRecordDecl *
decl,
1738 const cling::Interpreter &
interp,
1747 std::string
csymbol = classname;
1761 bool isStd = TMetaUtils::IsStdClass(*
decl);
1762 const cling::LookupHelper&
lh =
interp.getLookupHelper();
1772 <<
" static void " <<
mappedname.c_str() <<
"_TClassManip(TClass*);\n";
1790 finalString <<
" static void delete_" <<
mappedname.c_str() <<
"(void *p);" <<
"\n" <<
" static void deleteArray_" <<
mappedname.c_str() <<
"(void *p);" <<
"\n" <<
" static void destruct_" <<
mappedname.c_str() <<
"(void *p);" <<
"\n";
1793 finalString <<
" static void directoryAutoAdd_" <<
mappedname.c_str() <<
"(void *obj, TDirectory *dir);" <<
"\n";
1796 finalString <<
" static void streamer_" <<
mappedname.c_str() <<
"(TBuffer &buf, void *obj);" <<
"\n";
1799 finalString <<
" static void conv_streamer_" <<
mappedname.c_str() <<
"(TBuffer &buf, void *obj, const TClass*);" <<
"\n";
1802 finalString <<
" static Long64_t merge_" <<
mappedname.c_str() <<
"(void *obj, TCollection *coll,TFileMergeInfo *info);" <<
"\n";
1805 finalString <<
" static void reset_" <<
mappedname.c_str() <<
"(void *obj, TFileMergeInfo *info);" <<
"\n";
1824 finalString <<
"\n // Schema evolution read functions\n";
1843 if(
rIt->find(
"code" ) !=
rIt->
end() ) {
1859 finalString <<
"\n // Schema evolution read raw functions\n";
1886 finalString <<
"\n" <<
" // Function generating the singleton type initializer" <<
"\n";
1888 finalString <<
" static TGenericClassInfo *GenerateInitInstanceLocal(const " <<
csymbol <<
"*)" <<
"\n" <<
" {" <<
"\n";
1894 finalString <<
" static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< " <<
csymbol <<
" >(nullptr);" <<
"\n";
1897 finalString <<
" static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(" <<
csymbol <<
"));" <<
"\n";
1899 finalString <<
" static ::ROOT::TGenericClassInfo " <<
"\n" <<
" instance(\"" << classname.c_str() <<
"\", ";
1912 static const char *
versionFunc =
"GetClassVersion";
1916 std::string
proto = classname +
"*";
1917 const clang::Decl*
ctxt = llvm::dyn_cast<clang::Decl>((*cl).getDeclContext());
1920 interp, cling::LookupHelper::NoDiagnostics);
1939 for (
unsigned int i=0; i<
filename.length(); i++) {
1944 <<
"," <<
"\n" <<
" typeid(" <<
csymbol
1945 <<
"), ::ROOT::Internal::DefineBehavior(ptr, ptr)," <<
"\n" <<
" ";
1968 finalString <<
" instance.SetDelete(&delete_" <<
mappedname.c_str() <<
");" <<
"\n" <<
" instance.SetDeleteArray(&deleteArray_" <<
mappedname.c_str() <<
");" <<
"\n" <<
" instance.SetDestructor(&destruct_" <<
mappedname.c_str() <<
");" <<
"\n";
1971 finalString <<
" instance.SetDirectoryAutoAdd(&directoryAutoAdd_" <<
mappedname.c_str() <<
");" <<
"\n";
1979 finalString <<
" instance.SetConvStreamerFunc(&conv_streamer_" <<
mappedname.c_str() <<
");" <<
"\n";
1988 finalString <<
" instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" <<
"Pushback" <<
"<Internal::TStdBitsetHelper< " << classname.c_str() <<
" > >()));" <<
"\n";
1991 }
else if (
stl != 0 &&
1994 int idx = classname.find(
"<");
2023 finalString <<
" instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" <<
methodTCP <<
"< " <<
classNameForIO.c_str() <<
" >()));" <<
"\n";
2033 finalString <<
"\n" <<
" instance.AdoptAlternate(::ROOT::AddClassAlternate(\""
2040 finalString <<
"\n" <<
" instance.AdoptAlternate(::ROOT::AddClassAlternate(\""
2050 finalString <<
"\n" <<
" ::ROOT::Internal::TSchemaHelper* rule;" <<
"\n";
2054 finalString <<
"\n" <<
" // the io read rules" <<
"\n" <<
" std::vector<::ROOT::Internal::TSchemaHelper> readrules(" <<
rulesIt1->second.size() <<
");" <<
"\n";
2056 finalString <<
" instance.SetReadRules( readrules );" <<
"\n";
2060 finalString <<
"\n" <<
" // the io read raw rules" <<
"\n" <<
" std::vector<::ROOT::Internal::TSchemaHelper> readrawrules(" <<
rulesIt2->second.size() <<
");" <<
"\n";
2062 finalString <<
" instance.SetReadRawRules( readrawrules );" <<
"\n";
2065 finalString <<
" return &instance;" <<
"\n" <<
" }" <<
"\n";
2069 finalString <<
" TGenericClassInfo *GenerateInitInstance(const " <<
csymbol <<
"*)" <<
"\n" <<
" {\n return GenerateInitInstanceLocal(static_cast<" <<
csymbol <<
"*>(nullptr));\n }" <<
"\n";
2072 finalString <<
" // Static variable to force the class initialization" <<
"\n";
2076 finalString <<
" static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal(static_cast<const " <<
csymbol <<
"*>(nullptr)); R__UseDummy(_R__UNIQUE_DICT_(Init));" <<
"\n";
2079 finalString <<
"\n" <<
" // Dictionary for non-ClassDef classes" <<
"\n"
2080 <<
" static TClass *" <<
mappedname <<
"_Dictionary() {\n"
2081 <<
" TClass* theClass ="
2082 <<
"::ROOT::GenerateInitInstanceLocal(static_cast<const " <<
csymbol <<
"*>(nullptr))->GetClass();\n"
2083 <<
" " <<
mappedname <<
"_TClassManip(theClass);\n";
2094 if (
decl->hasAttrs()){
2096 for (clang::Decl::attr_iterator
attrIt =
decl->attr_begin();
2113 manipString+=
" theClass->CreateAttributeMap();\n";
2114 manipString+=
" TDictAttributeMap* attrMap( theClass->GetAttributeMap() );\n";
2125 if (!(!(*internalDeclIt)->isImplicit()
2146 TMetaUtils::Error(
nullptr,
"Cannot convert field declaration to clang::NamedDecl");
2162 if (
attrName == propNames::comment ||
2164 attrName == propNames::ioname )
continue;
2189 finalString <<
"} // end of namespace ROOT" <<
"\n" <<
"\n";
2201 const clang::CXXRecordDecl *cl)
2211 auto ctxt = cl->getEnclosingNamespaceContext();
2216 const clang::NamedDecl *
namedCtxt = llvm::dyn_cast<clang::NamedDecl>(
ctxt);
2218 const clang::NamespaceDecl *
nsdecl = llvm::dyn_cast<clang::NamespaceDecl>(
namedCtxt);
2233 const clang::DeclContext *
ctxt = cl.getDeclContext();
2234 while(
ctxt && !
ctxt->isNamespace()) {
2255 const clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(
ctxt);
2261 out <<
"namespace " << ns->getNameAsString() <<
" {" << std::endl;
2280 clang::TemplateSpecializationKind kind = cl->getTemplateSpecializationKind();
2281 if (kind == clang::TSK_Undeclared ) {
2284 }
else if (kind == clang::TSK_ExplicitSpecialization) {
2299 const char *
proto =
"size_t";
2306 cling::LookupHelper::NoDiagnostics);
2310 cling::LookupHelper::NoDiagnostics);
2312 const clang::DeclContext *
ctxtnew =
nullptr;
2348 const clang::CXXRecordDecl*
clnew = llvm::dyn_cast<clang::CXXRecordDecl>(
ctxtnew);
2395 const clang::CXXRecordDecl *
decl,
2396 const cling::Interpreter &
interp,
2420 classname.insert(0,
"::");
2428 finalString <<
" // Wrappers around operator new" <<
"\n";
2429 finalString <<
" static void *new_" <<
mappedname.c_str() <<
"(void *p) {" <<
"\n" <<
" return p ? ";
2436 finalString <<
"::new(static_cast<::ROOT::Internal::TOperatorNewHelper*>(p)) ";
2441 finalString <<
"new " << classname.c_str() << args <<
";" <<
"\n";
2456 finalString <<
"::new(static_cast<::ROOT::Internal::TOperatorNewHelper*>(p)) ";
2470 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";
2474 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";
2478 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";
2482 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";
2486 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";
2488 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";
2492 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";
2494 finalString <<
"} // end of namespace ROOT for class " << classname.c_str() <<
"\n" <<
"\n";
2501 const cling::Interpreter &
interp,
2512 const clang::CXXRecordDecl *
clxx = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
2516 for(clang::CXXRecordDecl::base_class_const_iterator iter =
clxx->bases_begin(), end =
clxx->bases_end();
2522 Internal::RStl::Instance().GenerateTClassFor( iter->getType(),
interp,
normCtxt);
2527 for(clang::RecordDecl::field_iterator
field_iter =
clxx->field_begin(), end =
clxx->field_end();
2559 const clang::Type *
rawtype =
m.getType()->getCanonicalTypeInternal().getTypePtr();
2575 const clang::CXXRecordDecl*
CRD = llvm::dyn_cast<clang::CXXRecordDecl>(cl);
2587 if (
funcCV == (clang::FunctionDecl*)-1)
return 1;
2602 using res_t = std::pair<bool, int>;
2604 const clang::CompoundStmt*
FuncBody
2605 = llvm::dyn_cast_or_null<clang::CompoundStmt>(
funcCV->getBody());
2607 return res_t{
false, -1};
2612 return res_t{
false, -1};
2614 const clang::ReturnStmt*
RetStmt
2615 = llvm::dyn_cast<clang::ReturnStmt>(
FuncBody->body_back());
2617 return res_t{
false, -1};
2629 return res_t{
false, -1};
2637 return TMetaUtils::IsSTLCont(*
annotated.GetRecordDecl());
2645 clang::QualType
type =
m.getType();
2648 if (
decl)
return TMetaUtils::IsSTLCont(*
decl);
2657 clang::QualType
type = base.getType();
2660 if (
decl)
return TMetaUtils::IsSTLCont(*
decl);
2670 const std::function<
void(
const clang::Module::Header &)> &
closure,
2683 const std::size_t
maxArrayLength = ((
sizeof module.Headers) / (sizeof *module.Headers));
2685 "'Headers' has changed it's size, we need to update publicHeaderIndex");
2690 llvm::SetVector<const clang::Module *>
modules;
2692 for (
size_t i = 0; i <
modules.size(); ++i) {
2693 const clang::Module *M =
modules[i];
2694 for (
const clang::Module *
subModule : M->submodules())
2698 for (
const clang::Module *
m :
modules) {
2700 for (clang::Module *
used :
m->DirectUses) {
2722 static char t[4096];
2723 static const char*
constwd =
"const ";
2732 if (
lev==0 && *s==
'*')
continue;
2738 if (
lev==0 && *s==
' ' && *(s+1)!=
'*') {
p = t;
continue;}
2739 if (
p - t > (
long)
sizeof(t)) {
2740 printf(
"ERROR (rootcling): type name too long for StortTypeName: %s\n",
2753 const cling::Interpreter&
interp)
2758 if (!comment.empty() && comment[0] ==
'!')
2761 clang::QualType
type =
m.getType();
2763 if (
type->isReferenceType()) {
2768 std::string
mTypeName =
type.getAsString(
m.getASTContext().getPrintingPolicy());
2780 const clang::Type *
rawtype =
type.getTypePtr()->getBaseElementTypeUnsafe ();
2782 if (
rawtype->isPointerType()) {
2796 const clang::CXXRecordDecl *
cxxdecl =
rawtype->getAsCXXRecordDecl();
2813 const clang::Type *
rawtype =
m.getType().getTypePtr();
2837 return rawtype->getAsCXXRecordDecl();
2846 const cling::Interpreter &
interp,
2852 const clang::CXXRecordDecl*
decl = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
2854 if (!
decl || !
decl->isCompleteDefinition()) {
2858 std::string fullname;
2872 ROOT::TMetaUtils::Info(
nullptr,
"Class %s: Do not generate Streamer() [*** custom streamer ***]\n",fullname.c_str());
2897 const clang::ASTContext&
Ctx =
interpreter.getCI()->getASTContext();
2903 if (llvm::isa<clang::PointerType>(
instanceType.getTypePtr())) {
2917 if (llvm::isa<clang::ReferenceType>(
instanceType.getTypePtr())) {
2937 clang::NestedNameSpecifier *prefix =
nullptr;
2939 const clang::ElaboratedType* etype
2940 = llvm::dyn_cast<clang::ElaboratedType>(
instanceType.getTypePtr());
2945 instanceType = clang::QualType(etype->getNamedType().getTypePtr(),0);
2951 const clang::TemplateSpecializationType*
TST
2952 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instanceType.getTypePtr());
2954 const clang::ClassTemplateSpecializationDecl*
TSTdecl
2955 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
instanceType.getTypePtr()->getAsCXXRecordDecl());
2971 clang::TemplateDecl *Template =
TSTdecl->getSpecializedTemplate()->getMostRecentDecl();
2972 clang::TemplateParameterList *Params = Template->getTemplateParameters();
2979 llvm::SmallVector<clang::TemplateArgument, 4>
desArgs;
2980 llvm::SmallVector<clang::TemplateArgument, 4>
canonArgs;
2989 if (
I->getKind() == clang::TemplateArgument::Template) {
2996 clang::NamespaceDecl* ns = clang::dyn_cast<clang::NamespaceDecl>(
declCtxt);
2997 clang::NestedNameSpecifier*
nns;
2999 nns = cling::utils::TypeName::CreateNestedNameSpecifier(
Ctx, ns);
3000 }
else if (clang::TagDecl*
TD = llvm::dyn_cast<clang::TagDecl>(
declCtxt)) {
3001 nns = cling::utils::TypeName::CreateNestedNameSpecifier(
Ctx,
TD,
false );
3008 if (clang::UsingShadowDecl *
USD =
templateName.getAsUsingShadowDecl())
3018 if (
I->getKind() != clang::TemplateArgument::Type) {
3023 clang::QualType
SubTy =
I->getAsType();
3045 if (
templateArg.getKind() != clang::TemplateArgument::Type) {
3051 clang::SourceLocation
TemplateLoc = Template->getSourceRange ().getBegin();
3054 clang::TemplateTypeParmDecl *
TTP = llvm::dyn_cast<clang::TemplateTypeParmDecl>(*
Param);
3057 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
3059 clang::TemplateArgumentLoc
ArgType = S.SubstDefaultTemplateArgumentIfAvailable(
3069 if (
ArgType.getArgument().isNull()
3070 ||
ArgType.getArgument().getKind() != clang::TemplateArgument::Type) {
3072 "Template parameter substitution failed for %s around %s\n",
3092 TST->getCanonicalTypeInternal());
3121 llvm::StringRef title;
3124 if (clang::AnnotateAttr *A =
m.getAttr<clang::AnnotateAttr>())
3125 title = A->getAnnotation();
3139 if (title.size() == 0 || (title[0] !=
'['))
return llvm::StringRef();
3141 if (
rightbracket == llvm::StringRef::npos)
return llvm::StringRef();
3160 char *current =
const_cast<char*
>(
working.c_str());
3166 for(i=0;i<
strlen(current);i++) {
3174 return llvm::StringRef();
3179 const clang::CXXRecordDecl *
parent_clxx = llvm::dyn_cast<clang::CXXRecordDecl>(
m.getDeclContext());
3180 const clang::FieldDecl *
index1 =
nullptr;
3193 if (
field_iter->getNameAsString() ==
m.getNameAsString() ) {
3201 return llvm::StringRef();
3213 return llvm::StringRef();
3238 return llvm::StringRef();
3240 if ( found && (
index1->getAccess() == clang::AS_private) ) {
3245 return llvm::StringRef();
3254 return llvm::StringRef();
3275 while((
c = in[i++])) {
3276 const char *
repl =
nullptr;
3278 case '+':
repl =
"pL";
break;
3279 case '-':
repl =
"mI";
break;
3280 case '*':
repl =
"mU";
break;
3281 case '/':
repl =
"dI";
break;
3282 case '&':
repl =
"aN";
break;
3283 case '%':
repl =
"pE";
break;
3284 case '|':
repl =
"oR";
break;
3285 case '^':
repl =
"hA";
break;
3286 case '>':
repl =
"gR";
break;
3287 case '<':
repl =
"lE";
break;
3288 case '=':
repl =
"eQ";
break;
3289 case '~':
repl =
"wA";
break;
3290 case '.':
repl =
"dO";
break;
3291 case '(':
repl =
"oP";
break;
3292 case ')':
repl =
"cP";
break;
3293 case '[':
repl =
"oB";
break;
3294 case ']':
repl =
"cB";
break;
3295 case '{':
repl =
"lB";
break;
3296 case '}':
repl =
"rB";
break;
3297 case ';':
repl =
"sC";
break;
3298 case '#':
repl =
"hS";
break;
3299 case '?':
repl =
"qM";
break;
3300 case '`':
repl =
"bT";
break;
3301 case '!':
repl =
"nO";
break;
3302 case ',':
repl =
"cO";
break;
3303 case '$':
repl =
"dA";
break;
3304 case ' ':
repl =
"sP";
break;
3305 case ':':
repl =
"cL";
break;
3306 case '"':
repl =
"dQ";
break;
3307 case '@':
repl =
"aT";
break;
3308 case '\'':
repl =
"sQ";
break;
3309 case '\':
repl =
"fI";
break;
3318 if (out.empty() ||
isdigit(out[0]))
3319 out.insert(out.begin(),
'_');
3322static clang::SourceLocation
3336 const cling::Interpreter&
interp)
3366 using namespace clang;
3391 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>>(),
3406 assert(
decl.isFirstDecl() &&
"Couldn't trace back include from a decl"
3407 " that is not from an AST file");
3432 clang::OptionalFileEntryRef
FELong;
3434 for (llvm::sys::path::const_iterator
3447 &&
"Mismatched partitioning of file name!");
3451 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>>(),
3463 for (llvm::sys::path::reverse_iterator
3471 &&
"Mismatched partitioning of file name!");
3477 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>>(),
3480 nullptr,
nullptr ) ==
FELong) {
3491 const clang::QualType &
qtype,
3503 const clang::QualType &
qtype,
3509 cling::Interpreter::PushTransactionRAII
RAII(
const_cast<cling::Interpreter*
>(&
interpreter));
3521 clang::ClassTemplateDecl*&
ctd,
3522 clang::ClassTemplateSpecializationDecl*&
ctsd)
3524 using namespace clang;
3532 if (
theType->isPointerType()) {
3537 ctsd = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
rType->getDecl());
3539 ctd =
ctsd->getSpecializedTemplate();
3549 ctsd = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
qt->getAsCXXRecordDecl());
3551 ctd =
ctsd->getSpecializedTemplate();
3566 using namespace clang;
3582 using namespace clang;
3601 const clang::NamedDecl&
tPar,
3602 const cling::Interpreter&
interp,
3606 using namespace clang;
3611 if (!
ttpdPtr->hasDefaultArgument())
return false;
3633 const clang::ElaboratedType* etype
3634 = llvm::dyn_cast<clang::ElaboratedType>(
tParQualType.getTypePtr());
3636 tParQualType = clang::QualType(etype->getNamedType().getTypePtr(),0);
3637 etype = llvm::dyn_cast<clang::ElaboratedType>(
tParQualType.getTypePtr());
3641 llvm::dyn_cast<TemplateSpecializationType>(
tParQualType.getTypePtr());
3647 = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
tArgQualType->getAsCXXRecordDecl());
3665 clang::Sema& S =
interp.getCI()->getSema();
3666 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interp));
3667 llvm::SmallVector<clang::TemplateArgument, 4>
canonArgs;
3680 newArg.getKind() != clang::TemplateArgument::Type) {
3682 "Template parameter substitution failed!");
3686 = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
newArg.getAsType()->getAsCXXRecordDecl());
3702 const clang::NamedDecl&
tPar)
3704 using namespace clang;
3709 if (!
nttpd.hasDefaultArgument())
3720 const int value =
tArg.getAsIntegral().getLimitedValue();
3733 using namespace clang;
3734 if (!
nDecl)
return false;
3736 return ttpd->hasDefaultArgument();
3738 return nttpd->hasDefaultArgument();
3745 const cling::Interpreter&
interp,
3750 const clang::TemplateArgument &
tArg,
3751 const cling::Interpreter&
interp,
3753 const clang::ASTContext&
astCtxt)
3756 using namespace clang;
3763 if (
tArg.getKind() == clang::TemplateArgument::Type) {
3772 }
else if (
normTArg.getKind() == clang::TemplateArgument::Pack) {
3773 assert(
tArg.getKind() == clang::TemplateArgument::Pack );
3801 const cling::Interpreter&
interp,
3805 using namespace clang;
3814 const int nArgsToKeep =
normCtxt.GetNargsToKeep(
ctd);
3824 if (llvm::isa<clang::PointerType>(
normalizedType.getTypePtr())) {
3837 if (llvm::isa<clang::ReferenceType>(
normalizedType.getTypePtr())) {
3856 clang::NestedNameSpecifier* prefix =
nullptr;
3858 const clang::ElaboratedType* etype
3859 = llvm::dyn_cast<clang::ElaboratedType>(
normalizedType.getTypePtr());
3865 normalizedType = clang::QualType(etype->getNamedType().getTypePtr(),0);
3873 clang::TemplateParameterList*
tpl =
rd->getTemplateParameters();
3874 if (
tpl->getMinRequiredArguments () <
tpl->size()) {
3881 Error(
"KeepNParams",
"Not found template default arguments\n");
3898 llvm::dyn_cast<TemplateSpecializationType>(
normalizedType.getTypePtr());
3904 const clang::ClassTemplateSpecializationDecl*
TSTdecl
3905 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
normalizedType.getTypePtr()->getAsCXXRecordDecl());
3913 llvm::SmallVector<TemplateArgument, 4>
argsToKeep;
3925 Error(
"KeepNParams",
"The parameter number %s is null.\n",
formal);
3947 if (
tParPtr->isTemplateParameterPack() ) {
3977 if (
argKind == clang::TemplateArgument::Type){
3980 }
else if (
argKind == clang::TemplateArgument::Integral){
4028 cling::Interpreter::PushTransactionRAII
RAII(
const_cast<cling::Interpreter*
>(&
interpreter));
4051 if (
type.isNull()) {
4059 clang::PrintingPolicy
policy(
ctxt.getPrintingPolicy());
4060 policy.SuppressTagKeyword =
true;
4061 policy.SuppressScope =
true;
4062 policy.AnonymousTagLocations =
false;
4070 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
4095 clang::ASTContext&
astCtxt =
sema.getASTContext();
4105std::pair<std::string,clang::QualType>
4126 cling::LookupHelper::DiagSetting::NoDiagnostics,
4145 "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());
4173 llvm::errs() << llvm::StringRef(
commentStart, 80) <<
'\n';
4222 if (
const clang::FunctionDecl*
FD = clang::dyn_cast<clang::FunctionDecl>(&
decl)) {
4223 if (
FD->isImplicit()) {
4227 if (
FD->isExplicitlyDefaulted() ||
FD->isDeletedAsWritten()) {
4231 }
else if (
FD->doesThisDeclarationHaveABody()) {
4236 &&
"Expected macro or end of body at '}'");
4248 }
else if (
const clang::EnumConstantDecl*
ECD
4249 = clang::dyn_cast<clang::EnumConstantDecl>(&
decl)) {
4251 if (
ECD->getNextDeclInContext())
4328 if (!
decl)
return false;
4335 static const std::vector<std::string>
signatures =
4336 {
"ClassDef",
"ClassDefOverride",
"ClassDefNV",
"ClassDefInline",
"ClassDefInlineOverride",
"ClassDefInlineNV" };
4353 clang::SourceLocation *
loc,
4356 using namespace clang;
4359 =
interpreter.getLookupHelper().findFunctionProto(&
decl,
"DeclFileLine",
"",
4360 cling::LookupHelper::NoDiagnostics);
4366 if (comment.size()) {
4373 return llvm::StringRef();
4385 if (
rawtype->isElaboratedTypeSpecifier() ) {
4389 rawtype =
type.getTypePtr()->getBaseElementTypeUnsafe ();
4398 if (
rawtype->isElaboratedTypeSpecifier() ) {
4418 if (
ctxt.isNamespace() ||
ctxt.isTranslationUnit())
4420 else if(
const auto parentdecl = llvm::dyn_cast<clang::CXXRecordDecl>(&
ctxt))
4433 const clang::DeclContext *
ctxt =
decl.getDeclContext();
4434 switch (
decl.getAccess()) {
4435 case clang::AS_public:
4437 case clang::AS_protected:
4439 case clang::AS_private:
4441 case clang::AS_none:
4445 assert(
false &&
"Unexpected value for the access property value in Clang");
4455 return cling::utils::Analyze::IsStdClass(cl);
4465 if (cling::utils::Analyze::IsStdClass(cl)) {
4466 static const char *names[] =
4467 {
"shared_ptr",
"__shared_ptr",
4468 "vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset"};
4469 llvm::StringRef
clname(cl.getName());
4470 for(
auto &&
name : names) {
4508 const clang::CXXRecordDecl *
thisDecl =
4509 llvm::dyn_cast_or_null<clang::CXXRecordDecl>(
lh.findScope(
typ, cling::LookupHelper::WithDiagnostics));
4513 Error(
"IsOfType",
"Record decl of type %s not found in the AST.",
typ.c_str());
4543 if (!IsStdClass(cl)) {
4544 auto *
nsDecl = llvm::dyn_cast<clang::NamespaceDecl>(cl.getDeclContext());
4545 if (cl.getName() !=
"RVec" ||
nsDecl ==
nullptr ||
nsDecl->getName() !=
"VecOps")
4548 auto *
parentNsDecl = llvm::dyn_cast<clang::NamespaceDecl>(cl.getDeclContext()->getParent());
4553 return STLKind(cl.getName());
4557 using namespace clang;
4558 struct SearchTypedef:
public TypeVisitor<SearchTypedef, bool> {
4563 return Visit(
AT->getElementType().getTypePtr());
4566 return Visit(
DT->getUnderlyingType().getTypePtr());
4569 return Visit(
PT->getPointeeType().getTypePtr());
4572 return Visit(
RT->getPointeeType().getTypePtr());
4575 return Visit(
STST->getReplacementType().getTypePtr());
4579 if (
TA.getKind() == TemplateArgument::Type && Visit(
TA.getAsType().getTypePtr()))
4588 return TOT->getUnmodifiedType().getTypePtr();
4593 if (
NNS->getKind() == NestedNameSpecifier::TypeSpec) {
4594 if (Visit(
NNS->getAsType()))
4599 return Visit(
ET->getNamedType().getTypePtr());
4620 using namespace llvm;
4621 using namespace clang;
4622 const clang::ASTContext &
Ctxt =
instance->getAsCXXRecordDecl()->getASTContext();
4625 const clang::ElaboratedType* etype
4626 = llvm::dyn_cast<clang::ElaboratedType>(
input.getTypePtr());
4631 assert(
instance->getAsCXXRecordDecl() !=
nullptr &&
"ReSubstTemplateArg only makes sense with a type representing a class.");
4651 if (
nQT ==
QT->getPointeeType())
return QT;
4667 if (
nQT ==
QT->getPointeeType())
return QT;
4688 if (
newQT ==
arr->getElementType())
return QT;
4692 arr->getSizeModifier(),
4693 arr->getIndexTypeCVRQualifiers());
4701 arr->getSizeModifier(),
4702 arr->getIndexTypeCVRQualifiers(),
4703 arr->getBracketsRange());
4708 if (
newQT ==
arr->getElementType())
return QT;
4710 arr->getSizeModifier(),
4711 arr->getIndexTypeCVRQualifiers());
4716 if (
newQT ==
arr->getElementType())
return QT;
4719 arr->getSizeModifier(),
4720 arr->getIndexTypeCVRQualifiers(),
4721 arr->getBracketsRange());
4730 etype = llvm::dyn_cast<clang::ElaboratedType>(
instance);
4732 instance = etype->getNamedType().getTypePtr();
4736 const clang::TemplateSpecializationType*
TST
4737 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instance);
4741 const clang::ClassTemplateSpecializationDecl*
TSTdecl
4742 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
instance->getAsCXXRecordDecl());
4746 const clang::SubstTemplateTypeParmType *
substType
4747 = llvm::dyn_cast<clang::SubstTemplateTypeParmType>(
input.getTypePtr());
4751 const clang::ClassTemplateDecl *
replacedCtxt =
nullptr;
4755 unsigned int index =
substType->getReplacedParameter()->getIndex();
4758 if (
decl->getKind() == clang::Decl::ClassTemplatePartialSpecialization) {
4759 const clang::ClassTemplatePartialSpecializationDecl *
spec = llvm::dyn_cast<clang::ClassTemplatePartialSpecializationDecl>(
decl);
4761 unsigned int depth =
substType->getReplacedParameter()->getDepth();
4777 const clang::SubstTemplateTypeParmType *
argType
4778 = llvm::dyn_cast<clang::SubstTemplateTypeParmType>(
argQualType);
4803 llvm::raw_string_ostream ostream(
astDump);
4806 ROOT::TMetaUtils::Warning(
"ReSubstTemplateArg",
"Unexpected type of declaration context for template parameter: %s.\n\tThe responsible class is:\n\t%s\n",
4814 ==
TSTdecl->getSpecializedTemplate ()->getTemplateParameters()->getParam(
index))
4816 const auto &
TAs =
TST->template_arguments();
4833 const clang::TemplateSpecializationType*
inputTST
4834 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
input.getTypePtr());
4839 llvm::SmallVector<clang::TemplateArgument, 4>
desArgs;
4840 for (
const clang::TemplateArgument &
TA :
inputTST->template_arguments()) {
4841 if (
TA.getKind() != clang::TemplateArgument::Type) {
4846 clang::QualType
SubTy =
TA.getAsType();
4848 if (llvm::isa<clang::ElaboratedType>(
SubTy)
4849 || llvm::isa<clang::SubstTemplateTypeParmType>(
SubTy)
4850 || llvm::isa<clang::TemplateSpecializationType>(
SubTy)) {
4865 inputTST->getCanonicalTypeInternal());
4906 static const char *
stls[] =
4907 {
"any",
"vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset",
4908 "forward_list",
"unordered_set",
"unordered_multiset",
"unordered_map",
"unordered_multimap",
"RVec",
nullptr};
4922 for(
int k=1;
stls[k];k++) {
if (
type.equals(
stls[k]))
return values[k];}
4933 TND =
TND->getMostRecentDecl();
4934 while (
TND && !(
TND->hasAttrs()))
4935 TND =
TND->getPreviousDecl();
4947 TD =
TD->getMostRecentDecl();
4948 while (
TD && !(
TD->hasAttrs() &&
TD->isThisDeclarationADefinition()))
4949 TD =
TD->getPreviousDecl();
5005 std::list<std::pair<std::string,unsigned int> >&
enclosingSc)
5033 std::string::size_type
beginVar = 0;
5034 std::string::size_type
endVar = 0;
5038 std::string::size_type
endVarName = std::string::npos;
5108 str.replace(
start_pos, from.length(), to);
5175 return llvm::sys::path::extension(
filename) ==
".h" ||
5176 llvm::sys::path::extension(
filename) ==
".hh" ||
5177 llvm::sys::path::extension(
filename) ==
".hpp" ||
5178 llvm::sys::path::extension(
filename) ==
".H" ||
5179 llvm::sys::path::extension(
filename) ==
".h++" ||
5180 llvm::sys::path::extension(
filename) ==
"hxx" ||
5181 llvm::sys::path::extension(
filename) ==
"Hxx" ||
5182 llvm::sys::path::extension(
filename) ==
"HXX";
5188 cling::Interpreter::IgnoreFilesFunc_t
ignoreFiles,
5189 const cling::Interpreter &
interp,
5197 clang::Decl *
ncDecl =
const_cast<clang::Decl *
>(
decl);
5242 static const std::string
scopeType [] = {
"namespace ",
"inline namespace ",
"class "};
5284 std::string typeName;
5287 if (llvm::isa<clang::TemplateTypeParmDecl>(
nDecl)){
5288 typeName =
"typename ";
5289 if (
nDecl->isParameterPack())
5291 typeName += (*prmIt)->getNameAsString();
5294 else if (
auto nttpd = llvm::dyn_cast<clang::NonTypeTemplateParmDecl>(
nDecl)){
5298 if (
theType.getAsString().find(
"enum") != std::string::npos){
5300 llvm::raw_string_ostream ostream(
astDump);
5301 nttpd->dump(ostream);
5312 else if (
auto ttpd = llvm::dyn_cast<clang::TemplateTemplateParmDecl>(
nDecl)){
5316 llvm::raw_string_ostream ostream(
astDump);
5317 ttpd->dump(ostream);
5342 "Cannot extract template parameter list for %s",
5350 "Problems with arguments for forward declaration of class %s\n",
5360 if (llvm::isa<clang::TemplateTemplateParmDecl>(&
templDecl)) {
5382 if (clang::TemplateArgument::Type != arg.getKind())
return 0;
5397 if (llvm::isa<clang::BuiltinType>(
argTypePtr)){
5430 if (
specDef->getTemplateSpecializationKind() != clang::TSK_ExplicitSpecialization)
5434 std::cout <<
" Forward declaring template spec " <<
normalizedName <<
":\n";
5439 std::cout <<
" o Template argument ";
5441 std::cout <<
"successfully treated. Arg fwd decl: " <<
argFwdDecl << std::endl;
5443 std::cout <<
"could not be treated. Abort fwd declaration generation.\n";
5484 std::cout <<
"Class " <<
recordDecl.getNameAsString()
5485 <<
" is a template specialisation. Treating its arguments.\n";
5489 std::cout <<
" o Template argument ";
5491 std::cout <<
"successfully treated. Arg fwd decl: " <<
argFwdDecl << std::endl;
5493 std::cout <<
"could not be treated. Abort fwd declaration generation.\n";
5541 std::string buffer =
tdnDecl.getNameAsString();
5544 if (
const clang::TagType* TT
5546 if (clang::NamedDecl*
ND = TT->getDecl()) {
5547 if (!
ND->getIdentifier()) {
5591 std::cout <<
"Typedef " <<
tdnDecl.getNameAsString() <<
" hides a class: "
5618 const clang::PrintingPolicy&
ppolicy)
5621 auto&
ctxt = par.getASTContext();
5642 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 .