24#include <unordered_set>
26#include "RConfigure.h"
34#include "clang/AST/ASTContext.h"
35#include "clang/AST/Attr.h"
36#include "clang/AST/CXXInheritance.h"
37#include "clang/AST/Decl.h"
38#include "clang/AST/DeclTemplate.h"
39#include "clang/AST/Mangle.h"
40#include "clang/AST/Type.h"
41#include "clang/AST/TypeVisitor.h"
42#include "clang/Frontend/CompilerInstance.h"
43#include "clang/Lex/HeaderSearch.h"
44#include "clang/Lex/ModuleMap.h"
45#include "clang/Lex/Preprocessor.h"
46#include "clang/Lex/PreprocessorOptions.h"
48#include "clang/Sema/Lookup.h"
49#include "clang/Sema/Sema.h"
50#include "clang/Sema/SemaDiagnostic.h"
52#include "cling/Interpreter/LookupHelper.h"
53#include "cling/Interpreter/Transaction.h"
54#include "cling/Interpreter/Interpreter.h"
55#include "cling/Utils/AST.h"
56#include "cling/Interpreter/InterpreterAccessRAII.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",
379 const clang::RecordDecl *
decl,
399 const clang::RecordDecl *
decl,
419 "Could not remove the requested template arguments.\n");
429 const clang::RecordDecl *
decl,
453 const clang::RecordDecl *
decl,
505 if (
tname.empty())
return false;
519 if (!
dest.isNull() && (
dest != t)) {
539 if (!
dest.isNull() && (
dest != t) &&
561 const clang::NamespaceDecl *
nsdecl = llvm::dyn_cast<clang::NamespaceDecl>(
scope);
574 if (
tname.empty())
return false;
606 clang::PrintingPolicy
policy(
fInterpreter->getCI()->getASTContext().getPrintingPolicy());
607 policy.SuppressTagKeyword =
true;
608 policy.SuppressScope =
true;
623 for(
unsigned int i = 1; i<
result.length(); ++i) {
635 }
else if ( (i+1) <
result.length() &&
673 clang::QualType
toSkip =
lh.findType(
name, cling::LookupHelper::WithDiagnostics);
674 if (
const clang::Type* T =
toSkip.getTypePtr()) {
675 const clang::TypedefType *
tt = llvm::dyn_cast<clang::TypedefType>(T);
677 clang::Decl* D =
tt->getDecl();
678 fConfig.m_toSkip.insert(D);
680 clang::QualType
canon =
toSkip->getCanonicalTypeInternal();
681 fConfig.m_toReplace.insert(std::make_pair(
canon.getTypePtr(),T));
683 fTypeWithAlternative.insert(T);
696 keepTypedef(
lh,
"Double32_t");
697 keepTypedef(
lh,
"Float16_t");
698 keepTypedef(
lh,
"Long64_t",
true);
699 keepTypedef(
lh,
"ULong64_t",
true);
701 clang::QualType
toSkip =
lh.findType(
"string", cling::LookupHelper::WithDiagnostics);
703 if (
const clang::TypedefType* TT
704 = llvm::dyn_cast_or_null<clang::TypedefType>(
toSkip.getTypePtr()))
705 fConfig.m_toSkip.insert(TT->getDecl());
707 toSkip =
lh.findType(
"std::string", cling::LookupHelper::WithDiagnostics);
709 if (
const clang::TypedefType* TT
710 = llvm::dyn_cast_or_null<clang::TypedefType>(
toSkip.getTypePtr()))
711 fConfig.m_toSkip.insert(TT->getDecl());
713 clang::QualType
canon =
toSkip->getCanonicalTypeInternal();
714 fConfig.m_toReplace.insert(std::make_pair(
canon.getTypePtr(),
toSkip.getTypePtr()));
725 return (cl.getKind() == clang::Decl::ClassTemplatePartialSpecialization
726 || cl.getKind() == clang::Decl::ClassTemplateSpecialization);
733 const cling::Interpreter&
interp)
735 clang::Sema* S = &
interp.getSema();
736 const clang::NamedDecl*
ND = cling::utils::Lookup::Named(S,
name, cl);
737 if (
ND == (clang::NamedDecl*)-1)
738 return (clang::FunctionDecl*)-1;
739 return llvm::dyn_cast_or_null<clang::FunctionDecl>(
ND);
745const clang::CXXRecordDecl *
749 const cling::LookupHelper&
lh =
interp.getLookupHelper();
752 const clang::CXXRecordDecl *
result
753 = llvm::dyn_cast_or_null<clang::CXXRecordDecl>
760 result = llvm::dyn_cast_or_null<clang::CXXRecordDecl>
771 clang::QualType
qType(cl->getTypeForDecl(),0);
779 clang::Sema& S =
interp.getCI()->getSema();
782 cling::Interpreter::PushTransactionRAII
RAII(
const_cast<cling::Interpreter*
>(&
interp));
783 return S.RequireCompleteType(
Loc, Type, clang::diag::err_incomplete_type);
789 const clang::CXXRecordDecl *context,
const cling::Interpreter &
interp)
795 if (!cl->getDefinition() || !cl->isCompleteDefinition()) {
803 if (!base->hasDefinition()) {
807 return cl->isDerivedFrom(base);
819 const clang::NamedDecl *base
823 return IsBase(
CRD, llvm::dyn_cast<clang::CXXRecordDecl>( base ),
824 llvm::dyn_cast<clang::CXXRecordDecl>(
m.getDeclContext()),
interp);
833 const clang::QualType &
qti,
835 const cling::Interpreter &
interp,
843 kBIT_ISSTRING = 0x40000000,
850 const clang::Type &
ti( *
qti.getTypePtr() );
873 if (
tiName ==
"string")
kase |= kBIT_ISSTRING;
874 if (
tiName ==
"string*")
kase |= kBIT_ISSTRING;
878 tcl =
" internal error in rootcling ";
903 <<
" R__b >> readtemp;" << std::endl
904 <<
" " <<
R__t <<
" = static_cast<" <<
tiName <<
">(readtemp);" << std::endl;
916 finalString <<
" if (R__b.GetInfo() && R__b.GetInfo()->GetOldVersion()<=3) {" << std::endl;
918 finalString <<
" R__ASSERT(0);// " <<
objType <<
" is abstract. We assume that older file could not be produced using this streaming method." << std::endl;
921 <<
" " <<
R__t <<
"->Streamer(R__b);" << std::endl;
924 <<
" " <<
R__t <<
" = (" <<
tiName <<
")R__b.ReadObjectAny(" <<
tcl <<
");" << std::endl
925 <<
" }" << std::endl;
931 <<
" R__str.Streamer(R__b);" << std::endl
932 <<
" " <<
R__t <<
" = R__str.Data();}" << std::endl;
938 <<
" R__str.Streamer(R__b);" << std::endl
939 <<
" " <<
R__t <<
" = new string(R__str.Data());}" << std::endl;
966 finalString <<
" R__b >> *reinterpret_cast<Int_t*>(ptr_enum); }" << std::endl;
982 finalString <<
" {TString R__str(" <<
R__t <<
".c_str());" << std::endl
983 <<
" R__str.Streamer(R__b);};" << std::endl;
988 finalString <<
" {TString R__str(" <<
R__t <<
"->c_str());" << std::endl
989 <<
" R__str.Streamer(R__b);}" << std::endl;
1011 clang::CXXRecordDecl*
ncCl =
const_cast<clang::CXXRecordDecl*
>(cl);
1014 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
1017 if (
Ctor->getAccess() == clang::AS_public && !
Ctor->isDeleted()) {
1035 const cling::LookupHelper&
lh =
interpreter.getLookupHelper();
1044 return EIOCtorCategory::kAbsent;
1047 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
1048 for (
auto iter = cl->ctor_begin(), end = cl->ctor_end(); iter != end; ++iter)
1050 if ((iter->getAccess() != clang::AS_public) || (iter->getNumParams() != 1))
1054 clang::QualType
argType((*iter->param_begin())->getType());
1058 if (
argType->isPointerType()) {
1061 }
else if (
argType->isReferenceType()) {
1068 const clang::CXXRecordDecl *
argDecl =
argType->getAsCXXRecordDecl();
1075 std::string
clarg(
"class ");
1082 return EIOCtorCategory::kAbsent;
1095 if (!
ioctortype.GetType() && (!arg || !arg[0])) {
1109 const cling::Interpreter &
interp,
1112 const clang::FunctionDecl*
funcD
1114 diagnose ? cling::LookupHelper::WithDiagnostics
1115 : cling::LookupHelper::NoDiagnostics);
1117 return llvm::dyn_cast<const clang::CXXMethodDecl>(
funcD);
1126 namespace TMetaUtils {
1129 const cling::LookupHelper&
lh =
interp.getLookupHelper();
1148 const cling::Interpreter &
interp)
1150 if (cl->isAbstract())
return false;
1156 if (EIOCtorCategory::kAbsent ==
ioCtorCat)
1166 if (EIOCtorCategory::kIOPtrType ==
ioCtorCat) {
1168 }
else if (EIOCtorCategory::kIORefType ==
ioCtorCat) {
1172 arg +=
")nullptr )";
1175 const clang::CXXMethodDecl *
method
1177 cling::LookupHelper::NoDiagnostics);
1178 if (
method &&
method->getAccess() != clang::AS_public) {
1192 const cling::Interpreter&
interp)
1194 if (!cl)
return false;
1196 if (cl->hasUserDeclaredDestructor()) {
1198 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interp));
1199 clang::CXXDestructorDecl *
dest = cl->getDestructor();
1201 return (
dest->getAccess() == clang::AS_public);
1215 const cling::Interpreter &
interp,
1218 const clang::CXXMethodDecl *
method
1220 diagnose ? cling::LookupHelper::WithDiagnostics
1221 : cling::LookupHelper::NoDiagnostics);
1222 return (
method &&
method->getAccess() == clang::AS_public);
1233 const char *
proto =
"TDirectory*";
1234 const char *
name =
"DirectoryAutoAdd";
1248 const char *
proto =
"TCollection*,TFileMergeInfo*";
1249 const char *
name =
"Merge";
1262 const char *
proto =
"TCollection*";
1263 const char *
name =
"Merge";
1278 const char *
proto =
"TFileMergeInfo*";
1279 const char *
name =
"ResetAfterMerge";
1289 const clang::CXXRecordDecl*
clxx,
1290 const cling::Interpreter &
interp,
1293 static const char *
proto =
"TBuffer&";
1295 const clang::CXXMethodDecl *
method
1297 cling::LookupHelper::NoDiagnostics);
1308 const clang::CXXRecordDecl*
clxx,
1309 const cling::Interpreter &
interp,
1312 static const char *
proto =
"TBuffer&,TClass*";
1314 const clang::CXXMethodDecl *
method
1316 cling::LookupHelper::NoDiagnostics);
1381 llvm::raw_string_ostream stream(
qual_name);
1382 clang::PrintingPolicy
policy( cl.getASTContext().getPrintingPolicy() );
1383 policy.SuppressTagKeyword =
true;
1384 policy.SuppressUnwrittenScope =
true;
1386 cl.getNameForDiagnostic(stream,
policy,
true);
1442 std::stringstream
dims;
1445 const clang::ASTContext&
astContext = cl.getASTContext();
1448 for(clang::RecordDecl::field_iterator
field_iter = cl.field_begin(), end = cl.field_end();
1462 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
fieldType.getTypePtr());
1464 dims <<
"[" <<
arrayType->getSize().getLimitedValue() <<
"]";
1466 arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual());
1476 for(clang::CXXRecordDecl::base_class_const_iterator iter = cl.bases_begin(), end = cl.bases_end();
1479 std::string
basename( iter->getType()->getAsCXXRecordDecl()->getNameAsString() );
1489 const cling::Interpreter &
interp,
1493 diagnose ? cling::LookupHelper::WithDiagnostics
1494 : cling::LookupHelper::NoDiagnostics);
1553 while (llvm::isa<clang::PointerType>(
instanceType.getTypePtr())
1554 || llvm::isa<clang::ReferenceType>(
instanceType.getTypePtr()))
1559 const clang::ElaboratedType* etype
1560 = llvm::dyn_cast<clang::ElaboratedType>(
instanceType.getTypePtr());
1562 instanceType = clang::QualType(etype->getNamedType().getTypePtr(),0);
1576 if (
clxx &&
clxx->getTemplateSpecializationKind() != clang::TSK_Undeclared) {
1578 const clang::TemplateSpecializationType*
TST
1579 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instanceType.getTypePtr());
1586 for (
const clang::TemplateArgument &
TA :
TST->template_arguments()) {
1587 if (
TA.getKind() == clang::TemplateArgument::Type) {
1599 const cling::Interpreter &
interp,
1602 const clang::CXXRecordDecl *
clxx = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
1603 if (!
clxx ||
clxx->getTemplateSpecializationKind() == clang::TSK_Undeclared)
return false;
1606 cling::LookupHelper::WithDiagnostics);
1620 clang::AnnotateAttr*
annAttr = clang::dyn_cast<clang::AnnotateAttr>(
attribute);
1663 for (clang::Decl::attr_iterator
attrIt =
decl.attr_begin();
1665 clang::AnnotateAttr*
annAttr = clang::dyn_cast<clang::AnnotateAttr>(*
attrIt);
1669 std::pair<llvm::StringRef,llvm::StringRef> split =
attribute.split(propNames::separator.c_str());
1670 if (split.first !=
propName.c_str())
continue;
1686 for (clang::Decl::attr_iterator
attrIt =
decl.attr_begin();
1688 clang::AnnotateAttr*
annAttr = clang::dyn_cast<clang::AnnotateAttr>(*
attrIt);
1692 std::pair<llvm::StringRef,llvm::StringRef> split =
attribute.split(propNames::separator.c_str());
1693 if (split.first !=
propName.c_str())
continue;
1695 return split.second.getAsInteger(10,
propValue);
1706 const clang::CXXRecordDecl *
decl,
1707 const cling::Interpreter &
interp,
1716 std::string
csymbol = classname;
1730 bool isStd = TMetaUtils::IsStdClass(*
decl);
1731 const cling::LookupHelper&
lh =
interp.getLookupHelper();
1741 <<
" static void " <<
mappedname.c_str() <<
"_TClassManip(TClass*);\n";
1759 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";
1762 finalString <<
" static void directoryAutoAdd_" <<
mappedname.c_str() <<
"(void *obj, TDirectory *dir);" <<
"\n";
1765 finalString <<
" static void streamer_" <<
mappedname.c_str() <<
"(TBuffer &buf, void *obj);" <<
"\n";
1768 finalString <<
" static void conv_streamer_" <<
mappedname.c_str() <<
"(TBuffer &buf, void *obj, const TClass*);" <<
"\n";
1771 finalString <<
" static Long64_t merge_" <<
mappedname.c_str() <<
"(void *obj, TCollection *coll,TFileMergeInfo *info);" <<
"\n";
1774 finalString <<
" static void reset_" <<
mappedname.c_str() <<
"(void *obj, TFileMergeInfo *info);" <<
"\n";
1793 finalString <<
"\n // Schema evolution read functions\n";
1812 if(
rIt->find(
"code" ) !=
rIt->
end() ) {
1828 finalString <<
"\n // Schema evolution read raw functions\n";
1855 finalString <<
"\n" <<
" // Function generating the singleton type initializer" <<
"\n";
1857 finalString <<
" static TGenericClassInfo *GenerateInitInstanceLocal(const " <<
csymbol <<
"*)" <<
"\n" <<
" {" <<
"\n";
1863 finalString <<
" static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< " <<
csymbol <<
" >(nullptr);" <<
"\n";
1866 finalString <<
" static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(" <<
csymbol <<
"));" <<
"\n";
1868 finalString <<
" static ::ROOT::TGenericClassInfo " <<
"\n" <<
" instance(\"" << classname.c_str() <<
"\", ";
1881 static const char *
versionFunc =
"GetClassVersion";
1885 std::string
proto = classname +
"*";
1886 const clang::Decl*
ctxt = llvm::dyn_cast<clang::Decl>((*cl).getDeclContext());
1889 interp, cling::LookupHelper::NoDiagnostics);
1908 for (
unsigned int i=0; i<
filename.length(); i++) {
1913 <<
"," <<
"\n" <<
" typeid(" <<
csymbol
1914 <<
"), ::ROOT::Internal::DefineBehavior(ptr, ptr)," <<
"\n" <<
" ";
1937 finalString <<
" instance.SetDelete(&delete_" <<
mappedname.c_str() <<
");" <<
"\n" <<
" instance.SetDeleteArray(&deleteArray_" <<
mappedname.c_str() <<
");" <<
"\n" <<
" instance.SetDestructor(&destruct_" <<
mappedname.c_str() <<
");" <<
"\n";
1940 finalString <<
" instance.SetDirectoryAutoAdd(&directoryAutoAdd_" <<
mappedname.c_str() <<
");" <<
"\n";
1948 finalString <<
" instance.SetConvStreamerFunc(&conv_streamer_" <<
mappedname.c_str() <<
");" <<
"\n";
1957 finalString <<
" instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" <<
"Pushback" <<
"<Internal::TStdBitsetHelper< " << classname.c_str() <<
" > >()));" <<
"\n";
1960 }
else if (
stl != 0 &&
1963 int idx = classname.find(
"<");
1992 finalString <<
" instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" <<
methodTCP <<
"< " <<
classNameForIO.c_str() <<
" >()));" <<
"\n";
2002 finalString <<
"\n" <<
" instance.AdoptAlternate(::ROOT::AddClassAlternate(\""
2009 finalString <<
"\n" <<
" instance.AdoptAlternate(::ROOT::AddClassAlternate(\""
2019 finalString <<
"\n" <<
" ::ROOT::Internal::TSchemaHelper* rule;" <<
"\n";
2023 finalString <<
"\n" <<
" // the io read rules" <<
"\n" <<
" std::vector<::ROOT::Internal::TSchemaHelper> readrules(" <<
rulesIt1->second.size() <<
");" <<
"\n";
2025 finalString <<
" instance.SetReadRules( readrules );" <<
"\n";
2029 finalString <<
"\n" <<
" // the io read raw rules" <<
"\n" <<
" std::vector<::ROOT::Internal::TSchemaHelper> readrawrules(" <<
rulesIt2->second.size() <<
");" <<
"\n";
2031 finalString <<
" instance.SetReadRawRules( readrawrules );" <<
"\n";
2034 finalString <<
" return &instance;" <<
"\n" <<
" }" <<
"\n";
2038 finalString <<
" TGenericClassInfo *GenerateInitInstance(const " <<
csymbol <<
"*)" <<
"\n" <<
" {\n return GenerateInitInstanceLocal(static_cast<" <<
csymbol <<
"*>(nullptr));\n }" <<
"\n";
2041 finalString <<
" // Static variable to force the class initialization" <<
"\n";
2045 finalString <<
" static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal(static_cast<const " <<
csymbol <<
"*>(nullptr)); R__UseDummy(_R__UNIQUE_DICT_(Init));" <<
"\n";
2048 finalString <<
"\n" <<
" // Dictionary for non-ClassDef classes" <<
"\n"
2049 <<
" static TClass *" <<
mappedname <<
"_Dictionary() {\n"
2050 <<
" TClass* theClass ="
2051 <<
"::ROOT::GenerateInitInstanceLocal(static_cast<const " <<
csymbol <<
"*>(nullptr))->GetClass();\n"
2052 <<
" " <<
mappedname <<
"_TClassManip(theClass);\n";
2063 if (
decl->hasAttrs()){
2065 for (clang::Decl::attr_iterator
attrIt =
decl->attr_begin();
2082 manipString+=
" theClass->CreateAttributeMap();\n";
2083 manipString+=
" TDictAttributeMap* attrMap( theClass->GetAttributeMap() );\n";
2094 if (!(!(*internalDeclIt)->isImplicit()
2115 TMetaUtils::Error(
nullptr,
"Cannot convert field declaration to clang::NamedDecl");
2131 if (
attrName == propNames::comment ||
2133 attrName == propNames::ioname )
continue;
2158 finalString <<
"} // end of namespace ROOT" <<
"\n" <<
"\n";
2170 const clang::CXXRecordDecl *cl)
2180 auto ctxt = cl->getEnclosingNamespaceContext();
2185 const clang::NamedDecl *
namedCtxt = llvm::dyn_cast<clang::NamedDecl>(
ctxt);
2187 const clang::NamespaceDecl *
nsdecl = llvm::dyn_cast<clang::NamespaceDecl>(
namedCtxt);
2202 const clang::DeclContext *
ctxt = cl.getDeclContext();
2203 while(
ctxt && !
ctxt->isNamespace()) {
2224 const clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(
ctxt);
2230 out <<
"namespace " << ns->getNameAsString() <<
" {" << std::endl;
2249 clang::TemplateSpecializationKind kind = cl->getTemplateSpecializationKind();
2250 if (kind == clang::TSK_Undeclared ) {
2253 }
else if (kind == clang::TSK_ExplicitSpecialization) {
2268 const char *
proto =
"size_t";
2275 cling::LookupHelper::NoDiagnostics);
2279 cling::LookupHelper::NoDiagnostics);
2281 const clang::DeclContext *
ctxtnew =
nullptr;
2317 const clang::CXXRecordDecl*
clnew = llvm::dyn_cast<clang::CXXRecordDecl>(
ctxtnew);
2364 const clang::CXXRecordDecl *
decl,
2365 const cling::Interpreter &
interp,
2389 classname.insert(0,
"::");
2397 finalString <<
" // Wrappers around operator new" <<
"\n";
2398 finalString <<
" static void *new_" <<
mappedname.c_str() <<
"(void *p) {" <<
"\n" <<
" return p ? ";
2405 finalString <<
"::new(static_cast<::ROOT::Internal::TOperatorNewHelper*>(p)) ";
2410 finalString <<
"new " << classname.c_str() << args <<
";" <<
"\n";
2425 finalString <<
"::new(static_cast<::ROOT::Internal::TOperatorNewHelper*>(p)) ";
2439 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";
2443 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";
2447 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";
2451 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";
2455 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";
2457 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";
2461 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";
2463 finalString <<
"} // end of namespace ROOT for class " << classname.c_str() <<
"\n" <<
"\n";
2470 const cling::Interpreter &
interp,
2481 const clang::CXXRecordDecl *
clxx = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
2485 for(clang::CXXRecordDecl::base_class_const_iterator iter =
clxx->bases_begin(), end =
clxx->bases_end();
2491 Internal::RStl::Instance().GenerateTClassFor( iter->getType(),
interp,
normCtxt);
2496 for(clang::RecordDecl::field_iterator
field_iter =
clxx->field_begin(), end =
clxx->field_end();
2528 const clang::Type *
rawtype =
m.getType()->getCanonicalTypeInternal().getTypePtr();
2544 const clang::CXXRecordDecl*
CRD = llvm::dyn_cast<clang::CXXRecordDecl>(cl);
2556 if (
funcCV == (clang::FunctionDecl*)-1)
return 1;
2571 using res_t = std::pair<bool, int>;
2573 const clang::CompoundStmt*
FuncBody
2574 = llvm::dyn_cast_or_null<clang::CompoundStmt>(
funcCV->getBody());
2576 return res_t{
false, -1};
2581 return res_t{
false, -1};
2583 const clang::ReturnStmt*
RetStmt
2584 = llvm::dyn_cast<clang::ReturnStmt>(
FuncBody->body_back());
2586 return res_t{
false, -1};
2598 return res_t{
false, -1};
2606 return TMetaUtils::IsSTLCont(*
annotated.GetRecordDecl());
2614 clang::QualType
type =
m.getType();
2617 if (
decl)
return TMetaUtils::IsSTLCont(*
decl);
2626 clang::QualType
type = base.getType();
2629 if (
decl)
return TMetaUtils::IsSTLCont(*
decl);
2639 const std::function<
void(
const clang::Module::Header &)> &
closure,
2652 const std::size_t
maxArrayLength = ((
sizeof module.Headers) / (sizeof *module.Headers));
2654 "'Headers' has changed it's size, we need to update publicHeaderIndex");
2659 llvm::SetVector<const clang::Module *>
modules;
2661 for (
size_t i = 0; i <
modules.size(); ++i) {
2662 const clang::Module *M =
modules[i];
2663 for (
const clang::Module *
subModule : M->submodules())
2667 for (
const clang::Module *
m :
modules) {
2669 for (clang::Module *
used :
m->DirectUses) {
2691 static char t[4096];
2692 static const char*
constwd =
"const ";
2701 if (
lev==0 && *s==
'*')
continue;
2707 if (
lev==0 && *s==
' ' && *(s+1)!=
'*') {
p = t;
continue;}
2708 if (
p - t > (
long)
sizeof(t)) {
2709 printf(
"ERROR (rootcling): type name too long for StortTypeName: %s\n",
2722 const cling::Interpreter&
interp)
2727 if (!comment.empty() && comment[0] ==
'!')
2730 clang::QualType
type =
m.getType();
2732 if (
type->isReferenceType()) {
2737 std::string
mTypeName =
type.getAsString(
m.getASTContext().getPrintingPolicy());
2749 const clang::Type *
rawtype =
type.getTypePtr()->getBaseElementTypeUnsafe ();
2751 if (
rawtype->isPointerType()) {
2765 const clang::CXXRecordDecl *
cxxdecl =
rawtype->getAsCXXRecordDecl();
2782 const clang::Type *
rawtype =
m.getType().getTypePtr();
2806 return rawtype->getAsCXXRecordDecl();
2815 const cling::Interpreter &
interp,
2821 const clang::CXXRecordDecl*
decl = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
2823 if (!
decl || !
decl->isCompleteDefinition()) {
2827 std::string fullname;
2841 ROOT::TMetaUtils::Info(
nullptr,
"Class %s: Do not generate Streamer() [*** custom streamer ***]\n",fullname.c_str());
2866 const clang::ASTContext&
Ctx =
interpreter.getCI()->getASTContext();
2872 if (llvm::isa<clang::PointerType>(
instanceType.getTypePtr())) {
2886 if (llvm::isa<clang::ReferenceType>(
instanceType.getTypePtr())) {
2906 clang::NestedNameSpecifier *prefix =
nullptr;
2908 const clang::ElaboratedType* etype
2909 = llvm::dyn_cast<clang::ElaboratedType>(
instanceType.getTypePtr());
2914 instanceType = clang::QualType(etype->getNamedType().getTypePtr(),0);
2920 const clang::TemplateSpecializationType*
TST
2921 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instanceType.getTypePtr());
2923 const clang::ClassTemplateSpecializationDecl*
TSTdecl
2924 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
instanceType.getTypePtr()->getAsCXXRecordDecl());
2940 clang::TemplateDecl *Template =
TSTdecl->getSpecializedTemplate()->getMostRecentDecl();
2941 clang::TemplateParameterList *Params = Template->getTemplateParameters();
2948 llvm::SmallVector<clang::TemplateArgument, 4>
desArgs;
2949 llvm::SmallVector<clang::TemplateArgument, 4>
canonArgs;
2958 if (
I->getKind() == clang::TemplateArgument::Template) {
2965 clang::NamespaceDecl* ns = clang::dyn_cast<clang::NamespaceDecl>(
declCtxt);
2966 clang::NestedNameSpecifier*
nns;
2968 nns = cling::utils::TypeName::CreateNestedNameSpecifier(
Ctx, ns);
2969 }
else if (clang::TagDecl*
TD = llvm::dyn_cast<clang::TagDecl>(
declCtxt)) {
2970 nns = cling::utils::TypeName::CreateNestedNameSpecifier(
Ctx,
TD,
false );
2977 if (clang::UsingShadowDecl *
USD =
templateName.getAsUsingShadowDecl())
2987 if (
I->getKind() != clang::TemplateArgument::Type) {
2992 clang::QualType
SubTy =
I->getAsType();
3014 if (
templateArg.getKind() != clang::TemplateArgument::Type) {
3020 clang::SourceLocation
TemplateLoc = Template->getSourceRange ().getBegin();
3023 clang::TemplateTypeParmDecl *
TTP = llvm::dyn_cast<clang::TemplateTypeParmDecl>(*
Param);
3026 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
3028 clang::TemplateArgumentLoc
ArgType = S.SubstDefaultTemplateArgumentIfAvailable(
3038 if (
ArgType.getArgument().isNull()
3039 ||
ArgType.getArgument().getKind() != clang::TemplateArgument::Type) {
3041 "Template parameter substitution failed for %s around %s\n",
3061 TST->getCanonicalTypeInternal());
3090 llvm::StringRef title;
3093 if (clang::AnnotateAttr *A =
m.getAttr<clang::AnnotateAttr>())
3094 title = A->getAnnotation();
3108 if (title.size() == 0 || (title[0] !=
'['))
return llvm::StringRef();
3110 if (
rightbracket == llvm::StringRef::npos)
return llvm::StringRef();
3129 char *current =
const_cast<char*
>(
working.c_str());
3135 for(i=0;i<
strlen(current);i++) {
3143 return llvm::StringRef();
3148 const clang::CXXRecordDecl *
parent_clxx = llvm::dyn_cast<clang::CXXRecordDecl>(
m.getDeclContext());
3149 const clang::FieldDecl *
index1 =
nullptr;
3162 if (
field_iter->getNameAsString() ==
m.getNameAsString() ) {
3170 return llvm::StringRef();
3182 return llvm::StringRef();
3207 return llvm::StringRef();
3209 if ( found && (
index1->getAccess() == clang::AS_private) ) {
3214 return llvm::StringRef();
3223 return llvm::StringRef();
3244 while((
c = in[i++])) {
3245 const char *
repl =
nullptr;
3247 case '+':
repl =
"pL";
break;
3248 case '-':
repl =
"mI";
break;
3249 case '*':
repl =
"mU";
break;
3250 case '/':
repl =
"dI";
break;
3251 case '&':
repl =
"aN";
break;
3252 case '%':
repl =
"pE";
break;
3253 case '|':
repl =
"oR";
break;
3254 case '^':
repl =
"hA";
break;
3255 case '>':
repl =
"gR";
break;
3256 case '<':
repl =
"lE";
break;
3257 case '=':
repl =
"eQ";
break;
3258 case '~':
repl =
"wA";
break;
3259 case '.':
repl =
"dO";
break;
3260 case '(':
repl =
"oP";
break;
3261 case ')':
repl =
"cP";
break;
3262 case '[':
repl =
"oB";
break;
3263 case ']':
repl =
"cB";
break;
3264 case '!':
repl =
"nO";
break;
3265 case ',':
repl =
"cO";
break;
3266 case '$':
repl =
"dA";
break;
3267 case ' ':
repl =
"sP";
break;
3268 case ':':
repl =
"cL";
break;
3269 case '"':
repl =
"dQ";
break;
3270 case '@':
repl =
"aT";
break;
3271 case '\'':
repl =
"sQ";
break;
3272 case '\\':
repl =
"fI";
break;
3286static clang::SourceLocation
3300 const cling::Interpreter&
interp)
3330 using namespace clang;
3355 ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>>(),
3370 assert(
decl.isFirstDecl() &&
"Couldn't trace back include from a decl"
3371 " that is not from an AST file");
3396 clang::OptionalFileEntryRef
FELong;
3398 for (llvm::sys::path::const_iterator
3411 &&
"Mismatched partitioning of file name!");
3415 ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>>(),
3427 for (llvm::sys::path::reverse_iterator
3435 &&
"Mismatched partitioning of file name!");
3441 ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>>(),
3444 nullptr,
nullptr ) ==
FELong) {
3455 const clang::QualType &
qtype,
3467 const clang::QualType &
qtype,
3473 cling::Interpreter::PushTransactionRAII
RAII(
const_cast<cling::Interpreter*
>(&
interpreter));
3485 clang::ClassTemplateDecl*&
ctd,
3486 clang::ClassTemplateSpecializationDecl*&
ctsd)
3488 using namespace clang;
3496 if (
theType->isPointerType()) {
3501 ctsd = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
rType->getDecl());
3503 ctd =
ctsd->getSpecializedTemplate();
3513 ctsd = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
qt->getAsCXXRecordDecl());
3515 ctd =
ctsd->getSpecializedTemplate();
3530 using namespace clang;
3546 using namespace clang;
3565 const clang::NamedDecl&
tPar,
3566 const cling::Interpreter&
interp,
3570 using namespace clang;
3575 if (!
ttpdPtr->hasDefaultArgument())
return false;
3597 const clang::ElaboratedType* etype
3598 = llvm::dyn_cast<clang::ElaboratedType>(
tParQualType.getTypePtr());
3600 tParQualType = clang::QualType(etype->getNamedType().getTypePtr(),0);
3601 etype = llvm::dyn_cast<clang::ElaboratedType>(
tParQualType.getTypePtr());
3605 llvm::dyn_cast<TemplateSpecializationType>(
tParQualType.getTypePtr());
3611 = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
tArgQualType->getAsCXXRecordDecl());
3629 clang::Sema& S =
interp.getCI()->getSema();
3630 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interp));
3631 llvm::SmallVector<clang::TemplateArgument, 4>
canonArgs;
3644 newArg.getKind() != clang::TemplateArgument::Type) {
3646 "Template parameter substitution failed!");
3650 = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
newArg.getAsType()->getAsCXXRecordDecl());
3666 const clang::NamedDecl&
tPar)
3668 using namespace clang;
3673 if (!
nttpd.hasDefaultArgument())
3684 const int value =
tArg.getAsIntegral().getLimitedValue();
3697 using namespace clang;
3698 if (!
nDecl)
return false;
3700 return ttpd->hasDefaultArgument();
3702 return nttpd->hasDefaultArgument();
3709 const cling::Interpreter&
interp,
3714 const clang::TemplateArgument &
tArg,
3715 const cling::Interpreter&
interp,
3717 const clang::ASTContext&
astCtxt)
3720 using namespace clang;
3727 if (
tArg.getKind() == clang::TemplateArgument::Type) {
3736 }
else if (
normTArg.getKind() == clang::TemplateArgument::Pack) {
3737 assert(
tArg.getKind() == clang::TemplateArgument::Pack );
3765 const cling::Interpreter&
interp,
3769 using namespace clang;
3778 const int nArgsToKeep =
normCtxt.GetNargsToKeep(
ctd);
3788 if (llvm::isa<clang::PointerType>(
normalizedType.getTypePtr())) {
3801 if (llvm::isa<clang::ReferenceType>(
normalizedType.getTypePtr())) {
3820 clang::NestedNameSpecifier* prefix =
nullptr;
3822 const clang::ElaboratedType* etype
3823 = llvm::dyn_cast<clang::ElaboratedType>(
normalizedType.getTypePtr());
3829 normalizedType = clang::QualType(etype->getNamedType().getTypePtr(),0);
3837 clang::TemplateParameterList*
tpl =
rd->getTemplateParameters();
3838 if (
tpl->getMinRequiredArguments () <
tpl->size()) {
3845 Error(
"KeepNParams",
"Not found template default arguments\n");
3862 llvm::dyn_cast<TemplateSpecializationType>(
normalizedType.getTypePtr());
3868 const clang::ClassTemplateSpecializationDecl*
TSTdecl
3869 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
normalizedType.getTypePtr()->getAsCXXRecordDecl());
3877 llvm::SmallVector<TemplateArgument, 4>
argsToKeep;
3889 Error(
"KeepNParams",
"The parameter number %s is null.\n",
formal);
3911 if (
tParPtr->isTemplateParameterPack() ) {
3941 if (
argKind == clang::TemplateArgument::Type){
3944 }
else if (
argKind == clang::TemplateArgument::Integral){
3992 cling::Interpreter::PushTransactionRAII
RAII(
const_cast<cling::Interpreter*
>(&
interpreter));
4015 if (
type.isNull()) {
4023 clang::PrintingPolicy
policy(
ctxt.getPrintingPolicy());
4024 policy.SuppressTagKeyword =
true;
4025 policy.SuppressScope =
true;
4026 policy.AnonymousTagLocations =
false;
4034 cling::Interpreter::PushTransactionRAII
clingRAII(
const_cast<cling::Interpreter*
>(&
interpreter));
4059 clang::ASTContext&
astCtxt =
sema.getASTContext();
4069std::pair<std::string,clang::QualType>
4090 cling::LookupHelper::DiagSetting::NoDiagnostics,
4109 "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());
4137 llvm::errs() << llvm::StringRef(
commentStart, 80) <<
'\n';
4186 if (
const clang::FunctionDecl*
FD = clang::dyn_cast<clang::FunctionDecl>(&
decl)) {
4187 if (
FD->isImplicit()) {
4191 if (
FD->isExplicitlyDefaulted() ||
FD->isDeletedAsWritten()) {
4195 }
else if (
FD->doesThisDeclarationHaveABody()) {
4200 &&
"Expected macro or end of body at '}'");
4212 }
else if (
const clang::EnumConstantDecl*
ECD
4213 = clang::dyn_cast<clang::EnumConstantDecl>(&
decl)) {
4215 if (
ECD->getNextDeclInContext())
4292 if (!
decl)
return false;
4299 static const std::vector<std::string>
signatures =
4300 {
"ClassDef",
"ClassDefOverride",
"ClassDefNV",
"ClassDefInline",
"ClassDefInlineOverride",
"ClassDefInlineNV" };
4317 clang::SourceLocation *
loc,
4320 using namespace clang;
4323 =
interpreter.getLookupHelper().findFunctionProto(&
decl,
"DeclFileLine",
"",
4324 cling::LookupHelper::NoDiagnostics);
4330 if (comment.size()) {
4337 return llvm::StringRef();
4349 if (
rawtype->isElaboratedTypeSpecifier() ) {
4353 rawtype =
type.getTypePtr()->getBaseElementTypeUnsafe ();
4362 if (
rawtype->isElaboratedTypeSpecifier() ) {
4382 if (
ctxt.isNamespace() ||
ctxt.isTranslationUnit())
4384 else if(
const auto parentdecl = llvm::dyn_cast<clang::CXXRecordDecl>(&
ctxt))
4397 const clang::DeclContext *
ctxt =
decl.getDeclContext();
4398 switch (
decl.getAccess()) {
4399 case clang::AS_public:
4401 case clang::AS_protected:
4403 case clang::AS_private:
4405 case clang::AS_none:
4409 assert(
false &&
"Unexpected value for the access property value in Clang");
4419 return cling::utils::Analyze::IsStdClass(cl);
4429 if (cling::utils::Analyze::IsStdClass(cl)) {
4430 static const char *names[] =
4431 {
"shared_ptr",
"__shared_ptr",
4432 "vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset"};
4433 llvm::StringRef
clname(cl.getName());
4434 for(
auto &&
name : names) {
4472 const clang::CXXRecordDecl *
thisDecl =
4473 llvm::dyn_cast_or_null<clang::CXXRecordDecl>(
lh.findScope(
typ, cling::LookupHelper::WithDiagnostics));
4477 Error(
"IsOfType",
"Record decl of type %s not found in the AST.",
typ.c_str());
4507 if (!IsStdClass(cl)) {
4508 auto *
nsDecl = llvm::dyn_cast<clang::NamespaceDecl>(cl.getDeclContext());
4509 if (cl.getName() !=
"RVec" ||
nsDecl ==
nullptr ||
nsDecl->getName() !=
"VecOps")
4512 auto *
parentNsDecl = llvm::dyn_cast<clang::NamespaceDecl>(cl.getDeclContext()->getParent());
4517 return STLKind(cl.getName());
4521 using namespace clang;
4522 struct SearchTypedef:
public TypeVisitor<SearchTypedef, bool> {
4527 return Visit(
AT->getElementType().getTypePtr());
4530 return Visit(
DT->getUnderlyingType().getTypePtr());
4533 return Visit(
PT->getPointeeType().getTypePtr());
4536 return Visit(
RT->getPointeeType().getTypePtr());
4539 return Visit(
STST->getReplacementType().getTypePtr());
4543 if (
TA.getKind() == TemplateArgument::Type && Visit(
TA.getAsType().getTypePtr()))
4552 return TOT->getUnmodifiedType().getTypePtr();
4557 if (
NNS->getKind() == NestedNameSpecifier::TypeSpec) {
4558 if (Visit(
NNS->getAsType()))
4563 return Visit(
ET->getNamedType().getTypePtr());
4584 using namespace llvm;
4585 using namespace clang;
4586 const clang::ASTContext &
Ctxt =
instance->getAsCXXRecordDecl()->getASTContext();
4589 const clang::ElaboratedType* etype
4590 = llvm::dyn_cast<clang::ElaboratedType>(
input.getTypePtr());
4595 assert(
instance->getAsCXXRecordDecl() !=
nullptr &&
"ReSubstTemplateArg only makes sense with a type representing a class.");
4614 if (
nQT ==
QT->getPointeeType())
return QT;
4630 if (
nQT ==
QT->getPointeeType())
return QT;
4651 if (
newQT ==
arr->getElementType())
return QT;
4655 arr->getSizeModifier(),
4656 arr->getIndexTypeCVRQualifiers());
4664 arr->getSizeModifier(),
4665 arr->getIndexTypeCVRQualifiers(),
4666 arr->getBracketsRange());
4671 if (
newQT ==
arr->getElementType())
return QT;
4673 arr->getSizeModifier(),
4674 arr->getIndexTypeCVRQualifiers());
4679 if (
newQT ==
arr->getElementType())
return QT;
4682 arr->getSizeModifier(),
4683 arr->getIndexTypeCVRQualifiers(),
4684 arr->getBracketsRange());
4693 etype = llvm::dyn_cast<clang::ElaboratedType>(
instance);
4695 instance = etype->getNamedType().getTypePtr();
4699 const clang::TemplateSpecializationType*
TST
4700 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
instance);
4704 const clang::ClassTemplateSpecializationDecl*
TSTdecl
4705 = llvm::dyn_cast_or_null<const clang::ClassTemplateSpecializationDecl>(
instance->getAsCXXRecordDecl());
4709 const clang::SubstTemplateTypeParmType *
substType
4710 = llvm::dyn_cast<clang::SubstTemplateTypeParmType>(
input.getTypePtr());
4714 const clang::ClassTemplateDecl *
replacedCtxt =
nullptr;
4718 unsigned int index =
substType->getReplacedParameter()->getIndex();
4721 if (
decl->getKind() == clang::Decl::ClassTemplatePartialSpecialization) {
4722 const clang::ClassTemplatePartialSpecializationDecl *
spec = llvm::dyn_cast<clang::ClassTemplatePartialSpecializationDecl>(
decl);
4724 unsigned int depth =
substType->getReplacedParameter()->getDepth();
4740 const clang::SubstTemplateTypeParmType *
argType
4741 = llvm::dyn_cast<clang::SubstTemplateTypeParmType>(
argQualType);
4766 llvm::raw_string_ostream ostream(
astDump);
4769 ROOT::TMetaUtils::Warning(
"ReSubstTemplateArg",
"Unexpected type of declaration context for template parameter: %s.\n\tThe responsible class is:\n\t%s\n",
4776 const auto &
TAs =
TST->template_arguments();
4793 const clang::TemplateSpecializationType*
inputTST
4794 = llvm::dyn_cast<const clang::TemplateSpecializationType>(
input.getTypePtr());
4799 llvm::SmallVector<clang::TemplateArgument, 4>
desArgs;
4800 for (
const clang::TemplateArgument &
TA :
inputTST->template_arguments()) {
4801 if (
TA.getKind() != clang::TemplateArgument::Type) {
4806 clang::QualType
SubTy =
TA.getAsType();
4808 if (llvm::isa<clang::ElaboratedType>(
SubTy)
4809 || llvm::isa<clang::SubstTemplateTypeParmType>(
SubTy)
4810 || llvm::isa<clang::TemplateSpecializationType>(
SubTy)) {
4825 inputTST->getCanonicalTypeInternal());
4866 static const char *
stls[] =
4867 {
"any",
"vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset",
4868 "forward_list",
"unordered_set",
"unordered_multiset",
"unordered_map",
"unordered_multimap",
"RVec",
nullptr};
4882 for(
int k=1;
stls[k];k++) {
if (
type.equals(
stls[k]))
return values[k];}
4893 TND =
TND->getMostRecentDecl();
4894 while (
TND && !(
TND->hasAttrs()))
4895 TND =
TND->getPreviousDecl();
4907 TD =
TD->getMostRecentDecl();
4908 while (
TD && !(
TD->hasAttrs() &&
TD->isThisDeclarationADefinition()))
4909 TD =
TD->getPreviousDecl();
4965 std::list<std::pair<std::string,unsigned int> >&
enclosingSc)
4993 std::string::size_type
beginVar = 0;
4994 std::string::size_type
endVar = 0;
4998 std::string::size_type
endVarName = std::string::npos;
5135 return llvm::sys::path::extension(
filename) ==
".h" ||
5136 llvm::sys::path::extension(
filename) ==
".hh" ||
5137 llvm::sys::path::extension(
filename) ==
".hpp" ||
5138 llvm::sys::path::extension(
filename) ==
".H" ||
5139 llvm::sys::path::extension(
filename) ==
".h++" ||
5140 llvm::sys::path::extension(
filename) ==
"hxx" ||
5141 llvm::sys::path::extension(
filename) ==
"Hxx" ||
5142 llvm::sys::path::extension(
filename) ==
"HXX";
5148 cling::Interpreter::IgnoreFilesFunc_t
ignoreFiles,
5149 const cling::Interpreter &
interp,
5157 clang::Decl *
ncDecl =
const_cast<clang::Decl *
>(
decl);
5202 static const std::string
scopeType [] = {
"namespace ",
"inline namespace ",
"class "};
5244 std::string typeName;
5247 if (llvm::isa<clang::TemplateTypeParmDecl>(
nDecl)){
5248 typeName =
"typename ";
5249 if (
nDecl->isParameterPack())
5251 typeName += (*prmIt)->getNameAsString();
5254 else if (
auto nttpd = llvm::dyn_cast<clang::NonTypeTemplateParmDecl>(
nDecl)){
5258 if (
theType.getAsString().find(
"enum") != std::string::npos){
5260 llvm::raw_string_ostream ostream(
astDump);
5261 nttpd->dump(ostream);
5272 else if (
auto ttpd = llvm::dyn_cast<clang::TemplateTemplateParmDecl>(
nDecl)){
5276 llvm::raw_string_ostream ostream(
astDump);
5277 ttpd->dump(ostream);
5302 "Cannot extract template parameter list for %s",
5310 "Problems with arguments for forward declaration of class %s\n",
5320 if (llvm::isa<clang::TemplateTemplateParmDecl>(&
templDecl)) {
5342 if (clang::TemplateArgument::Type != arg.getKind())
return 0;
5357 if (llvm::isa<clang::BuiltinType>(
argTypePtr)){
5390 if (
specDef->getTemplateSpecializationKind() != clang::TSK_ExplicitSpecialization)
5394 std::cout <<
" Forward declaring template spec " <<
normalizedName <<
":\n";
5399 std::cout <<
" o Template argument ";
5401 std::cout <<
"successfully treated. Arg fwd decl: " <<
argFwdDecl << std::endl;
5403 std::cout <<
"could not be treated. Abort fwd declaration generation.\n";
5444 std::cout <<
"Class " <<
recordDecl.getNameAsString()
5445 <<
" is a template specialisation. Treating its arguments.\n";
5449 std::cout <<
" o Template argument ";
5451 std::cout <<
"successfully treated. Arg fwd decl: " <<
argFwdDecl << std::endl;
5453 std::cout <<
"could not be treated. Abort fwd declaration generation.\n";
5501 std::string buffer =
tdnDecl.getNameAsString();
5504 if (
const clang::TagType* TT
5506 if (clang::NamedDecl*
ND = TT->getDecl()) {
5507 if (!
ND->getIdentifier()) {
5551 std::cout <<
"Typedef " <<
tdnDecl.getNameAsString() <<
" hides a class: "
5578 const clang::PrintingPolicy&
ppolicy)
5581 auto&
ctxt = par.getASTContext();
5602 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 .