62#include "RConfigure.h"
63#include "compiledata.h"
80#include "clang/AST/ASTContext.h"
81#include "clang/AST/Decl.h"
82#include "clang/AST/DeclarationName.h"
83#include "clang/AST/GlobalDecl.h"
84#include "clang/AST/RecordLayout.h"
85#include "clang/AST/DeclVisitor.h"
86#include "clang/AST/RecursiveASTVisitor.h"
87#include "clang/AST/Type.h"
88#include "clang/Basic/SourceLocation.h"
89#include "clang/Basic/Specifiers.h"
90#include "clang/Basic/TargetInfo.h"
91#include "clang/CodeGen/ModuleBuilder.h"
92#include "clang/Frontend/CompilerInstance.h"
93#include "clang/Frontend/FrontendDiagnostic.h"
94#include "clang/Lex/HeaderSearch.h"
95#include "clang/Lex/Preprocessor.h"
96#include "clang/Lex/PreprocessorOptions.h"
97#include "clang/Parse/Parser.h"
98#include "clang/Sema/Lookup.h"
99#include "clang/Sema/Sema.h"
100#include "clang/Serialization/ASTReader.h"
101#include "clang/Serialization/GlobalModuleIndex.h"
103#include "cling/Interpreter/ClangInternalState.h"
104#include "cling/Interpreter/DynamicLibraryManager.h"
105#include "cling/Interpreter/Interpreter.h"
106#include "cling/Interpreter/LookupHelper.h"
107#include "cling/Interpreter/Value.h"
108#include "cling/Interpreter/Transaction.h"
109#include "cling/MetaProcessor/MetaProcessor.h"
110#include "cling/Utils/AST.h"
111#include "cling/Utils/ParserStateRAII.h"
112#include "cling/Utils/SourceNormalization.h"
113#include "cling/Interpreter/Exception.h"
115#include "llvm/IR/GlobalValue.h"
116#include "llvm/IR/Module.h"
118#include "llvm/Support/DynamicLibrary.h"
119#include "llvm/Support/raw_ostream.h"
120#include "llvm/Support/Path.h"
121#include "llvm/Support/Process.h"
122#include "llvm/Object/ELFObjectFile.h"
123#include "llvm/Object/ObjectFile.h"
124#include "llvm/Object/SymbolicFile.h"
125#include "llvm/Support/FileSystem.h"
139#include <unordered_map>
140#include <unordered_set>
147#define R__DLLEXPORT __attribute__ ((visibility ("default")))
155#include <mach-o/dyld.h>
156#include <mach-o/loader.h>
170#if defined(__CYGWIN__)
171#include <sys/cygwin.h>
172#define HMODULE void *
174 __declspec(dllimport)
void * __stdcall GetCurrentProcess();
175 __declspec(dllimport)
bool __stdcall EnumProcessModules(
void *,
void **,
unsigned long,
unsigned long *);
176 __declspec(dllimport)
unsigned long __stdcall GetModuleFileNameExW(
void *,
void *,
wchar_t *,
unsigned long);
183# define STDIN_FILENO 0
186# define STDOUT_FILENO 1
189# define STDERR_FILENO 2
198#undef GetModuleFileName
199#define RTLD_DEFAULT ((void *)::GetModuleHandle(NULL))
200#define dlsym(library, function_name) ::GetProcAddress((HMODULE)library, function_name)
201#define dlopen(library_name, flags) ::LoadLibraryA(library_name)
202#define dlclose(library) ::FreeLibrary((HMODULE)library)
203#define R__DLLEXPORT __declspec(dllexport)
211 class TCling_UnloadMarker {
213 ~TCling_UnloadMarker() {
219 static TCling_UnloadMarker gTClingUnloadMarker;
228 return D->getDeclContext();
231 return llvm::dyn_cast<clang::NamespaceDecl>(DC);
234 return llvm::dyn_cast<clang::RecordDecl>(DC);
237 return DC->dumpDeclContext();
246 return ((clang::Decl*)D)->dump();
249 if (clang::NamedDecl* ND = llvm::dyn_cast<clang::NamedDecl>(D)) {
252 llvm::raw_string_ostream OS(
name);
253 ND->getNameForDiagnostic(OS, D->getASTContext().getPrintingPolicy(),
256 printf(
"%s\n",
name.c_str());
264 return D->isInvalidDecl();
268 assert(info && info->
IsValid());
269 return info->
GetDecl()->isInvalidDecl();
273using namespace clang;
277 static const std::string gInterpreterClassDef = R
"ICF(
279#define ClassDef(name, id) \
280_ClassDefInterp_(name,id,virtual,) \
281static int DeclFileLine() { return __LINE__; }
283#define ClassDefNV(name, id) \
284_ClassDefInterp_(name,id,,) \
285static int DeclFileLine() { return __LINE__; }
286#undef ClassDefOverride
287#define ClassDefOverride(name, id) \
288_ClassDefInterp_(name,id,,override) \
289static int DeclFileLine() { return __LINE__; }
292 static const std::string gNonInterpreterClassDef = R
"ICF(
293#define __ROOTCLING__ 1
295#define ClassDef(name,id) \
296_ClassDefOutline_(name,id,virtual,) \
297static int DeclFileLine() { return __LINE__; }
299#define ClassDefNV(name, id)\
300_ClassDefOutline_(name,id,,)\
301static int DeclFileLine() { return __LINE__; }
302#undef ClassDefOverride
303#define ClassDefOverride(name, id)\
304_ClassDefOutline_(name,id,,override)\
305static int DeclFileLine() { return __LINE__; }
309 static const std::string gClassDefInterpMacro = R
"ICF(
312#define _ClassDefInterp_(name,id,virtual_keyword, overrd) \
315 static TClass *Class() { static TClass* sIsA = 0; if (!sIsA) sIsA = TClass::GetClass(#name); return sIsA; } \
316 static const char *Class_Name() { return #name; } \
317 virtual_keyword Bool_t CheckTObjectHashConsistency() const overrd { return true; } \
318 static Version_t Class_Version() { return id; } \
319 static TClass *Dictionary() { return 0; } \
320 virtual_keyword TClass *IsA() const overrd { return name::Class(); } \
321 virtual_keyword void ShowMembers(TMemberInspector&insp) const overrd { ::ROOT::Class_ShowMembers(name::Class(), this, insp); } \
322 virtual_keyword void Streamer(TBuffer&) overrd { ::Error("Streamer", "Cannot stream interpreted class."); } \
323 void StreamerNVirtual(TBuffer&ClassDef_StreamerNVirtual_b) { name::Streamer(ClassDef_StreamerNVirtual_b); } \
324 static const char *DeclFileName() { return __FILE__; } \
325 static int ImplFileLine() { return 0; } \
326 static const char *ImplFileName() { return __FILE__; }
357 return ((
TCling*)
gCling)->LibraryLoadingFailed(errmessage, libStem, permanent, resolved);
396 static vector<const NamedDecl*> updateList;
399 if (entered) topLevel =
kFALSE;
414 updateList.push_back(TD);
417 while (!updateList.empty()) {
419 updateList.pop_back();
426 const clang::Decl* D =
static_cast<const clang::Decl*
>(enumObj->
GetDeclId());
427 if(
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(D)) {
429 for (EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(),
430 EDE = ED->enumerator_end(); EDI != EDE; ++EDI) {
432 std::string constbuf;
433 if (
const NamedDecl* END = llvm::dyn_cast<NamedDecl>(*EDI)) {
434 PrintingPolicy Policy((*EDI)->getASTContext().getPrintingPolicy());
435 llvm::raw_string_ostream stream(constbuf);
437 Policy.AnonymousTagLocations =
false;
438 (END)->getNameForDiagnostic(stream, Policy,
false);
440 const char* constantName = constbuf.c_str();
444 const llvm::APSInt valAPSInt = (*EDI)->getInitVal();
445 if (valAPSInt.isSigned()) {
446 value = valAPSInt.getSExtValue();
448 value = valAPSInt.getZExtValue();
455 DataMemberInfo_t* dmInfo = (DataMemberInfo_t*) tcDmInfo;
459 enumConstant =
new TEnumConstant(dmInfo, constantName, value, enumObj);
466 globals->
Add(enumConstant);
479 const clang::Decl* D =
static_cast<const clang::Decl*
>(VD);
481 if (
const EnumDecl* ED = llvm::dyn_cast<EnumDecl>(D)) {
483 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
484 llvm::raw_string_ostream stream(buf);
486 Policy.AnonymousTagLocations =
false;
487 ED->getNameForDiagnostic(stream, Policy,
false);
493 const char*
name = buf.c_str();
504 const clang::Decl* D =
static_cast<const clang::Decl*
>(DV);
506 if (!D->isCanonicalDecl() && !isa<clang::NamespaceDecl>(D)
507 && !dyn_cast<clang::RecordDecl>(D))
return;
509 if (isa<clang::FunctionDecl>(D->getDeclContext())
510 || isa<clang::TagDecl>(D->getDeclContext()))
514 if (
const clang::CXXRecordDecl* RD = dyn_cast<clang::CXXRecordDecl>(D)) {
515 if (RD->getDescribedClassTemplate())
517 }
else if (
const clang::FunctionDecl* FD = dyn_cast<clang::FunctionDecl>(D)) {
518 if (FD->getDescribedFunctionTemplate())
522 if (
const RecordDecl *TD = dyn_cast<RecordDecl>(D)) {
523 if (TD->isCanonicalDecl() || TD->isThisDeclarationADefinition())
526 else if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
528 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
532 }
else if (
const NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(D)) {
537 if (!isa<TranslationUnitDecl>(ND->getDeclContext()))
541 if (isa<EnumDecl>(ND))
546 if (!(isa<VarDecl>(ND)))
550 if (
gROOT->GetListOfGlobals()->FindObject(ND->getNameAsString().c_str()))
554 gROOT->GetListOfGlobals()->Add(
new TGlobal((DataMemberInfo_t *)
556 cast<ValueDecl>(ND), 0)));
588 const char* canonicalName) {
589 ((
TCling*)
gCling)->LibraryLoaded(dyLibHandle, canonicalName);
594 ((
TCling *)
gCling)->RegisterRdictForLoadPCM(pcmFileNameFullPath, pcmContent);
598 const char* canonicalName) {
599 ((
TCling*)
gCling)->LibraryUnloaded(dyLibHandle, canonicalName);
615 cling::DynamicLibraryManager::ExposeHiddenSharedLibrarySymbols(interpLibHandle);
616 return new TCling(
"C++",
"cling C++ Interpreter", argv);
638 return ((
TCling*)
gCling)->GetClassSharedLibs(className);
644 return ((
TCling*)
gCling)->IsAutoLoadNamespaceCandidate(nsDecl);
649 string file(fileName);
655 string &args,
string &io,
string &fname)
657 string file(fileName);
658 TString f, amode, arguments, aclicio;
660 mode = amode.
Data(); args = arguments.
Data();
661 io = aclicio.
Data(); fname =
f.Data();
671 char *__unDName(
char *demangled,
const char *mangled,
int out_len,
672 void * (* pAlloc )(
size_t),
void (* pFree )(
void *),
673 unsigned short int flags);
685 using namespace clang;
686 if (NamespaceDecl* nsd = llvm::dyn_cast<NamespaceDecl>(decl)){
690 if (ClassTemplateDecl* ctd = llvm::dyn_cast<ClassTemplateDecl>(decl)){
702 return ((
TCling*)
gCling)->LazyFunctionCreatorAutoload(mangled_name);
711 const std::vector<std::string> &headers,
712 const std::vector<std::string> &fwdDecls,
713 const std::vector<std::string> &unknown)
719 if (classes.empty()) {
723 const std::string& className = classes[0];
725 TString fileName =
"AutoDict_";
726 std::string::const_iterator sIt;
727 for (sIt = className.begin(); sIt != className.end(); ++sIt) {
728 if (*sIt ==
'<' || *sIt ==
'>' ||
729 *sIt ==
' ' || *sIt ==
'*' ||
730 *sIt ==
',' || *sIt ==
'&' ||
738 if (classes.size() > 1) {
740 std::vector<std::string>::const_iterator it = classes.begin();
741 while ((++it) != classes.end()) {
742 for (
UInt_t cursor = 0; cursor != it->length(); ++cursor) {
743 chk = chk * 3 + it->at(cursor);
756 static const std::set<std::string> sSTLTypes {
757 "vector",
"list",
"forward_list",
"deque",
"map",
"unordered_map",
"multimap",
758 "unordered_multimap",
"set",
"unordered_set",
"multiset",
"unordered_multiset",
759 "queue",
"priority_queue",
"stack",
"iterator"};
760 std::vector<std::string>::const_iterator it;
761 std::string fileContent(
"");
762 for (it = headers.begin(); it != headers.end(); ++it) {
763 fileContent +=
"#include \"" + *it +
"\"\n";
765 for (it = unknown.begin(); it != unknown.end(); ++it) {
771 while (dirbase.
Length() && dirbase !=
"."
772 && dirbase !=
"include" && dirbase !=
"inc"
773 && dirbase !=
"prec_stl") {
777 fileContent +=
TString(
"#include \"") + header +
"\"\n";
780 for (it = fwdDecls.begin(); it != fwdDecls.end(); ++it) {
781 fileContent +=
"class " + *it +
";\n";
783 fileContent +=
"#ifdef __CINT__ \n";
784 fileContent +=
"#pragma link C++ nestedclasses;\n";
785 fileContent +=
"#pragma link C++ nestedtypedefs;\n";
786 for (it = classes.begin(); it != classes.end(); ++it) {
788 size_t posTemplate =
n.find(
'<');
789 std::set<std::string>::const_iterator iSTLType = sSTLTypes.end();
790 if (posTemplate != std::string::npos) {
791 n.erase(posTemplate, std::string::npos);
792 if (
n.compare(0, 5,
"std::") == 0) {
795 iSTLType = sSTLTypes.find(
n);
797 fileContent +=
"#pragma link C++ class ";
798 fileContent += *it +
"+;\n" ;
799 fileContent +=
"#pragma link C++ class ";
800 if (iSTLType != sSTLTypes.end()) {
804 fileContent += *it +
"::*;\n" ;
809 fileContent += *it +
"::*+;\n" ;
812 fileContent +=
"#endif\n";
816 filePointer = fopen(fileName,
"w");
817 if (filePointer == NULL) {
823 fprintf(filePointer,
"%s", fileContent.c_str());
839 const std::vector<std::string> &headers,
840 const std::vector<std::string> &fwdDecls,
841 const std::vector<std::string> &unknown)
847 std::vector<std::string> classes;
848 classes.push_back(className);
876 void exceptionErrorHandler(
void * ,
877 const std::string& reason,
879 throw std::runtime_error(std::string(
">>> Interpreter compilation error:\n") + reason);
893 class clangDiagSuppr {
895 clangDiagSuppr(clang::DiagnosticsEngine& diag): fDiagEngine(diag){
896 fOldDiagValue = fDiagEngine.getIgnoreAllWarnings();
897 fDiagEngine.setIgnoreAllWarnings(
true);
901 fDiagEngine.setIgnoreAllWarnings(fOldDiagValue);
904 clang::DiagnosticsEngine& fDiagEngine;
926 unsigned long offset = 0;
927 if (strncmp(tname.c_str(),
"const ", 6) == 0) {
930 unsigned long end = tname.length();
931 while( end && (tname[end-1]==
'&' || tname[end-1]==
'*' || tname[end-1]==
']') ) {
932 if ( tname[end-1]==
']' ) {
934 while ( end && tname[end-1]!=
'[' ) --end;
938 std::string innerbuf;
940 if (end != tname.length()) {
941 innerbuf = tname.substr(offset,end-offset);
942 inner = innerbuf.c_str();
944 inner = tname.c_str()+offset;
948 if (
gROOT->GetListOfClasses()->FindObject(inner)
958 const char *newname =
type->GetFullTypeName();
960 newname =
"Long64_t";
962 newname =
"ULong64_t";
964 if (strcmp(inner,newname) == 0) {
967 if (offset) result =
"const ";
969 if ( end != tname.length() ) {
970 result += tname.substr(end,tname.length()-end);
972 if (result == tname) result.clear();
978 if (lastPos != inner)
982 const auto enName = lastPos;
983 const auto scopeNameSize = ((
Long64_t)lastPos - (
Long64_t)inner) /
sizeof(
decltype(*lastPos)) - 2;
984 char *scopeName =
new char[scopeNameSize + 1];
985 strncpy(scopeName, inner, scopeNameSize);
986 scopeName[scopeNameSize] =
'\0';
988 if (
auto scope =
static_cast<TClass *
>(
gROOT->GetListOfClasses()->FindObject(scopeName))) {
989 auto enumTable =
dynamic_cast<const THashList *
>(scope->GetListOfEnums(
false));
990 if (enumTable && enumTable->THashList::FindObject(enName)) {
delete [] scopeName;
return true; }
994 auto listOfEnums = scope->GetListOfEnums();
996 auto enumTable =
dynamic_cast<const THashList *
>(listOfEnums);
997 if (enumTable && enumTable->THashList::FindObject(enName)) {
delete [] scopeName;
return true; }
1000 delete [] scopeName;
1004 auto enumTable =
dynamic_cast<const THashList *
>(
gROOT->GetListOfEnums());
1005 if (enumTable && enumTable->THashList::FindObject(inner))
return true;
1028 return fContent.c_str();
1036 bool notPresent = fLinesHashSet.emplace(fHashFunc(str)).second;
1050static bool LoadModule(
const std::string &ModuleName, cling::Interpreter &interp)
1060 assert(!currentDir.empty());
1063 ::Info(
"TCling::__LoadModule",
"Preloading module %s. \n",
1064 ModuleName.c_str());
1066 return interp.loadModule(ModuleName,
true);
1072static void LoadModules(
const std::vector<std::string> &modules, cling::Interpreter &interp)
1074 for (
const auto &modName : modules)
1080 const static bool foundSymbol = dlsym(RTLD_DEFAULT,
"usedToIdentifyRootClingByDlSym");
1085static bool HasASTFileOnDisk(clang::Module *M,
const clang::Preprocessor &PP, std::string *FullFileName =
nullptr)
1087 const HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
1089 std::string ModuleFileName;
1090 if (!HSOpts.PrebuiltModulePaths.empty())
1092 ModuleFileName = PP.getHeaderSearchInfo().getModuleFileName(M->Name,
"",
true);
1094 *FullFileName = ModuleFileName;
1096 return !ModuleFileName.empty();
1102 CompilerInstance &CI = *interp.getCI();
1103 Preprocessor &PP = CI.getPreprocessor();
1104 auto ModuleManager = CI.getModuleManager();
1105 assert(ModuleManager);
1110 if (ModuleIndexPath.empty())
1113 ModuleManager->resetForReload();
1114 ModuleManager->loadGlobalIndex();
1115 GlobalModuleIndex *GlobalIndex = ModuleManager->getGlobalIndex();
1120 ModuleMap &MMap = PP.getHeaderSearchInfo().getModuleMap();
1121 bool RecreateIndex =
false;
1122 for (ModuleMap::module_iterator
I = MMap.module_begin(),
E = MMap.module_end();
I !=
E; ++
I) {
1123 Module *TheModule =
I->second;
1128 RecreateIndex =
true;
1130 if (RecreateIndex) {
1131 GlobalModuleIndex::writeIndex(CI.getFileManager(), CI.getPCHContainerReader(), ModuleIndexPath);
1132 ModuleManager->resetForReload();
1133 ModuleManager->loadGlobalIndex();
1134 GlobalIndex = ModuleManager->getGlobalIndex();
1143 if (!clingInterp.getCI()->getLangOpts().Modules)
1160 LoadModule(
"_Builtin_intrinsics", clingInterp);
1164 std::vector<std::string> CoreModules = {
"ROOT_Foundation_C",
1167 "ROOT_Foundation_Stage1_NoRTTI",
1174 static constexpr std::array<const char *, 3> ExcludeModules = {
1175 {
"Rtools",
"RSQLite",
"RInterface"}};
1179 std::vector<std::string> CommonModules = {
"MathCore"};
1183 std::vector<std::string> FIXMEModules = {
"Hist",
"Gpad",
"Graf",
1184 "GenVector",
"Smatrix",
"Tree",
1185 "TreePlayer",
"Physics",
1189 clang::CompilerInstance &CI = *clingInterp.getCI();
1190 GlobalModuleIndex *GlobalIndex =
nullptr;
1191 const char *experimentalGMI =
gSystem->
Getenv(
"ROOT_EXPERIMENTAL_GMI");
1192 if (experimentalGMI && strcmp(experimentalGMI,
"false") != 0) {
1194 GlobalIndex = CI.getModuleManager()->getGlobalIndex();
1196 llvm::StringSet<> KnownModuleFileNames;
1198 GlobalIndex->getKnownModuleFileNames(KnownModuleFileNames);
1200 clang::Preprocessor &PP = CI.getPreprocessor();
1201 std::vector<std::string> PendingModules;
1202 PendingModules.reserve(256);
1203 ModuleMap &MMap = PP.getHeaderSearchInfo().getModuleMap();
1204 for (
auto I = MMap.module_begin(),
E = MMap.module_end();
I !=
E; ++
I) {
1205 clang::Module *M =
I->second;
1209 std::string FullASTFilePath;
1213 if (GlobalIndex && KnownModuleFileNames.count(FullASTFilePath))
1216 if (M->IsMissingRequirement)
1224 if (std::find(CoreModules.begin(), CoreModules.end(), M->Name) != CoreModules.end())
1227 if (std::find(ExcludeModules.begin(), ExcludeModules.end(), M->Name) != ExcludeModules.end())
1235 PendingModules.push_back(M->Name);
1242 assert(clingInterp.getMacro(
"gROOT") &&
"Couldn't load gROOT macro?");
1250 clingInterp.declare(
"#ifdef I\n #undef I\n #endif\n");
1254 clingInterp.declare(
"#ifdef complex\n #undef complex\n #endif\n");
1258 clingInterp.declare(
"#ifdef PI\n #undef PI\n #endif\n");
1259 clingInterp.declare(
"#ifdef ERROR\n #undef ERROR\n #endif\n");
1264 std::string PreIncludes;
1265 bool hasCxxModules = clingInterp.getCI()->getLangOpts().Modules;
1271 PreIncludes +=
"#include \"RtypesCore.h\"\n";
1274 PreIncludes +=
"#include \"Rtypes.h\"\n";
1276 PreIncludes += gClassDefInterpMacro +
"\n"
1277 + gInterpreterClassDef +
"\n"
1279 "#define ClassImp(X);\n";
1282 PreIncludes +=
"#include <string>\n";
1287 PreIncludes +=
"#include <cassert>\n";
1289 PreIncludes +=
"using namespace std;\n";
1290 clingInterp.declare(PreIncludes);
1308#ifdef R__USE_CXXMODULES
1312 llvm::install_fatal_error_handler(&exceptionErrorHandler);
1316 std::vector<std::string> clingArgsStorage;
1317 clingArgsStorage.push_back(
"cling4root");
1318 for (
const char*
const* arg = argv; *arg; ++arg)
1319 clingArgsStorage.push_back(*arg);
1322 if (!fromRootCling) {
1327 clingArgsStorage.push_back(
"-I" + interpInclude);
1330 clingArgsStorage.push_back(
"-I" + interpInclude +
"/cling");
1341 std::string pchFilename = interpInclude +
"/allDict.cxx.pch";
1346 clingArgsStorage.push_back(
"-include-pch");
1347 clingArgsStorage.push_back(pchFilename);
1350 clingArgsStorage.push_back(
"-Wno-undefined-inline");
1351 clingArgsStorage.push_back(
"-fsigned-char");
1355 llvm::Optional<std::string> EnvOpt = llvm::sys::Process::GetEnv(
"EXTRA_CLING_ARGS");
1356 if (EnvOpt.hasValue()) {
1357 StringRef Env(*EnvOpt);
1358 while (!Env.empty()) {
1360 std::tie(Arg, Env) = Env.split(
' ');
1361 clingArgsStorage.push_back(Arg.str());
1365 auto GetEnvVarPath = [](
const std::string &EnvVar,
1366 std::vector<std::string> &Paths) {
1367 llvm::Optional<std::string> EnvOpt = llvm::sys::Process::GetEnv(EnvVar);
1368 if (EnvOpt.hasValue()) {
1369 StringRef Env(*EnvOpt);
1370 while (!Env.empty()) {
1373 if (std::find(Paths.begin(), Paths.end(), Arg.str()) == Paths.end())
1374 Paths.push_back(Arg.str());
1380 std::vector<std::string> Paths;
1385 GetEnvVarPath(
"CLING_PREBUILT_MODULE_PATH", Paths);
1387 std::string EnvVarPath;
1388 for (
const std::string&
P : Paths)
1391 gSystem->
Setenv(
"CLING_PREBUILT_MODULE_PATH", EnvVarPath.c_str());
1395 EnvOpt = llvm::sys::Process::GetEnv(
"ROOT_CLING_TIMING");
1396 if (EnvOpt.hasValue())
1397 clingArgsStorage.push_back(
"-ftime-report");
1404 std::vector<std::string> Paths;
1406 GetEnvVarPath(
"CLING_MODULEMAP_PATH", Paths);
1411 for (
const std::string&
P : Paths) {
1413 +
"module.modulemap";
1414 if (!llvm::sys::fs::exists(ModuleMapLoc)) {
1416 ::Info(
"TCling::TCling",
"Modulemap %s does not exist \n",
1417 ModuleMapLoc.c_str());
1422 clingArgsStorage.push_back(
"-fmodule-map-file=" + ModuleMapLoc);
1424 std::string ModulesCachePath;
1425 EnvOpt = llvm::sys::Process::GetEnv(
"CLING_MODULES_CACHE_PATH");
1426 if (EnvOpt.hasValue()){
1427 StringRef Env(*EnvOpt);
1428 assert(llvm::sys::fs::exists(Env) &&
"Path does not exist!");
1429 ModulesCachePath = Env.str();
1434 clingArgsStorage.push_back(
"-fmodules-cache-path=" + ModulesCachePath);
1437 std::vector<const char*> interpArgs;
1438 for (std::vector<std::string>::const_iterator iArg = clingArgsStorage.begin(),
1439 eArg = clingArgsStorage.end(); iArg != eArg; ++iArg)
1440 interpArgs.push_back(iArg->c_str());
1447 if (!fromRootCling) {
1449 interpArgs.push_back(
"-fmodules");
1450 interpArgs.push_back(
"-fno-implicit-module-maps");
1454 interpArgs.push_back(
"-Rmodule-build");
1460 interpArgs.push_back(
"-fno-autolink");
1465 interpArgs.push_back(
"-ffast-math");
1471 extraArgs && *extraArgs; ++extraArgs) {
1472 if (!strcmp(*extraArgs,
"-resource-dir")) {
1474 llvmResourceDir = *(++extraArgs);
1476 interpArgs.push_back(*extraArgs);
1481 interpArgs.push_back(arg.c_str());
1485 cling::Interpreter::ModuleFileExtensions extensions;
1486 EnvOpt = llvm::sys::Process::GetEnv(
"ROOTDEBUG_RDICT");
1487 if (!EnvOpt.hasValue())
1488 extensions.push_back(std::make_shared<TClingRdictModuleFileExtension>());
1490 fInterpreter = llvm::make_unique<cling::Interpreter>(interpArgs.size(),
1492 llvmResourceDir, extensions);
1494 if (!fromRootCling) {
1499 fInterpreter->getCI()->getPreprocessorOpts().DisablePCHValidation =
true;
1503 fInterpreter->getCI()->getLangOpts().SpellChecking =
false;
1508 static llvm::raw_fd_ostream fMPOuts (STDOUT_FILENO,
false);
1528 if (!fromRootCling) {
1538 std::unique_ptr<TClingCallbacks>
1544 if (!fromRootCling) {
1545 cling::DynamicLibraryManager& DLM = *
fInterpreter->getDynamicLibraryManager();
1549 auto ShouldPermanentlyIgnore = [](llvm::StringRef FileName) ->
bool{
1550 llvm::StringRef stem = llvm::sys::path::stem(FileName);
1551 return stem.startswith(
"libNew") || stem.startswith(
"libcppyy_backend");
1554 DLM.initializeDyld(ShouldPermanentlyIgnore);
1592 assert(
GetRootMapFiles() == 0 &&
"Must be called before LoadLibraryMap!");
1611 auto setFactory = []() {
1615 static bool doneFactory = setFactory();
1627 if (llvm::sys::fs::exists(pcmFileNameFullPath)) {
1628 ::Error(
"TCling::RegisterRdictForLoadPCM",
"Rdict '%s' is both in Module extension and in File system.", pcmFileNameFullPath.c_str());
1645 if (listOfKeys && ((listOfKeys->GetSize() == 0) ||
1646 ((listOfKeys->GetSize() == 1) &&
1647 !strcmp(((
TKey *)listOfKeys->At(0))->GetName(),
"EMPTY")
1654 ::Info(
"TCling::LoadPCMImpl",
"reading protoclasses for %s \n", pcmFile.
GetName());
1656 pcmFile.
GetObject(
"__ProtoClasses", protoClasses);
1659 for (
auto obj : *protoClasses) {
1669 for (
auto proto : *protoClasses) {
1677 ::Error(
"TCling::LoadPCM",
"Inconsistent TClassTable for %s",
proto->GetName());
1688 protoClasses->Clear();
1689 delete protoClasses;
1693 pcmFile.
GetObject(
"__Typedefs", dataTypes);
1695 for (
auto typedf : *dataTypes)
1696 gROOT->GetListOfTypes()->Add(typedf);
1705 auto listOfGlobals =
gROOT->GetListOfGlobals();
1706 auto listOfEnums =
dynamic_cast<THashList *
>(
gROOT->GetListOfEnums());
1708 for (
auto selEnum : *enums) {
1709 const char *enumScope = selEnum->
GetTitle();
1710 const char *enumName = selEnum->GetName();
1711 if (strcmp(enumScope,
"") == 0) {
1714 if (!listOfEnums->THashList::FindObject(enumName)) {
1715 ((
TEnum *)selEnum)->SetClass(
nullptr);
1716 listOfEnums->Add(selEnum);
1719 if (!listOfGlobals->FindObject(enumConstant)) {
1720 listOfGlobals->Add(enumConstant);
1727 if (!nsTClassEntry) {
1730 auto listOfEnums = nsTClassEntry->
fEnums.load();
1741 if (listOfEnums && !listOfEnums->THashList::FindObject(enumName)) {
1742 ((
TEnum *)selEnum)->SetClass(nsTClassEntry);
1743 listOfEnums->Add(selEnum);
1759 assert(!pcmFileNameFullPath.empty());
1760 assert(llvm::sys::path::is_absolute(pcmFileNameFullPath));
1763 TString pcmFileName = pcmFileNameFullPath;
1771 llvm::SaveAndRestore<Int_t> SaveGDebug(
gDebug);
1774 ::Info(
"TCling::LoadPCM",
"Loading ROOT PCM %s", pcmFileName.
Data());
1779 if (llvm::sys::fs::is_symlink_file(pcmFileNameFullPath))
1784 llvm::StringRef pcmContent = pendingRdict->second;
1786 std::string RDictFileOpts = pcmFileNameFullPath +
"?filetype=pcm";
1787 TMemFile pcmMemFile(RDictFileOpts.c_str(), range);
1795 if (!llvm::sys::fs::exists(pcmFileNameFullPath)) {
1796 ::Error(
"TCling::LoadPCM",
"ROOT PCM %s file does not exist",
1797 pcmFileNameFullPath.data());
1800 ::Info(
"TCling::LoadPCM",
"In-memory ROOT PCM candidate %s\n",
1801 rdict.first.c_str());
1805 if (!
gROOT->IsRootFile(pcmFileName)) {
1806 Fatal(
"LoadPCM",
"The file %s is not a ROOT as was expected\n", pcmFileName.
Data());
1809 TFile pcmFile(pcmFileName +
"?filetype=pcm",
"READ");
1816 using namespace clang;
1818 class ExtLexicalStorageAdder:
public RecursiveASTVisitor<ExtLexicalStorageAdder>{
1823 bool VisitRecordDecl(clang::RecordDecl* rcd){
1825 Info(
"ExtLexicalStorageAdder",
1826 "Adding external lexical storage to class %s",
1827 rcd->getNameAsString().c_str());
1828 auto reDeclPtr = rcd->getMostRecentDecl();
1830 reDeclPtr->setHasExternalLexicalStorage();
1831 }
while ((reDeclPtr = reDeclPtr->getPreviousDecl()));
1844 const std::string &ModuleMapName )
const
1846 assert(llvm::sys::path::is_absolute(FullPath));
1847 Preprocessor &PP =
fInterpreter->getCI()->getPreprocessor();
1848 FileManager &FM = PP.getFileManager();
1851 const DirectoryEntry *DE = FM.getDirectory(FullPath);
1853 HeaderSearch &HS = PP.getHeaderSearchInfo();
1854 HeaderSearchOptions &HSOpts = HS.getHeaderSearchOpts();
1855 const auto &ModPaths = HSOpts.PrebuiltModulePaths;
1856 bool pathExists = std::find(ModPaths.begin(), ModPaths.end(), FullPath) != ModPaths.end();
1858 HSOpts.AddPrebuiltModulePath(FullPath);
1863 llvm::SmallString<256> ModuleMapFileName(DE->getName());
1864 llvm::sys::path::append(ModuleMapFileName, ModuleMapName);
1865 const FileEntry *FE = FM.getFile(ModuleMapFileName,
false,
1870 if (FE && !this->
IsLoaded(FE->getName().data())) {
1871 if (!HS.loadModuleMapFile(FE,
false))
1873 Error(
"RegisterPrebuiltModulePath",
"Could not load modulemap in %s", ModuleMapFileName.c_str());
1889 "libforward_listDict",
1897 "libunordered_setDict",
1898 "libunordered_multisetDict",
1899 "libunordered_mapDict",
1900 "libunordered_multimapDict",
1908 char dyLibError[1000];
1909 FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
1910 dyLibError,
sizeof(dyLibError), NULL);
1912 const char *dyLibError = dlerror();
1914 ::Error(
"TCling::RegisterModule",
"Cannot open shared library %s for dictionary %s:\n %s", dyLibName, modulename,
1915 (dyLibError) ? dyLibError :
"");
1952 const char** headers,
1953 const char** includePaths,
1954 const char* payloadCode,
1955 const char* fwdDeclsCode,
1956 void (*triggerFunc)(),
1958 const char** classesHeaders,
1959 Bool_t lateRegistration ,
1966 if (fromRootCling)
return;
1975 bool isACLiC = strstr(modulename,
"_ACLiC_dict") !=
nullptr;
1976 if (hasHeaderParsingOnDemand && isACLiC) {
1978 Info(
"TCling::RegisterModule",
1979 "Header parsing on demand is active but this is an Aclic library. Disabling it for this library.");
1980 hasHeaderParsingOnDemand =
false;
1994 for (
const char** inclPath = includePaths; *inclPath; ++inclPath) {
1997 cling::Transaction*
T = 0;
1999 for (
auto& fwdDeclArgToSkipPair : fwdDeclsArgToSkip){
2000 const std::string& fwdDecl = fwdDeclArgToSkipPair.first;
2001 const int nArgsToSkip = fwdDeclArgToSkipPair.second;
2003 assert(cling::Interpreter::kSuccess == compRes &&
2004 "A fwd declaration could not be compiled");
2005 if (compRes!=cling::Interpreter::kSuccess){
2006 Warning(
"TCling::RegisterModule",
2007 "Problems in declaring string '%s' were encountered.",
2022 TString code = gNonInterpreterClassDef;
2024 code += payloadCode;
2026 std::string dyLibName = cling::DynamicLibraryManager::getSymbolLocation(triggerFunc);
2027 assert(!llvm::sys::fs::is_symlink_file(dyLibName));
2029 if (dyLibName.empty()) {
2030 ::Error(
"TCling::RegisterModule",
"Dictionary trigger function for %s not found", modulename);
2035 bool isSharedLib = cling::DynamicLibraryManager::isSharedLibrary(dyLibName);
2037 bool wasDlopened =
false;
2042 if (!lateRegistration) {
2049 void* dyLibHandle = dlopen(dyLibName.c_str(), RTLD_LAZY | RTLD_GLOBAL);
2059 if (hasHeaderParsingOnDemand && fwdDeclsCode){
2062 std::string fwdDeclsCodeLessEnums;
2066 std::string fwdDeclsLine;
2067 std::istringstream fwdDeclsCodeStr(fwdDeclsCode);
2068 std::vector<std::string> scopes;
2069 while (std::getline(fwdDeclsCodeStr, fwdDeclsLine)) {
2070 const auto enumPos = fwdDeclsLine.find(
"enum __attribute__((annotate(\"");
2072 if (enumPos != std::string::npos) {
2079 auto nsPos = fwdDeclsLine.find(
"namespace");
2080 R__ASSERT(nsPos < enumPos &&
"Inconsistent enum and enclosing scope parsing!");
2081 while (nsPos < enumPos && nsPos != std::string::npos) {
2083 const auto nsNameStart = nsPos + 10;
2084 const auto nsNameEnd = fwdDeclsLine.find(
'{', nsNameStart);
2085 const auto nsName = fwdDeclsLine.substr(nsNameStart, nsNameEnd - nsNameStart);
2086 scopes.push_back(nsName);
2087 nsPos = fwdDeclsLine.find(
"namespace", nsNameEnd);
2090 clang::DeclContext* DC = 0;
2091 for (
auto &&aScope: scopes) {
2092 DC = cling::utils::Lookup::Namespace(&
fInterpreter->getSema(), aScope.c_str(), DC);
2098 if (scopes.empty() || DC) {
2100 size_t posEnumName = fwdDeclsLine.find(
"\"))) ", 32);
2101 R__ASSERT(posEnumName != std::string::npos &&
"Inconsistent enum fwd decl!");
2103 while (isspace(fwdDeclsLine[posEnumName]))
2105 size_t posEnumNameEnd = fwdDeclsLine.find(
" : ", posEnumName);
2106 R__ASSERT(posEnumNameEnd != std::string::npos &&
"Inconsistent enum fwd decl (end)!");
2107 while (isspace(fwdDeclsLine[posEnumNameEnd]))
2111 std::string enumName = fwdDeclsLine.substr(posEnumName,
2112 posEnumNameEnd - posEnumName + 1);
2114 if (clang::NamedDecl* enumDecl
2115 = cling::utils::Lookup::Named(&
fInterpreter->getSema(),
2116 enumName.c_str(), DC)) {
2119 R__ASSERT(llvm::dyn_cast<clang::EnumDecl>(enumDecl) &&
"not an enum decl!");
2126 fwdDeclsCodeLessEnums += fwdDeclsLine +
"\n";
2130 if (fwdDeclsCodeLessEnums.size() != 0){
2131 auto compRes =
fInterpreter->declare(fwdDeclsCodeLessEnums, &
T);
2132 assert(cling::Interpreter::kSuccess == compRes &&
2133 "The forward declarations could not be compiled");
2134 if (compRes!=cling::Interpreter::kSuccess){
2135 Warning(
"TCling::RegisterModule",
2136 "Problems in compiling forward declarations for module %s: '%s'",
2137 modulename, fwdDeclsCodeLessEnums.c_str()) ;
2145 ExtLexicalStorageAdder elsa;
2146 for (
auto dciIt =
T->decls_begin();dciIt!=
T->decls_end();dciIt++){
2147 cling::Transaction::DelayCallInfo& dci = *dciIt;
2148 for(
auto dit = dci.m_DGR.begin(); dit != dci.m_DGR.end(); ++dit) {
2149 clang::Decl* declPtr = *dit;
2150 elsa.TraverseDecl(declPtr);
2164 for (
const char** classesHeader = classesHeaders; *classesHeader; ++classesHeader) {
2165 temp=*classesHeader;
2167 size_t theTemplateHash = 0;
2168 bool addTemplate =
false;
2169 size_t posTemplate = temp.find(
'<');
2170 if (posTemplate != std::string::npos) {
2172 std::string templateName = temp.substr(0, posTemplate);
2178 for (
const char** classesHeader_inner = classesHeader; 0!=strcmp(*classesHeader_inner,
"@"); ++classesHeader_inner,++classesHeader){
2180 if (payloadCode == *classesHeader_inner ){
2182 if (addTemplate)
fPayloads.insert(theTemplateHash);
2185 Info(
"TCling::RegisterModule",
2186 "Adding a header for %s", temp.c_str());
2192 addTemplate =
false;
2200 bool ModuleWasSuccessfullyLoaded =
false;
2202 std::string ModuleName = modulename;
2203 if (llvm::StringRef(modulename).startswith(
"lib"))
2204 ModuleName = llvm::StringRef(modulename).substr(3).str();
2209 clang::Preprocessor &PP = TheSema.getPreprocessor();
2210 std::string ModuleMapName;
2212 ModuleMapName = ModuleName +
".modulemap";
2214 ModuleMapName =
"module.modulemap";
2221 if (!ModuleWasSuccessfullyLoaded) {
2223 clang::HeaderSearch &headerSearch = PP.getHeaderSearchInfo();
2224 clang::ModuleMap &moduleMap = headerSearch.getModuleMap();
2225 if (moduleMap.findModule(ModuleName))
2226 Info(
"TCling::RegisterModule",
"Module %s in modulemap failed to load.", ModuleName.c_str());
2231 llvm::SmallString<256> pcmFileNameFullPath(dyLibName);
2234 llvm::sys::fs::make_absolute(pcmFileNameFullPath);
2235 llvm::sys::path::remove_filename(pcmFileNameFullPath);
2236 llvm::sys::path::append(pcmFileNameFullPath,
2238 LoadPCM(pcmFileNameFullPath.str().str());
2245 clangDiagSuppr diagSuppr(TheSema.getDiagnostics());
2247#if defined(R__MUST_REVISIT)
2248#if R__MUST_REVISIT(6,2)
2249 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
2253 if (!ModuleWasSuccessfullyLoaded && !hasHeaderParsingOnDemand){
2256 const cling::Transaction* watermark =
fInterpreter->getLastTransaction();
2257 cling::Interpreter::CompilationResult compRes =
fInterpreter->parseForModule(code.
Data());
2263 assert(cling::Interpreter::kSuccess == compRes &&
2264 "Payload code of a dictionary could not be parsed correctly.");
2265 if (compRes!=cling::Interpreter::kSuccess) {
2266 Warning(
"TCling::RegisterModule",
2267 "Problems declaring payload for module %s.", modulename) ;
2280 if (!ModuleWasSuccessfullyLoaded && !hasHeaderParsingOnDemand) {
2283 "#undef __ROOTCLING__\n"
2284 + gInterpreterClassDef +
2289 assert(isSharedLib);
2292 dlclose(dyLibHandle);
2312 typedef std::vector<std::pair<TClass*,DictFuncPtr_t> >::iterator iterator;
2318 if ( i->first == oldcl ) {
2341 const char* input_line,
2342 cling::Interpreter::CompilationResult& compRes,
2346 return metaProcessor->process(input_line, compRes, result);
2348 catch (cling::InterpreterException&
ex)
2350 Error(
"HandleInterpreterException",
"%s.\n%s",
ex.what(),
"Execution of your code was aborted.");
2352 compRes = cling::Interpreter::kFailure;
2361 if (
auto ie =
dynamic_cast<const cling::InterpreterException*
>(&
e)) {
2387 gROOT->SetLineIsProcessing();
2391 gROOT->SetLineHasBeenProcessed();
2404 gROOT->SetLineIsProcessing();
2406 struct InterpreterFlagsRAII {
2408 bool fWasDynamicLookupEnabled;
2410 InterpreterFlagsRAII(cling::Interpreter* interp):
2412 fWasDynamicLookupEnabled(interp->isDynamicLookupEnabled())
2416 ~InterpreterFlagsRAII() {
2417 fInterpreter->enableDynamicLookup(fWasDynamicLookupEnabled);
2418 gROOT->SetLineHasBeenProcessed();
2427 cling::Interpreter::CompilationResult compRes = cling::Interpreter::kSuccess;
2428 if (!strncmp(sLine.
Data(),
".L", 2) || !strncmp(sLine.
Data(),
".x", 2) ||
2429 !strncmp(sLine.
Data(),
".X", 2)) {
2437 aclicMode, arguments, io);
2438 if (aclicMode.
Length()) {
2440 R__ASSERT(aclicMode[0]==
'+' &&
"ACLiC mode must start with a +");
2442 if (aclicMode[1]==
'+') {
2448 compRes = cling::Interpreter::kFailure;
2450 if (strncmp(sLine.
Data(),
".L", 2) != 0) {
2453 if (arguments.
Length()==0) {
2462 mod_line =
function + arguments + io;
2468 size_t unnamedMacroOpenCurly;
2471 std::string codeline;
2472 std::ifstream in(fname);
2474 std::getline(in, codeline);
2475 code += codeline +
"\n";
2477 unnamedMacroOpenCurly
2478 = cling::utils::isUnnamedMacro(code,
fInterpreter->getCI()->getLangOpts());
2482 if (unnamedMacroOpenCurly != std::string::npos) {
2484 unnamedMacroOpenCurly);
2494 if (0!=strncmp(sLine.
Data(),
".autodict ",10) && sLine !=
".autodict") {
2499 bool isInclusionDirective = sLine.
Contains(
"\n#include") || sLine.
BeginsWith(
"#include");
2500 if (isInclusionDirective) {
2508 if (result.isValid())
2517 case cling::Interpreter::kSuccess: *error =
kNoError;
break;
2518 case cling::Interpreter::kFailure: *error =
kRecoverable;
break;
2519 case cling::Interpreter::kMoreInputExpected: *error =
kProcessing;
break;
2522 if (compRes == cling::Interpreter::kSuccess
2524 && !result.isVoid())
2526 return result.simplisticCastAs<
long>();
2548 if (path[0] ==
'-' && path[1] ==
'I')
2572 static const TClassRef clRefString(
"std::string");
2573 if (clRefString == cl) {
2583 const char* cobj = (
const char*) obj;
2590 auto inspInspect = [&] (ptrdiff_t offset){
2596 switch(complexType) {
2603 inspInspect(
sizeof(
float));
2608 inspInspect(
sizeof(
double));
2613 inspInspect(
sizeof(
int));
2618 inspInspect(
sizeof(
long));
2623 static clang::PrintingPolicy
2625 if (printPol.Indentation) {
2627 printPol.Indentation = 0;
2628 printPol.SuppressInitializers =
true;
2631 const char* clname = cl->
GetName();
2634 const clang::ASTContext& astContext =
fInterpreter->getCI()->getASTContext();
2635 const clang::Decl *scopeDecl = 0;
2640 scopeDecl = clingCI->
GetDecl();
2641 recordType = clingCI->
GetType();
2643 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
2645 scopeDecl = lh.findScope(clname, cling::LookupHelper::NoDiagnostics,
2649 Error(
"InspectMembers",
"Cannot find Decl for class %s", clname);
2652 const clang::CXXRecordDecl* recordDecl
2653 = llvm::dyn_cast<const clang::CXXRecordDecl>(scopeDecl);
2655 Error(
"InspectMembers",
"Cannot find Decl for class %s is not a CXXRecordDecl.", clname);
2664 astContext.getASTRecordLayout(recordDecl);
2666 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2667 eField = recordDecl->field_end(); iField != eField; ++iField) {}
2670 const clang::ASTRecordLayout& recLayout
2671 = astContext.getASTRecordLayout(recordDecl);
2678 if (cl->
Size() != recLayout.getSize().getQuantity()) {
2679 Error(
"InspectMembers",
"TClass and cling disagree on the size of the class %s, respectively %d %lld\n",
2683 unsigned iNField = 0;
2686 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2687 eField = recordDecl->field_end(); iField != eField;
2688 ++iField, ++iNField) {
2691 clang::QualType memberQT = iField->getType();
2696 memberQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, memberQT,
fNormalizedCtxt->
GetConfig(),
false );
2697 if (memberQT.isNull()) {
2698 std::string memberName;
2699 llvm::raw_string_ostream stream(memberName);
2701 printPol.AnonymousTagLocations =
false;
2702 iField->getNameForDiagnostic(stream, printPol,
true );
2704 Error(
"InspectMembers",
2705 "Cannot retrieve QualType for member %s while inspecting class %s",
2706 memberName.c_str(), clname);
2709 const clang::Type* memType = memberQT.getTypePtr();
2711 std::string memberName;
2712 llvm::raw_string_ostream stream(memberName);
2714 printPol.AnonymousTagLocations =
false;
2715 iField->getNameForDiagnostic(stream, printPol,
true );
2717 Error(
"InspectMembers",
2718 "Cannot retrieve Type for member %s while inspecting class %s",
2719 memberName.c_str(), clname);
2724 Bool_t ispointer =
false;
2725 if (memNonPtrType->isPointerType()) {
2727 clang::QualType ptrQT
2728 = memNonPtrType->getAs<clang::PointerType>()->getPointeeType();
2733 ptrQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, ptrQT,
fNormalizedCtxt->
GetConfig(),
false );
2734 if (ptrQT.isNull()) {
2735 std::string memberName;
2736 llvm::raw_string_ostream stream(memberName);
2738 printPol.AnonymousTagLocations =
false;
2739 iField->getNameForDiagnostic(stream, printPol,
true );
2741 Error(
"InspectMembers",
2742 "Cannot retrieve pointee Type for member %s while inspecting class %s",
2743 memberName.c_str(), clname);
2746 memNonPtrType = ptrQT.getTypePtr();
2750 llvm::SmallString<8> arraySize;
2751 const clang::ArrayType* arrType = memNonPtrType->getAsArrayTypeUnsafe();
2752 unsigned arrLevel = 0;
2753 bool haveErrorDueToArray =
false;
2757 const clang::ConstantArrayType* constArrType =
2758 clang::dyn_cast<clang::ConstantArrayType>(arrType);
2760 constArrType->getSize().toStringUnsigned(arraySize);
2763 clang::QualType subArrQT = arrType->getElementType();
2764 if (subArrQT.isNull()) {
2765 std::string memberName;
2766 llvm::raw_string_ostream stream(memberName);
2768 printPol.AnonymousTagLocations =
false;
2769 iField->getNameForDiagnostic(stream, printPol,
true );
2771 Error(
"InspectMembers",
2772 "Cannot retrieve QualType for array level %d (i.e. element type of %s) for member %s while inspecting class %s",
2773 arrLevel, subArrQT.getAsString(printPol).c_str(),
2774 memberName.c_str(), clname);
2775 haveErrorDueToArray =
true;
2778 arrType = subArrQT.getTypePtr()->getAsArrayTypeUnsafe();
2780 if (haveErrorDueToArray) {
2785 std::string fieldName;
2786 if (memType->isPointerType()) {
2791 std::string
ioname(iField->getName());
2794 fieldName += arraySize;
2799 clang::CharUnits offset(astContext.toCharUnitsFromBits(recLayout.getFieldOffset(iNField)));
2800 ptrdiff_t fieldOffset = offset.getQuantity();
2810 auto iFiledQtype = iField->getType();
2811 if (
auto tagDecl = iFiledQtype->getAsTagDecl()){
2812 auto declAccess = tagDecl->getAccess();
2813 if (declAccess == AS_private || declAccess == AS_protected) {
2819 insp.
Inspect(
const_cast<TClass*
>(cl), insp.
GetParent(), fieldName.c_str(), cobj + fieldOffset, isTransient);
2822 const clang::CXXRecordDecl* fieldRecDecl = memNonPtrType->getAsCXXRecordDecl();
2823 if (fieldRecDecl && !fieldRecDecl->isAnonymousStructOrUnion()) {
2826 std::string sFieldRecName;
2829 clang::QualType(memNonPtrType,0),
2839 insp.
InspectMember(sFieldRecName.c_str(), cobj + fieldOffset,
2848 unsigned iNBase = 0;
2849 for (clang::CXXRecordDecl::base_class_const_iterator iBase
2850 = recordDecl->bases_begin(), eBase = recordDecl->bases_end();
2851 iBase != eBase; ++iBase, ++iNBase) {
2852 clang::QualType baseQT = iBase->getType();
2853 if (baseQT.isNull()) {
2854 Error(
"InspectMembers",
2855 "Cannot find QualType for base number %d while inspecting class %s",
2859 const clang::CXXRecordDecl* baseDecl
2860 = baseQT->getAsCXXRecordDecl();
2862 Error(
"InspectMembers",
2863 "Cannot find CXXRecordDecl for base number %d while inspecting class %s",
2868 std::string sBaseName;
2870 std::vector<TClass*> foundClasses;
2872 if (foundClasses.size()==1){
2873 baseCl=foundClasses[0];
2886 std::string qualNameForDiag;
2888 Error(
"InspectMembers",
2889 "Cannot find TClass for base class %s", qualNameForDiag.c_str() );
2894 if (iBase->isVirtual()) {
2897 Error(
"InspectMembers",
2898 "Base %s of class %s is virtual but no object provided",
2899 sBaseName.c_str(), clname);
2907 baseOffset = ci->
GetBaseOffset(baseCi,
const_cast<void*
>(obj),
2909 if (baseOffset == -1) {
2910 Error(
"InspectMembers",
2911 "Error calculating offset of virtual base %s of class %s",
2912 sBaseName.c_str(), clname);
2915 Error(
"InspectMembers",
2916 "Cannot calculate offset of virtual base %s of class %s",
2917 sBaseName.c_str(), clname);
2922 baseOffset = recLayout.getBaseClassOffset(baseDecl).getQuantity();
2969 bool oldDynLookup =
fInterpreter->isDynamicLookupEnabled();
2998 return fInterpreter->getDynamicLibraryManager()->isLibraryLoaded(tLibName.
Data());
3013 llvm::StringRef ModuleName(libname);
3014 ModuleName = llvm::sys::path::stem(ModuleName);
3015 ModuleName.consume_front(
"lib");
3023 clang::ModuleMap &moduleMap =
fInterpreter->getCI()->getPreprocessor().getHeaderSearchInfo().getModuleMap();
3024 clang::Module *M = moduleMap.findModule(ModuleName);
3025 return M && !M->IsMissingRequirement && M->getASTFile();
3043 std::string file_name = filename;
3044 size_t at = std::string::npos;
3045 while ((at = file_name.find(
"/./")) != std::string::npos)
3046 file_name.replace(at, 3,
"/");
3048 std::string filesStr =
"";
3049 llvm::raw_string_ostream filesOS(filesStr);
3050 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
3051 cling::ClangInternalState::printIncludedFiles(filesOS, SM);
3054 llvm::SmallVector<llvm::StringRef, 100> files;
3055 llvm::StringRef(filesStr).split(files,
"\n");
3057 std::set<std::string> fileMap;
3059 for (llvm::SmallVector<llvm::StringRef, 100>::const_iterator
3060 iF = files.begin(), iE = files.end(); iF != iE; ++iF) {
3061 if ((*iF) == file_name.c_str())
return kTRUE;
3062 fileMap.insert(*iF);
3065 if (fileMap.empty())
return kFALSE;
3068 TString sFilename(file_name.c_str());
3070 && fileMap.count(sFilename.
Data())) {
3078 while (incPath.
Index(
" :") != -1) {
3082 sFilename = file_name.c_str();
3084 && fileMap.count(sFilename.
Data())) {
3093 const clang::DirectoryLookup *CurDir = 0;
3094 clang::Preprocessor &PP =
fInterpreter->getCI()->getPreprocessor();
3095 clang::HeaderSearch &HS = PP.getHeaderSearchInfo();
3096 const clang::FileEntry *FE = HS.LookupFile(file_name.c_str(),
3097 clang::SourceLocation(),
3100 clang::ArrayRef<std::pair<
const clang::FileEntry *,
3101 const clang::DirectoryEntry *>>(),
3111 if (FE && FE->isValid()) {
3113 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
3115 clang::FileID FID = SM.translateFile(FE);
3116 if (!FID.isInvalid() && FID.getHashValue() == 0)
3119 clang::SrcMgr::SLocEntry SLocE = SM.getSLocEntry(FID);
3120 if (SLocE.isFile() && SLocE.getFile().getContentCache()->getRawBuffer() == 0)
3122 if (!FID.isInvalid())
3126 sFilename = FE->getName();
3128 && fileMap.count(sFilename.
Data())) {
3136#if defined(R__MACOSX)
3144static bool R__UpdateLibFileForLinking(
TString &lib)
3146 const char *mapfile =
nullptr;
3148 mapfile =
"/System/Library/dyld/dyld_shared_cache_x86_64.map";
3150 mapfile =
"/System/Library/dyld/dyld_shared_cache_arm64e.map";
3152 #error unsupported architecture
3154 if (std::ifstream cacheMap{mapfile}) {
3156 while (getline(cacheMap,
line)) {
3157 if (
line.find(lib) != std::string::npos) {
3175static int callback_for_dl_iterate_phdr(
struct dl_phdr_info *info,
size_t size,
void *data)
3178 static std::unordered_set<
decltype(info->dlpi_addr)> sKnownLoadedLibBaseAddrs;
3180 auto newLibs =
static_cast<std::vector<std::string>*
>(data);
3181 if (!sKnownLoadedLibBaseAddrs.count(info->dlpi_addr)) {
3183 if (info->dlpi_name && info->dlpi_name[0]
3184 && strncmp(info->dlpi_name,
"linux-vdso.so", 13)
3185 && strncmp(info->dlpi_name,
"linux-gate.so", 13))
3186 newLibs->emplace_back(info->dlpi_name);
3187 sKnownLoadedLibBaseAddrs.insert(info->dlpi_addr);
3200#if defined(R__WIN32) || defined(__CYGWIN__)
3201 HMODULE hModules[1024];
3203 unsigned long cbModules;
3205 hProcess = (
void *)::GetCurrentProcess();
3206 ::EnumProcessModules(hProcess, hModules,
sizeof(hModules), &cbModules);
3208 for (i = 1; i < (cbModules /
sizeof(
void *)); i++) {
3209 static const int bufsize = 260;
3210 wchar_t winname[bufsize];
3211 char posixname[bufsize];
3212 ::GetModuleFileNameExW(hProcess, hModules[i], winname, bufsize);
3213#if defined(__CYGWIN__)
3214 cygwin_conv_path(CCP_WIN_W_TO_POSIX, winname, posixname, bufsize);
3216 std::wstring wpath = winname;
3217 std::replace(wpath.begin(), wpath.end(),
'\\',
'/');
3218 string path(wpath.begin(), wpath.end());
3219 strncpy(posixname, path.c_str(), bufsize);
3225#elif defined(R__MACOSX)
3229 while (
const mach_header* mh = _dyld_get_image_header(imageIndex)) {
3231 if (mh->filetype == MH_DYLIB) {
3232 if (
const char* imageName = _dyld_get_image_name(imageIndex)) {
3240#elif defined(R__LINUX)
3244 std::vector<std::string> newLibs;
3245 dl_iterate_phdr(callback_for_dl_iterate_phdr, &newLibs);
3246 for (
auto &&lib: newLibs)
3249 Error(
"TCling::UpdateListOfLoadedSharedLibraries",
3250 "Platform not supported!");
3261 if (!filename)
return;
3265 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
3266 if (!DLM->isLibraryLoaded(filename)) {
3267 DLM->loadLibrary(filename,
true );
3270#if defined(R__MACOSX)
3272 auto lenFilename = strlen(filename);
3273 if (!strncmp(filename,
"/usr/lib/system/", 16)
3274 || !strncmp(filename,
"/usr/lib/libc++", 15)
3275 || !strncmp(filename,
"/System/Library/Frameworks/", 27)
3276 || !strncmp(filename,
"/System/Library/PrivateFrameworks/", 34)
3277 || !strncmp(filename,
"/System/Library/CoreServices/", 29)
3278 || !strcmp(filename,
"cl_kernels")
3279 || strstr(filename,
"/usr/lib/libSystem")
3280 || strstr(filename,
"/usr/lib/libstdc++")
3281 || strstr(filename,
"/usr/lib/libicucore")
3282 || strstr(filename,
"/usr/lib/libbsm")
3283 || strstr(filename,
"/usr/lib/libobjc")
3284 || strstr(filename,
"/usr/lib/libresolv")
3285 || strstr(filename,
"/usr/lib/libauto")
3286 || strstr(filename,
"/usr/lib/libcups")
3287 || strstr(filename,
"/usr/lib/libDiagnosticMessagesClient")
3288 || strstr(filename,
"/usr/lib/liblangid")
3289 || strstr(filename,
"/usr/lib/libCRFSuite")
3290 || strstr(filename,
"/usr/lib/libpam")
3291 || strstr(filename,
"/usr/lib/libOpenScriptingUtil")
3292 || strstr(filename,
"/usr/lib/libextension")
3293 || strstr(filename,
"/usr/lib/libAudioToolboxUtility")
3294 || strstr(filename,
"/usr/lib/liboah")
3295 || strstr(filename,
"/usr/lib/libRosetta")
3299 || (lenFilename > 4 && !strcmp(filename + lenFilename - 4,
".tbd")))
3302 R__UpdateLibFileForLinking(sFileName);
3303 filename = sFileName.
Data();
3304#elif defined(__CYGWIN__)
3306 static const int bufsize = 260;
3307 char posixwindir[bufsize];
3308 char *windir = getenv(
"WINDIR");
3310 cygwin_conv_path(CCP_WIN_A_TO_POSIX, windir, posixwindir, bufsize);
3312 snprintf(posixwindir,
sizeof(posixwindir),
"/Windows/");
3313 if (strstr(filename, posixwindir) ||
3314 strstr(filename,
"/usr/bin/cyg"))
3316#elif defined(R__WIN32)
3317 if (strstr(filename,
"/Windows/"))
3319#elif defined (R__LINUX)
3320 if (strstr(filename,
"/ld-linux")
3321 || strstr(filename,
"linux-gnu/")
3322 || strstr(filename,
"/libstdc++.")
3323 || strstr(filename,
"/libgcc")
3324 || strstr(filename,
"/libc.")
3325 || strstr(filename,
"/libdl.")
3326 || strstr(filename,
"/libm."))
3343 assert(!
IsFromRootCling() &&
"Trying to load library from rootcling!");
3347 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
3348 std::string canonLib = DLM->lookupLibrary(filename);
3349 cling::DynamicLibraryManager::LoadLibResult res
3350 = cling::DynamicLibraryManager::kLoadLibNotFound;
3351 if (!canonLib.empty()) {
3353 res = DLM->loadLibrary(filename, system);
3357 cling::Interpreter::CompilationResult compRes;
3359 if (compRes == cling::Interpreter::kSuccess)
3360 res = cling::DynamicLibraryManager::kLoadLibSuccess;
3364 if (res == cling::DynamicLibraryManager::kLoadLibSuccess) {
3368 case cling::DynamicLibraryManager::kLoadLibSuccess:
return 0;
3369 case cling::DynamicLibraryManager::kLoadLibAlreadyLoaded:
return 1;
3419 Warning(
"Calc",
"waiting for cling thread to free");
3422 gROOT->SetLineIsProcessing();
3430 cling::Interpreter::CompilationResult cr =
fInterpreter->evaluate(
line, valRef);
3431 if (cr != cling::Interpreter::kSuccess) {
3439 if (!valRef.isValid()) {
3448 if (valRef.isVoid()) {
3455 gROOT->SetLineHasBeenProcessed();
3458 return valRef.simplisticCastAs<
long>();
3465 void (*histaddFunc)(
const char*
line))
3470#if defined(R__MUST_REVISIT)
3471#if R__MUST_REVISIT(6,2)
3472 Warning(
"SetGetline",
"Cling should support the equivalent of SetGetlineFunc(getlineFunc, histaddFunc)");
3485 if ((std::distance(
T.decls_begin(),
T.decls_end()) != 1)
3486 ||
T.deserialized_decls_begin() !=
T.deserialized_decls_end()
3487 ||
T.macros_begin() !=
T.macros_end()
3488 || ((!
T.getFirstDecl().isNull()) && ((*
T.getFirstDecl().begin()) !=
T.getWrapperFD()))) {
3511 std::set<TObject*>::iterator iSpecial = ((std::set<TObject*>*)
fgSetOfSpecials)->find(obj);
3529#if defined(R__MUST_REVISIT)
3530#if R__MUST_REVISIT(6,2)
3532 Warning(
"Reset",
"Cling should support the equivalent of scratch_upto(&fDictPos)");
3542#if defined(R__MUST_REVISIT)
3543#if R__MUST_REVISIT(6,2)
3545 Warning(
"ResetAll",
"Cling should support the equivalent of complete reset (unload everything but the startup decls.");
3572#if defined(R__MUST_REVISIT)
3573#if R__MUST_REVISIT(6,2)
3575 Warning(
"ResetGlobalVar",
"Cling should support the equivalent of resetglobalvar(obj)");
3587#if defined(R__MUST_REVISIT)
3588#if R__MUST_REVISIT(6,2)
3590 Warning(
"RewindDictionary",
"Cling should provide a way to revert transaction similar to rewinddictionary()");
3601#if defined(R__MUST_REVISIT)
3602#if R__MUST_REVISIT(6,2)
3604 Warning(
"DeleteGlobal",
"Cling should provide the equivalent of deleteglobal(obj), see also DeleteVariable.");
3616#if defined(R__MUST_REVISIT)
3617#if R__MUST_REVISIT(6,2)
3618 Warning(
"DeleteVariable",
"should do more that just reseting the value to zero");
3623 llvm::StringRef srName(
name);
3624 const char* unscopedName =
name;
3625 llvm::StringRef::size_type posScope = srName.rfind(
"::");
3626 const clang::DeclContext* declCtx = 0;
3627 if (posScope != llvm::StringRef::npos) {
3628 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
3629 const clang::Decl* scopeDecl
3630 = lh.findScope(srName.substr(0, posScope),
3631 cling::LookupHelper::WithDiagnostics);
3633 Error(
"DeleteVariable",
"Cannot find enclosing scope for variable %s",
3637 declCtx = llvm::dyn_cast<clang::DeclContext>(scopeDecl);
3639 Error(
"DeleteVariable",
3640 "Enclosing scope for variable %s is not a declaration context",
3644 unscopedName += posScope + 2;
3648 clang::NamedDecl* nVarDecl
3649 = cling::utils::Lookup::Named(&
fInterpreter->getSema(), unscopedName, declCtx);
3651 Error(
"DeleteVariable",
"Unknown variable %s",
name);
3654 clang::VarDecl* varDecl = llvm::dyn_cast<clang::VarDecl>(nVarDecl);
3656 Error(
"DeleteVariable",
"Entity %s is not a variable",
name);
3660 clang::QualType qType = varDecl->getType();
3664 if (
type->isPointerType()) {
3665 int** ppInt = (
int**)
fInterpreter->getAddressOfGlobal(GlobalDecl(varDecl));
3667 if (ppInt) *ppInt = 0;
3677#if defined(R__MUST_REVISIT)
3678#if R__MUST_REVISIT(6,2)
3680 Warning(
"SaveContext",
"Cling should provide a way to record a state watermark similar to store_dictposition(&fDictPos)");
3690#if defined(R__MUST_REVISIT)
3691#if R__MUST_REVISIT(6,2)
3693 Warning(
"SaveGlobalsContext",
"Cling should provide a way to record a watermark for the list of global variable similar to store_dictposition(&fDictPosGlobals)");
3727struct AlternateTupleIntDoubleAsc
3733struct AlternateTupleIntDoubleDes
3741 std::tuple<int,double> value;
3742 AlternateTupleIntDoubleAsc asc;
3743 AlternateTupleIntDoubleDes des;
3745 size_t offset0 = ((
char*)&(std::get<0>(value))) - ((
char*)&value);
3746 size_t offset1 = ((
char*)&(std::get<1>(value))) - ((
char*)&value);
3748 size_t ascOffset0 = ((
char*)&(asc._0)) - ((
char*)&asc);
3749 size_t ascOffset1 = ((
char*)&(asc._1)) - ((
char*)&asc);
3751 size_t desOffset0 = ((
char*)&(des._0)) - ((
char*)&des);
3752 size_t desOffset1 = ((
char*)&(des._1)) - ((
char*)&des);
3754 if (offset0 == ascOffset0 && offset1 == ascOffset1) {
3756 }
else if (offset0 == desOffset0 && offset1 == desOffset1) {
3763static std::string
AlternateTuple(
const char *classname,
const cling::LookupHelper& lh)
3766 std::string alternateName =
"TEmulatedTuple";
3767 alternateName.append( classname + 5 );
3769 std::string fullname =
"ROOT::Internal::" + alternateName;
3770 if (lh.findScope(fullname, cling::LookupHelper::NoDiagnostics,
3774 std::string guard_name;
3776 std::ostringstream guard;
3777 guard <<
"ROOT_INTERNAL_TEmulated_";
3778 guard << guard_name;
3780 std::ostringstream alternateTuple;
3781 alternateTuple <<
"#ifndef " << guard.str() <<
"\n";
3782 alternateTuple <<
"#define " << guard.str() <<
"\n";
3783 alternateTuple <<
"namespace ROOT { namespace Internal {\n";
3784 alternateTuple <<
"template <class... Types> struct TEmulatedTuple;\n";
3785 alternateTuple <<
"template <> struct " << alternateName <<
" {\n";
3790 unsigned int nMember = 0;
3791 auto iter = tupleContent.
fElements.begin() + 1;
3792 auto theEnd = tupleContent.
fElements.end() - 1;
3793 while (iter != theEnd) {
3794 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
3801 unsigned int nMember = tupleContent.
fElements.size() - 3;
3802 auto iter = tupleContent.
fElements.rbegin() + 1;
3803 auto theEnd = tupleContent.
fElements.rend() - 1;
3804 while (iter != theEnd) {
3805 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
3812 Fatal(
"TCling::SetClassInfo::AlternateTuple",
3813 "Layout of std::tuple on this platform is unexpected.");
3818 alternateTuple <<
"};\n";
3819 alternateTuple <<
"}}\n";
3820 alternateTuple <<
"#endif\n";
3822 Error(
"Load",
"Could not declare %s",alternateName.c_str());
3825 alternateName =
"ROOT::Internal::" + alternateName;
3826 return alternateName;
3869 if (strncmp(cl->
GetName(),
"tuple<",strlen(
"tuple<"))==0) {
3905 zombieCandidate =
kTRUE;
3912 zombieCandidate =
kTRUE;
3966 static const char *anonEnum =
"anonymous enum ";
3967 static const int cmplen = strlen(anonEnum);
3994 const char *classname =
name;
3997 class MaybeSuspendAutoLoadParse {
3998 int fStoreAutoLoad = 0;
3999 int fStoreAutoParse = 0;
4000 bool fSuspendedAutoParse =
false;
4002 MaybeSuspendAutoLoadParse(
int autoload) {
4003 fStoreAutoLoad = ((
TCling*)
gCling)->SetClassAutoLoading(autoload);
4007 fSuspendedAutoParse =
true;
4008 fStoreAutoParse = ((
TCling*)
gCling)->SetSuspendAutoParsing(
true);
4011 ~MaybeSuspendAutoLoadParse() {
4012 if (fSuspendedAutoParse)
4013 ((
TCling*)
gCling)->SetSuspendAutoParsing(fStoreAutoParse);
4014 ((
TCling*)
gCling)->SetClassAutoLoading(fStoreAutoLoad);
4018 MaybeSuspendAutoLoadParse autoLoadParseRAII( autoload );
4020 autoLoadParseRAII.SuspendAutoParsing();
4029 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
4031 const clang::Decl *decl
4032 = lh.findScope(classname,
4033 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4034 : cling::LookupHelper::NoDiagnostics,
4038 decl = lh.findScope(buf,
4039 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4040 : cling::LookupHelper::NoDiagnostics,
4057 clang::ClassTemplateSpecializationDecl *tmpltDecl =
4058 llvm::dyn_cast_or_null<clang::ClassTemplateSpecializationDecl>
4059 (
type->getAsCXXRecordDecl());
4060 if (tmpltDecl && !tmpltDecl->getPointOfInstantiation().isValid()) {
4077 if (tci.
Property() & propertiesMask) {
4078 bool hasClassDefInline =
false;
4079 if (isClassOrNamespaceOnly) {
4085 if (hasDictionary.IsValid() && implLineFunc.IsValid()) {
4087 bool success =
false;
4088 std::tie(success, lineNumber) =
4090 hasClassDefInline = success && (lineNumber == -1);
4098 if (hasClassDefInline)
4137 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
4138 const clang::Decl *decl
4139 = lh.findClassTemplate(
name,
4140 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4141 : cling::LookupHelper::NoDiagnostics);
4143 std::string strname =
"std::";
4145 decl = lh.findClassTemplate(strname,
4146 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4147 : cling::LookupHelper::NoDiagnostics);
4173 cl->
fBase = listOfBase;
4189 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
4192 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
4195 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
4196 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
4197 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(), declEnd = allDeclContexts.end();
4198 declIter != declEnd; ++declIter) {
4200 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
4201 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
4202 if (
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(*DI)) {
4205 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
4206 llvm::raw_string_ostream stream(buf);
4208 Policy.AnonymousTagLocations =
false;
4209 ED->getNameForDiagnostic(stream, Policy,
false);
4213 const char*
name = buf.c_str();
4237 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
4241 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
4244 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
4245 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
4246 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(),
4247 declEnd = allDeclContexts.end(); declIter != declEnd; ++declIter) {
4249 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
4250 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
4251 if (
const clang::FunctionTemplateDecl* FTD = dyn_cast<clang::FunctionTemplateDecl>(*DI)) {
4252 funcTempList->
Get(FTD);
4310 if (
m->fMethodArgs) {
4321 m->fMethodArgs = arglist;
4361 if (llvm::isa<clang::NamespaceDecl>(cli->
GetDecl())) {
4370 Error(
"GenerateTClass",
4371 "Cannot find %s::Class_Version()! Class version might be wrong.",
4378 if (newvers == -1) {
4386 newvers = callfunc.
ExecInt(0);
4388 Error(
"GenerateTClass",
4389 "Cannot invoke %s::Class_Version()! Class version might be wrong.",
4393 if (newvers != oldvers) {
4410static void GenerateTClass_GatherInnerIncludes(cling::Interpreter *interp,
TString &includes,
TClingClassInfo *info)
4414 const clang::ClassTemplateSpecializationDecl *templateCl
4415 = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(info->
GetDecl());
4417 for(
unsigned int i=0; i < templateCl->getTemplateArgs().size(); ++i) {
4418 const clang::TemplateArgument &arg( templateCl->getTemplateArgs().get(i) );
4422 if (!uType->isFundamentalType() && !uType->isEnumeralType()) {
4424 const clang::CXXRecordDecl *argdecl = uType->getAsCXXRecordDecl();
4427 TClingClassInfo subinfo(interp,*(argdecl->getASTContext().getRecordType(argdecl).getTypePtr()));
4428 GenerateTClass_GatherInnerIncludes(interp, includes, &subinfo);
4431 llvm::raw_string_ostream OS(Result);
4432 arg.print(argdecl->getASTContext().getPrintingPolicy(),OS);
4433 Warning(
"TCling::GenerateTClass",
"Missing header file for %s",OS.str().c_str());
4448 if (!info || !info->
IsValid()) {
4449 Fatal(
"GenerateTClass",
"Requires a valid ClassInfo object");
4454 std::string classname;
4458 Info(
"GenerateTClass",
"Will (try to) generate the compiled TClass for %s.",classname.c_str());
4462 GenerateTClass_GatherInnerIncludes(
fInterpreter,includes,info);
4468 Error(
"GenerateTClass",
"Even though the dictionary generation for %s seemed successful we can't find the TClass bootstrap!",classname.c_str());
4474 cl =
new TClass(classinfo, version, 0, 0, -1, -1, silent);
4480 cl =
new TClass(classinfo, 1, 0, 0, -1, -1, silent);
4505 if (classes == 0 || classes[0] == 0) {
4506 Error(
"TCling::GenerateDictionary",
"Cannot generate dictionary without passing classes.");
4510 std::vector<std::string> listClasses;
4512 const char* current = classes, *prev = classes;
4516 if (*current ==
';') {
4517 listClasses.push_back(std::string(prev, current - prev));
4520 else if (*(current + 1) == 0) {
4521 listClasses.push_back(std::string(prev, current + 1 - prev));
4525 std::vector<std::string> listIncludes;
4529 const char* current = includes, *prev = includes;
4533 if (*current ==
';') {
4534 listIncludes.push_back(std::string(prev, current - prev));
4537 else if (*(current + 1) == 0) {
4538 listIncludes.push_back(std::string(prev, current + 1 - prev));
4544 std::vector<std::string>(), std::vector<std::string>());
4565 if (
const ValueDecl* decl = (
const ValueDecl*)
d){
4568 if (hasIoName && ioName !=
name)
return 0;
4580 using namespace clang;
4582 DeclarationName DName = &SemaR.Context.Idents.get(
name);
4584 LookupResult
R(SemaR, DName, SourceLocation(), Sema::LookupOrdinaryName,
4585 Sema::ForRedeclaration);
4589 cling::utils::Lookup::Named(&SemaR,
R);
4593 while (
F.hasNext()) {
4594 NamedDecl *D =
F.next();
4595 if (isa<VarDecl>(D) || isa<FieldDecl>(D) || isa<EnumConstantDecl>(D) ||
4596 isa<IndirectFieldDecl>(D))
4602 if (
R.isSingleResult())
4603 return R.getFoundDecl();
4615 const clang::Decl* possibleEnum = 0;
4620 const clang::DeclContext* dc = 0;
4621 if (
const clang::Decl* D = cci->
GetDecl()) {
4622 if (!(dc = dyn_cast<clang::NamespaceDecl>(D))) {
4623 dc = dyn_cast<clang::RecordDecl>(D);
4630 possibleEnum = cling::utils::Lookup::Tag(&
fInterpreter->getSema(),
name, dc);
4632 Error(
"TCling::GetEnum",
"DeclContext not found for %s .\n",
name);
4641 if (possibleEnum && (possibleEnum != (clang::Decl*)-1)
4642 && isa<clang::EnumDecl>(possibleEnum)) {
4643 return possibleEnum;
4655 llvm::StringRef mangled_name = gv->getName();
4670 std::string scopename(demangled_name_c);
4671 free(demangled_name_c);
4677 std::string dataname;
4679 if (!strncmp(scopename.c_str(),
"typeinfo for ",
sizeof(
"typeinfo for ")-1)) {
4680 scopename.erase(0,
sizeof(
"typeinfo for ")-1);
4681 }
else if (!strncmp(scopename.c_str(),
"vtable for ",
sizeof(
"vtable for ")-1)) {
4682 scopename.erase(0,
sizeof(
"vtable for ")-1);
4685 std::string::size_type pos = scopename.rfind(
'(');
4686 if (pos != std::string::npos) {
4690 pos = scopename.rfind(
':');
4691 if (pos != std::string::npos) {
4692 if ((pos != 0) && (scopename[pos-1] ==
':')) {
4693 dataname = scopename.substr(pos+1);
4694 scopename.erase(pos-1);
4698 dataname = scopename;
4706 if (scopename.size()) {
4722 Error(
"GetDataMemberWithValue()",
"not implemented");
4732 Error(
"GetDataMemberAtAddr()",
"not implemented");
4742 const char* params,
Bool_t objectIsConst )
4754 func.
SetFunc(&gcl, method, params, &offset);
4760 return mangled_name;
4775 GetMethod(method,
proto, objectIsConst, 0 , mode).GetMangledName();
4787 const char* params,
Bool_t objectIsConst )
4799 func.
SetFunc(&gcl, method, params, &offset);
4828 std::vector<DeclId_t>& res)
const
4831 clang::ASTContext& Ctx =
S.Context;
4832 const clang::Decl* CtxDecl
4834 Ctx.getTranslationUnitDecl();
4835 auto RecDecl = llvm::dyn_cast<const clang::RecordDecl>(CtxDecl);
4836 const clang::DeclContext* DeclCtx = RecDecl;
4839 DeclCtx = dyn_cast<clang::NamespaceDecl>(CtxDecl);
4840 if (!DeclCtx)
return;
4842 clang::DeclarationName DName;
4847 if (RecDecl->getNameAsString() == funcname) {
4848 clang::QualType QT = Ctx.getTypeDeclType(RecDecl);
4849 DName = Ctx.DeclarationNames.getCXXConstructorName(Ctx.getCanonicalType(QT));
4850 }
else if (funcname[0] ==
'~' && RecDecl->getNameAsString() == funcname + 1) {
4851 clang::QualType QT = Ctx.getTypeDeclType(RecDecl);
4852 DName = Ctx.DeclarationNames.getCXXDestructorName(Ctx.getCanonicalType(QT));
4854 DName = &Ctx.Idents.get(funcname);
4857 DName = &Ctx.Idents.get(funcname);
4861 clang::LookupResult
R(
S, DName, clang::SourceLocation(),
4862 Sema::LookupOrdinaryName, clang::Sema::NotForRedeclaration);
4863 R.suppressDiagnostics();
4864 S.LookupQualifiedName(
R,
const_cast<DeclContext*
>(DeclCtx));
4865 if (
R.empty())
return;
4867 res.reserve(res.size() + (
R.end() -
R.begin()));
4868 for (clang::LookupResult::iterator IR =
R.begin(), ER =
R.end();
4870 if (
const clang::FunctionDecl* FD
4871 = llvm::dyn_cast<const clang::FunctionDecl>(*IR)) {
4872 if (!FD->getDescribedFunctionTemplate()) {
4875 }
else if (
const auto *USD = llvm::dyn_cast<const clang::UsingShadowDecl>(*IR)) {
4877 if (llvm::isa<clang::FunctionDecl>(USD->getTargetDecl())) {
5037 const char* params,
Bool_t objectIsConst,
int* error)
5050 void* address = (
void*)((
Long_t)addr + offset);
5057 const char* params,
int* error)
5059 Execute(obj,cl,method,params,
false,error);
5074 Error(
"Execute",
"No method was defined");
5083 if (argc > nparms) {
5084 Error(
"Execute",
"Too many parameters to call %s, got %d but expected at most %d.",method->
GetName(),argc,nparms);
5087 if (nparms != argc) {
5097 Int_t firstDefault = -1;
5098 for (
Int_t i = 0; i < nparms; i ++) {
5105 if (firstDefault >= 0) {
5106 Error(
"Execute",
"Too few arguments to call %s, got only %d but expected at least %d and at most %d.",method->
GetName(),argc,firstDefault,nparms);
5108 Error(
"Execute",
"Too few arguments to call %s, got only %d but expected %d.",method->
GetName(),argc,nparms);
5114 const char* listpar =
"";
5119 for (
Int_t i = 0; i < argc; i ++) {
5135 complete += nxtpar->
String();
5138 listpar = complete.
Data();
5158 void* address = (
void*)((
Long_t)addr + offset);
5165 const void* args[] ,
5170 Error(
"ExecuteWithArgsAndReturn",
"No method was defined");
5197 Warning(
"GetTopLevelMacroName",
"Must change return type!");
5244#if defined(R__MUST_REVISIT)
5245#if R__MUST_REVISIT(6,0)
5246 Warning(
"GetCurrentMacroName",
"Must change return type!");
5259 TTHREAD_TLS(
char*) t = 0;
5260 TTHREAD_TLS(
unsigned int) tlen = 0;
5262 unsigned int dlen = strlen(typeDesc);
5265 t =
new char[dlen + 1];
5268 const char*
s, *template_start;
5269 if (!strstr(typeDesc,
"(*)(")) {
5270 s = strchr(typeDesc,
' ');
5271 template_start = strchr(typeDesc,
'<');
5272 if (!strcmp(typeDesc,
"long long")) {
5273 strlcpy(t, typeDesc, dlen + 1);
5275 else if (!strncmp(typeDesc,
"unsigned ",
s + 1 - typeDesc)) {
5276 strlcpy(t, typeDesc, dlen + 1);
5282 else if (
s && (template_start == 0 || (
s < template_start))) {
5283 strlcpy(t,
s + 1, dlen + 1);
5286 strlcpy(t, typeDesc, dlen + 1);
5290 strlcpy(t, typeDesc, dlen + 1);
5293 while (
l > 0 && (t[
l - 1] ==
'*' || t[
l - 1] ==
'&')) {
5301 assert(rootmapfile && *rootmapfile);
5303 llvm::StringRef libName = llvm::sys::path::filename(rootmapfile);
5304 libName.consume_back(
".rootmap");
5306 return !
gInterpreter->HasPCMForLibrary(libName.str().c_str());
5317 if (!(rootmapfile && *rootmapfile))
5324 const std::map<char, unsigned int> keyLenMap = {{
'c',6},{
'n',10},{
't',8},{
'h',7},{
'e',5},{
'v',4}};
5326 std::string rootmapfileNoBackslash(rootmapfile);
5328 std::replace(rootmapfileNoBackslash.begin(), rootmapfileNoBackslash.end(),
'\\',
'/');
5335 uniqueString->
Append(std::string(
"\n#line 1 \"Forward declarations from ") + rootmapfileNoBackslash +
"\"\n");
5337 std::ifstream
file(rootmapfileNoBackslash);
5340 std::string lib_name;
5342 bool newFormat =
false;
5343 while (getline(
file,
line,
'\n')) {
5344 if (!newFormat && (
line.compare(0, 8,
"Library.") == 0 ||
line.compare(0, 8,
"Declare.") == 0)) {
5350 if (
line.compare(0, 9,
"{ decls }") == 0) {
5353 while (getline(
file,
line,
'\n')) {
5356 if (!uniqueString) {
5357 Error(
"ReadRootmapFile",
"Cannot handle \"{ decls }\" sections in custom rootmap file %s",
5358 rootmapfileNoBackslash.c_str());
5364 const char firstChar =
line[0];
5365 if (firstChar ==
'[') {
5367 auto brpos =
line.find(
']');
5368 if (brpos == string::npos)
5370 lib_name =
line.substr(1, brpos - 1);
5372 while (lib_name[nspaces] ==
' ')
5375 lib_name.replace(0, nspaces,
"");
5377 TString lib_nameTstr(lib_name.c_str());
5382 Info(
"ReadRootmapFile",
"new section for %s", lib_nameTstr.
Data());
5384 Info(
"ReadRootmapFile",
"section for %s (library does not exist)", lib_nameTstr.
Data());
5390 auto keyLenIt = keyLenMap.find(firstChar);
5391 if (keyLenIt == keyLenMap.end())
5393 unsigned int keyLen = keyLenIt->second;
5395 const char *keyname =
line.c_str() + keyLen;
5397 Info(
"ReadRootmapFile",
"class %s in %s", keyname, lib_name.c_str());
5400 if (lib_name != isThere->
GetValue()) {
5401 if (firstChar ==
'n') {
5403 Info(
"ReadRootmapFile",
"namespace %s found in %s is already in %s", keyname, lib_name.c_str(),
5405 }
else if (firstChar ==
'h') {
5410 Warning(
"ReadRootmapFile",
"%s %s found in %s is already in %s",
line.substr(0, keyLen).c_str(),
5411 keyname, lib_name.c_str(), isThere->
GetValue());
5415 Info(
"ReadRootmapFile",
"Key %s was already defined for %s", keyname, lib_name.c_str());
5476 using namespace clang;
5478 class ExtVisibleStorageAdder:
public RecursiveASTVisitor<ExtVisibleStorageAdder>{
5484 ExtVisibleStorageAdder(std::unordered_set<const NamespaceDecl*>& nsSet): fNSSet(nsSet) {};
5485 bool VisitNamespaceDecl(NamespaceDecl* nsDecl) {
5490 nsDecl->setHasExternalVisibleStorage();
5491 fNSSet.insert(nsDecl);
5495 std::unordered_set<const NamespaceDecl*>& fNSSet;
5543 for (
Int_t j = 0; j < i; j++) {
5554 Info(
"LoadLibraryMap",
"%s",
d.Data());
5559 if (
f.EndsWith(
".rootmap")) {
5565 Info(
"LoadLibraryMap",
" rootmap file: %s", p.
Data());
5583 if (
f.BeginsWith(
"rootmap")) {
5588 Warning(
"LoadLibraryMap",
"please rename %s to end with \".rootmap\"", p.
Data());
5601 if (rootmapfile && *rootmapfile) {
5608 else if (res == -3) {
5618 while ((rec = (
TEnvRec*) next())) {
5620 if (!strncmp(cls.
Data(),
"Library.", 8) && cls.
Length() > 8) {
5639 Info(
"LoadLibraryMap",
"class %s in %s", cls.
Data(), wlib);
5642 Info(
"LoadLibraryMap",
"class %s in %s (library does not exist)", cls.
Data(), lib);
5648 else if (!strncmp(cls.
Data(),
"Declare.", 8) && cls.
Length() > 8) {
5658 cling::Transaction*
T =
nullptr;
5660 assert(cling::Interpreter::kSuccess == compRes &&
"A declaration in a rootmap could not be compiled");
5662 if (compRes!=cling::Interpreter::kSuccess){
5664 "Problems in %s declaring '%s' were encountered.", rootmapfile, uniqueString.
Data()) ;
5669 for (
auto declIt =
T->decls_begin(); declIt < T->decls_end(); ++declIt) {
5670 if (declIt->m_DGR.isSingleDecl()) {
5671 if (Decl* D = declIt->m_DGR.getSingleDecl()) {
5672 if (NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(D)) {
5673 evsAdder.TraverseDecl(NSD);
5708 for (
Int_t ilib = 0; ilib < nrSharedLibs; ilib++) {
5715 TString rootMapBaseStr = sharedLibBaseStr;
5716 if (sharedLibBaseStr.
EndsWith(
".dll")) {
5719 else if (sharedLibBaseStr.
EndsWith(
".DLL")) {
5722 else if (sharedLibBaseStr.
EndsWith(
".so")) {
5725 else if (sharedLibBaseStr.
EndsWith(
".sl")) {
5728 else if (sharedLibBaseStr.
EndsWith(
".dl")) {
5731 else if (sharedLibBaseStr.
EndsWith(
".a")) {
5735 Error(
"ReloadAllSharedLibraryMaps",
"Unknown library type %s", sharedLibBaseStr.
Data());
5739 rootMapBaseStr +=
".rootmap";
5742 Error(
"ReloadAllSharedLibraryMaps",
"Could not find rootmap %s in path", rootMapBaseStr.
Data());
5749 Error(
"ReloadAllSharedLibraryMaps",
"Error loading map %s", rootMap);
5784 if (!
fMapfile || !library || !*library) {
5792 size_t len = libname.
Length();
5797 while ((rec = (
TEnvRec *) next())) {
5808 if (!strncmp(cls.
Data(),
"Library.", 8) && cls.
Length() > 8) {
5817 if (!strncmp(lib, libname.
Data(), len)) {
5819 Error(
"UnloadLibraryMap",
"entry for <%s, %s> not found in library map table", cls.
Data(), lib);
5827 TString library_rootmap(library);
5828 if (!library_rootmap.
EndsWith(
".rootmap"))
5829 library_rootmap.
Append(
".rootmap");
5882 free(demangled_name);
5900 std::string demangled_name(demangled_name_c);
5901 free(demangled_name_c);
5914 result =
AutoLoad(demangled_name.c_str(), knowDictNotLoaded);
5933 if (
gROOT->LoadClass(cls, deplib) == 0) {
5936 "loaded dependent library %s for %s", deplib, cls);
5941 "failure loading dependent library %s for %s",
5946 if (lib && lib[0]) {
5947 if (
gROOT->LoadClass(cls, lib) == 0) {
5950 "loaded library %s for %s", lib, cls);
5956 "failure loading library %s for %s", lib, cls);
5979 static std::set<std::string> gClassOnStack;
5980 auto insertResult = gClassOnStack.insert(std::string(cls));
5981 if (insertResult.second) {
5985 for(
auto element :
proto->GetData()) {
5986 const char *subtypename = element->GetTypeName();
5999 if (classinfo &&
gInterpreter->ClassInfo_IsValid(classinfo)
6003 while (
gInterpreter->DataMemberInfo_Next(memberinfo)) {
6019 gClassOnStack.erase(insertResult.first);
6041 Info(
"TCling::AutoLoad",
"Explicitly disabled (the class name is %s)", cls);
6061 Info(
"TCling::AutoLoad",
6062 "Trying to autoload for %s", cls);
6067 Info(
"TCling::AutoLoad",
6068 "Disabled due to gROOT or gInterpreter being invalid/not ready (the class name is %s)", cls);
6097 cling::Interpreter *interpreter)
6099 std::string code = gNonInterpreterClassDef ;
6106 code += (
"#include \"");
6110 code += (
"#ifdef __ROOTCLING__\n"
6111 "#undef __ROOTCLING__\n"
6112 + gInterpreterClassDef +
6115 cling::Interpreter::CompilationResult cr;
6121 Sema &SemaR = interpreter->getSema();
6123 clangDiagSuppr diagSuppr(SemaR.getDiagnostics());
6125 #if defined(R__MUST_REVISIT)
6126 #if R__MUST_REVISIT(6,2)
6127 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
6131 cr = interpreter->parseForModule(code);
6149 Int_t nHheadersParsed = 0;
6150 unsigned long offset = 0;
6151 if (strncmp(cls,
"const ", 6) == 0) {
6156 bool skipFirstEntry =
false;
6157 std::vector<std::string> autoparseKeys;
6158 if (strchr(cls,
'<')) {
6164 if (!autoparseKeys.empty() && !autoparseKeys[0].empty()) {
6169 TString templateName(autoparseKeys[0]);
6170 auto tokens = templateName.
Tokenize(
"::");
6171 clang::NamedDecl* previousScopeAsNamedDecl =
nullptr;
6172 clang::DeclContext* previousScopeAsContext =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
6174 previousScopeAsContext =
fInterpreter->getSema().getStdNamespace();
6175 auto nTokens = tokens->GetEntriesFast();
6176 for (
Int_t tk = 0; tk < nTokens; ++tk) {
6177 auto scopeObj = tokens->UncheckedAt(tk);
6178 auto scopeName = ((
TObjString*) scopeObj)->String().Data();
6179 previousScopeAsNamedDecl = cling::utils::Lookup::Named(&
fInterpreter->getSema(), scopeName, previousScopeAsContext);
6181 if ((clang::NamedDecl*)-1 == previousScopeAsNamedDecl)
break;
6182 previousScopeAsContext = llvm::dyn_cast_or_null<clang::DeclContext>(previousScopeAsNamedDecl);
6183 if (!previousScopeAsContext)
break;
6187 if ((clang::NamedDecl*)-1 != previousScopeAsNamedDecl) {
6188 if (
auto templateDecl = llvm::dyn_cast_or_null<clang::ClassTemplateDecl>(previousScopeAsNamedDecl)) {
6189 if (
auto templatedDecl = templateDecl->getTemplatedDecl()) {
6190 skipFirstEntry = templatedDecl->hasDefinition();
6197 if (topLevel) autoparseKeys.emplace_back(cls);
6199 for (
const auto & apKeyStr : autoparseKeys) {
6200 if (skipFirstEntry) {
6201 skipFirstEntry=
false;
6204 if (apKeyStr.empty())
continue;
6205 const char *apKey = apKeyStr.c_str();
6209 Info(
"TCling::AutoParse",
6210 "Starting autoparse for %s\n", apKey);
6215 const cling::Transaction *
T =
fInterpreter->getCurrentTransaction();
6217 auto const &hNamesPtrs = iter->second;
6219 Info(
"TCling::AutoParse",
6220 "We can proceed for %s. We have %s headers.", apKey, std::to_string(hNamesPtrs.size()).c_str());
6222 for (
auto & hName : hNamesPtrs) {
6224 if (0 !=
fPayloads.count(normNameHash)) {
6225 float initRSSval=0.f, initVSIZEval=0.f;
6227 (
void) initVSIZEval;
6230 "Parsing full payload for %s", apKey);
6237 if (cRes != cling::Interpreter::kSuccess) {
6238 if (hName[0] ==
'\n')
6239 Error(
"AutoParse",
"Error parsing payload code for class %s with content:\n%s", apKey, hName);
6248 Info(
"Autoparse",
">>> RSS key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initRSSval, endRSSval, endRSSval-initRSSval);
6249 Info(
"Autoparse",
">>> VSIZE key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initVSIZEval, endVSIZEval, endVSIZEval-initVSIZEval);
6255 "Parsing single header %s", hName);
6258 if (cRes != cling::Interpreter::kSuccess) {
6259 Error(
"AutoParse",
"Error parsing headerfile %s for class %s.", hName, apKey);
6271 if (strchr(apKey,
'<')) {
6278 return nHheadersParsed;
6288 if (llvm::StringRef(cls).contains(
"(lambda)"))
6302 Info(
"TCling::AutoParse",
6303 "Trying to autoparse for %s", cls);
6325 return nHheadersParsed > 0 ? 1 : 0;
6333 StringRef errMsg(errmessage);
6334 if (errMsg.contains(
"undefined symbol: ")) {
6336 std::string mangled_name = std::string(errMsg.split(
"undefined symbol: ").second);
6337 void* res = ((
TCling*)
gCling)->LazyFunctionCreatorAutoload(mangled_name);
6338 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
6339 if (res && DLM && (DLM->loadLibrary(libStem, permanent, resolved) == cling::DynamicLibraryManager::kLoadLibSuccess))
6352 const cling::DynamicLibraryManager &DLM) {
6355 auto LibLoader = [](
const std::string& LibName) ->
bool {
6356 if (
gSystem->
Load(LibName.c_str(),
"",
false) < 0) {
6357 Error(
"TCling__LazyFunctionCreatorAutoloadForModule",
6358 "Failed to load library %s", LibName.c_str());
6368 assert(!llvm::StringRef(mangled_name).startswith(
"__") &&
"Already added!");
6369 std::string libName = DLM.searchLibrariesForSymbol(
'_' + mangled_name,
6372 std::string libName = DLM.searchLibrariesForSymbol(mangled_name,
6376 assert(!llvm::StringRef(libName).startswith(
"libNew") &&
6377 "We must not resolve symbols from libNew!");
6379 if (libName.empty())
6382 if (!LibLoader(libName))
6385 return llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(mangled_name);
6402 mangled_name.c_str())) {
6413 std::string
name(demangled_name_c);
6414 free(demangled_name_c);
6422 std::string::size_type pos =
name.find(
"__thiscall ");
6423 if (pos != std::string::npos) {
6424 name.erase(0, pos +
sizeof(
"__thiscall ")-1);
6426 pos =
name.find(
"__cdecl ");
6427 if (pos != std::string::npos) {
6428 name.erase(0, pos +
sizeof(
"__cdecl ")-1);
6430 if (!strncmp(
name.c_str(),
"typeinfo for ",
sizeof(
"typeinfo for ")-1)) {
6431 name.erase(0,
sizeof(
"typeinfo for ")-1);
6432 }
else if (!strncmp(
name.c_str(),
"vtable for ",
sizeof(
"vtable for ")-1)) {
6433 name.erase(0,
sizeof(
"vtable for ")-1);
6434 }
else if (!strncmp(
name.c_str(),
"operator",
sizeof(
"operator")-1)
6435 && !isalnum(
name[
sizeof(
"operator")])) {
6437 name.erase(0,
sizeof(
"operator")-1);
6438 pos =
name.rfind(
'(');
6439 if (pos != std::string::npos) {
6440 name.erase(0, pos + 1);
6441 pos =
name.find(
",");
6442 if (pos != std::string::npos) {
6446 pos =
name.rfind(
" const");
6447 if (pos != std::string::npos) {
6448 name.erase(pos, strlen(
" const"));
6450 while (!
name.empty() && strchr(
"&*",
name.back()))
6470 while (libs.
Tokenize(lib, posLib)) {
6480 void* addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(mangled_name.c_str());
6502 const NamedDecl *oldDef = llvm::dyn_cast_or_null<NamedDecl>(cci->
GetDecl());
6503 if (!oldDef || (def && def != oldDef)) {
6517 if (!alias && def !=
nullptr)
6540 const TagDecl *td = dyn_cast<TagDecl>(ND);
6541 const NamespaceDecl *
ns = dyn_cast<NamespaceDecl>(ND);
6542 const NamedDecl *canon =
nullptr;
6547 canon = tdDef = td->getDefinition();
6551 if (!tdDef->isCompleteDefinition() || llvm::isa<clang::FunctionDecl>(tdDef->getDeclContext())) {
6557 auto declName = tdDef->getNameAsString();
6568 clang::QualType
type(tdDef->getTypeForDecl(), 0);
6571 canon =
ns->getCanonicalDecl();
6572 name = ND->getQualifiedNameAsString();
6574 name = ND->getQualifiedNameAsString();
6623 std::set<TClass*> modifiedTClasses;
6628 bool isTUTransaction =
false;
6629 if (!
T.empty() &&
T.decls_begin() + 1 ==
T.decls_end() && !
T.hasNestedTransactions()) {
6630 clang::Decl* FirstDecl = *(
T.decls_begin()->m_DGR.begin());
6631 if (llvm::isa<clang::TranslationUnitDecl>(FirstDecl)) {
6634 isTUTransaction =
true;
6638 std::set<const void*> TransactionDeclSet;
6639 if (!isTUTransaction &&
T.decls_end() -
T.decls_begin()) {
6640 const clang::Decl* WrapperFD =
T.getWrapperFD();
6641 for (cling::Transaction::const_iterator
I =
T.decls_begin(),
E =
T.decls_end();
6643 if (
I->m_Call != cling::Transaction::kCCIHandleTopLevelDecl
6644 &&
I->m_Call != cling::Transaction::kCCIHandleTagDeclDefinition)
6647 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
6648 DE =
I->m_DGR.end(); DI != DE; ++DI) {
6649 if (*DI == WrapperFD)
6651 TransactionDeclSet.insert(*DI);
6652 ((
TCling*)
gCling)->HandleNewDecl(*DI,
false, modifiedTClasses);
6659 for (cling::Transaction::const_iterator
I =
T.deserialized_decls_begin(),
6660 E =
T.deserialized_decls_end();
I !=
E; ++
I) {
6661 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
6662 DE =
I->m_DGR.end(); DI != DE; ++DI)
6663 if (TransactionDeclSet.find(*DI) == TransactionDeclSet.end()) {
6679 std::vector<TClass*> modifiedTClassesDiff(modifiedTClasses.size());
6680 std::vector<TClass*>::iterator it;
6681 it = set_difference(modifiedTClasses.begin(), modifiedTClasses.end(),
6684 modifiedTClassesDiff.begin());
6685 modifiedTClassesDiff.resize(it - modifiedTClassesDiff.begin());
6688 ((
TCling*)
gCling)->GetModTClasses().insert(modifiedTClassesDiff.begin(),
6689 modifiedTClassesDiff.end());
6690 for (std::vector<TClass*>::const_iterator
I = modifiedTClassesDiff.begin(),
6691 E = modifiedTClassesDiff.end();
I !=
E; ++
I) {
6693 if (!
gROOT->GetListOfClasses()->FindObject(*
I)) {
6715 cling::Transaction::const_nested_iterator iNested =
T.nested_begin();
6716 for (cling::Transaction::const_iterator
I =
T.decls_begin(),
E =
T.decls_end();
6718 if (
I->m_Call == cling::Transaction::kCCIHandleVTable)
6720 if (
I->m_Call == cling::Transaction::kCCINone) {
6726 for (
auto &D :
I->m_DGR)
6752 if (D->isFromASTFile())
6760 if (isa<VarDecl>(D) || isa<FieldDecl>(D) || isa<EnumConstantDecl>(D)) {
6766 }
else if (isa<FunctionDecl>(D)) {
6768 }
else if (isa<FunctionTemplateDecl>(D)) {
6770 }
else if (isa<EnumDecl>(D)) {
6781 }
else if (isa<RecordDecl>(D) || isa<NamespaceDecl>(D)) {
6782 if (isa<RecordDecl>(D) && !cast<RecordDecl>(D)->isCompleteDefinition())
6785 std::vector<TClass *> Classes;
6788 for (
auto &
C : Classes) {
6793 for (
auto &
I : cast<DeclContext>(D)->decls())
6797 if (D->getKind() != Decl::Namespace
6798 || cast<NamespaceDecl>(D)->isOriginalNamespace())
6799 C->ResetClassInfo();
6811 std::size_t normNameHash = triter->second;
6817 auto const &hNamesPtrs = iter->second;
6818 for (
auto &hName : hNamesPtrs) {
6820 Info(
"TransactionRollback",
6821 "Restoring ability to autoaparse: %s", hName);
6858 using namespace clang;
6859 if (
const Decl *D = LH.findScope(cls, cling::LookupHelper::NoDiagnostics,
6861 if (!D->isFromASTFile()) {
6863 Warning(
"GetClassSharedLibsForModule",
"Decl found for %s is not part of a module", cls);
6866 class ModuleCollector :
public ConstDeclVisitor<ModuleCollector> {
6867 llvm::DenseSet<Module *> &m_TopLevelModules;
6870 ModuleCollector(llvm::DenseSet<Module *> &TopLevelModules) : m_TopLevelModules(TopLevelModules) {}
6871 void Collect(
const Decl *D) { Visit(D); }
6873 void VisitDecl(
const Decl *D)
6883 if (!D->hasOwningModule())
6885 if (Module *M = D->getOwningModule()->getTopLevelModule())
6886 m_TopLevelModules.insert(M);
6889 void VisitTemplateArgument(
const TemplateArgument &TA)
6891 switch (TA.getKind()) {
6893 case TemplateArgument::Integral:
6894 case TemplateArgument::Pack:
6895 case TemplateArgument::NullPtr:
6896 case TemplateArgument::Expression:
6897 case TemplateArgument::Template:
6898 case TemplateArgument::TemplateExpansion:
return;
6900 if (
const TagType *TagTy = dyn_cast<TagType>(TA.getAsType()))
6901 return Visit(TagTy->getDecl());
6903 case TemplateArgument::Declaration:
return Visit(TA.getAsDecl());
6905 llvm_unreachable(
"Invalid TemplateArgument::Kind!");
6908 void VisitClassTemplateSpecializationDecl(
const ClassTemplateSpecializationDecl *CTSD)
6910 if (CTSD->getOwningModule())
6913 VisitDecl(CTSD->getSpecializedTemplate());
6914 const TemplateArgumentList &ArgList = CTSD->getTemplateArgs();
6915 for (
const TemplateArgument *Arg = ArgList.data(), *ArgEnd = Arg + ArgList.size(); Arg != ArgEnd; ++Arg) {
6916 VisitTemplateArgument(*Arg);
6921 llvm::DenseSet<Module *> TopLevelModules;
6922 ModuleCollector
m(TopLevelModules);
6925 for (
auto M : TopLevelModules) {
6928 if (!M->LinkLibraries.size())
6931 if (M->Name ==
"Core")
6933 assert(M->LinkLibraries.size() == 1);
6934 if (!result.empty())
6936 result += M->LinkLibraries[0].Library;
6952 llvm::StringRef className = cls;
6958 if (className.contains(
"(lambda)"))
6962 cling::LookupHelper &LH =
fInterpreter->getLookupHelper();
6964 if (!libs.empty()) {
6970 if (!cls || !*cls) {
6978 const char* libs = libs_record->
GetValue();
6979 return (*libs) ? libs : 0;
6986 c.ReplaceAll(
"::",
"@@");
6989 c.ReplaceAll(
" ",
"-");
6996 const char* libs = libs_record->
GetValue();
6997 return (*libs) ? libs : 0;
7011 cling::Interpreter *interp,
7012 bool skipLoadedLibs =
true)
7015 if (!llvm::sys::path::is_absolute(lib)) {
7017 Error(
"TCling__GetSharedLibImmediateDepsSlow",
"Cannot find library '%s'", lib.c_str());
7021 assert(llvm::sys::fs::exists(lib) &&
"Must exist!");
7022 lib = llvm::sys::path::filename(lib);
7025 auto ObjF = llvm::object::ObjectFile::createObjectFile(LibFullPath.
Data());
7027 Warning(
"TCling__GetSharedLibImmediateDepsSlow",
"Failed to read object file %s", lib.c_str());
7031 llvm::object::ObjectFile *BinObjFile = ObjF.get().getBinary();
7033 std::set<string> DedupSet;
7034 std::string Result = lib +
' ';
7035 for (
const auto &
S : BinObjFile->symbols()) {
7036 uint32_t Flags =
S.getFlags();
7037 if (Flags & llvm::object::SymbolRef::SF_Undefined) {
7038 llvm::Expected<StringRef> SymNameErr =
S.getName();
7040 Warning(
"GetSharedLibDepsForModule",
"Failed to read symbol");
7043 llvm::StringRef SymName = SymNameErr.get();
7044 if (SymName.empty())
7047 if (BinObjFile->isELF()) {
7051 if (SymName.contains(
"@@GLIBCXX") || SymName.contains(
"@@CXXABI") ||
7052 SymName.contains(
"@@GLIBC") || SymName.contains(
"@@GCC"))
7060 if (SymName ==
"_Jv_RegisterClasses" ||
7061 SymName ==
"_ITM_deregisterTMCloneTable" ||
7062 SymName ==
"_ITM_registerTMCloneTable")
7070 if (skipLoadedLibs && SymName[0] ==
'_'
7071 && llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(SymName.drop_front()))
7076 if (skipLoadedLibs && llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(SymName))
7080 std::string found = interp->getDynamicLibraryManager()->searchLibrariesForSymbol(SymName,
false);
7086 if (!found.empty()) {
7087 std::string cand = llvm::sys::path::filename(found).str();
7088 if (!DedupSet.insert(cand).second)
7091 Result += cand +
' ';
7102 llvm::SmallString<256> rootmapName;
7103 if (!lib.startswith(
"lib"))
7104 rootmapName.append(
"lib");
7106 rootmapName.append(llvm::sys::path::filename(lib));
7107 llvm::sys::path::replace_extension(rootmapName,
"rootmap");
7113 llvm::StringRef rootmapNameNoLib = rootmapName.str();
7114 if (rootmapNameNoLib.consume_front(
"lib"))
7138 if (llvm::sys::path::is_absolute(lib) && !llvm::sys::fs::exists(lib))
7142 llvm::SmallString<512> rootmapName(lib);
7143 llvm::sys::path::replace_extension(rootmapName,
"rootmap");
7144 if (llvm::sys::fs::exists(rootmapName)) {
7146 Info(
"Load",
"loading %s", rootmapName.c_str());
7153 Warning(
"TCling::GetSharedLibDeps",
"Precomputed dependencies available but scanning '%s'", lib);
7158 if (!libs.empty()) {
7164 if (!
fMapfile || !lib || !lib[0]) {
7174 size_t len = libname.
Length();
7175 while ((rec = (
TEnvRec*) next())) {
7176 const char* libs = rec->
GetValue();
7177 if (!strncmp(libs, libname.
Data(), len) && strlen(libs) >= len
7178 && (!libs[len] || libs[len] ==
' ' || libs[len] ==
'.')) {
7191#if defined(R__MUST_REVISIT)
7192#if R__MUST_REVISIT(6,2)
7193 Warning(
"IsErrorMessagesEnabled",
"Interface not available yet.");
7205#if defined(R__MUST_REVISIT)
7206#if R__MUST_REVISIT(6,2)
7207 Warning(
"SetErrorMessages",
"Interface not available yet.");
7223 llvm::SmallVector<std::string, 10> includePaths;
7225 fInterpreter->GetIncludePaths(includePaths,
false,
true);
7226 if (
const size_t nPaths = includePaths.size()) {
7227 assert(!(nPaths & 1) &&
"GetIncludePath, number of paths and options is not equal");
7229 for (
size_t i = 0; i < nPaths; i += 2) {
7234 if (includePaths[i] !=
"-I")
7268 assert(fout != 0 &&
"DisplayIncludePath, 'fout' parameter is null");
7270 llvm::SmallVector<std::string, 10> includePaths;
7272 fInterpreter->GetIncludePaths(includePaths,
false,
true);
7273 if (
const size_t nPaths = includePaths.size()) {
7274 assert(!(nPaths & 1) &&
"DisplayIncludePath, number of paths and options is not equal");
7276 std::string allIncludes(
"include path:");
7277 for (
size_t i = 0; i < nPaths; i += 2) {
7279 allIncludes += includePaths[i];
7281 if (includePaths[i] !=
"-I")
7283 allIncludes += includePaths[i + 1];
7286 fprintf(fout,
"%s\n", allIncludes.c_str());
7305#if defined(R__MUST_REVISIT)
7306#if R__MUST_REVISIT(6,2)
7307 Warning(
"GenericError",
"Interface not available yet.");
7335#if defined(R__MUST_REVISIT)
7336#if R__MUST_REVISIT(6,2)
7337 Warning(
"GetSecurityError",
"Interface not available yet.");
7348 cling::Interpreter::CompilationResult compRes;
7350 return compRes == cling::Interpreter::kFailure;
7369 TTHREAD_TLS_DECL(std::string,buffer);
7371 return buffer.c_str();
7452#if defined(R__MUST_REVISIT)
7453#if R__MUST_REVISIT(6,2)
7454 Warning(
"SetErrmsgcallback",
"Interface not available yet.");
7472 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
7473 std::string canonical = DLM->lookupLibrary(path);
7474 if (canonical.empty()) {
7478 cling::Interpreter::CompilationResult compRes;
7480 return compRes == cling::Interpreter::kFailure;
7484 return std::unique_ptr<TInterpreterValue>(
new TClingValue);
7491 std::vector<std::string>& completions)
7502 return compRes!=cling::Interpreter::kSuccess ? 0 : 1 ;
7509 using namespace cling;
7523 if (value.isValid() && value.needsManagedAllocation()) {
7544 auto iSpecObj = iSpecObjMap->second.find(
Name);
7545 if (iSpecObj != iSpecObjMap->second.end()) {
7547 return iSpecObj->second;
7554 ASTContext&
C = SemaR.getASTContext();
7555 Preprocessor &PP = SemaR.getPreprocessor();
7557 Preprocessor::CleanupAndRestoreCacheRAII cleanupRAII(PP);
7558 Parser::ParserCurTokRestoreRAII savedCurToken(
P);
7561 Token& Tok =
const_cast<Token&
>(
P.getCurToken());
7562 Tok.setKind(tok::semi);
7568 Sema::ContextAndScopeRAII pushedDCAndS(SemaR,
C.getTranslationUnitDecl(),
7574 Error(
"GetObjectAddress",
"Got a special object without LookupCtx!");
7588 clang::CXXRecordDecl* klass)
const
7590 using namespace clang;
7591 ASTContext& Ctx = klass->getASTContext();
7592 FriendDecl::FriendUnion friendUnion(
function);
7595 FriendDecl* friendDecl = FriendDecl::Create(Ctx, klass, sl, friendUnion, sl);
7596 klass->pushFriendDecl(friendDecl);
7610 if (func)
return ((
TClingCallFunc*)func)->GetDecl()->getCanonicalDecl();
7681 f->Exec(address, &val);
7689 f->ExecWithReturn(address, ret);
7695 const void* args[] ,
7700 f->ExecWithArgsAndReturn(address, args, nargs, ret);
7708 return f->ExecInt(address);
7716 return f->ExecInt64(address);
7724 return f->ExecDouble(address);
7747 return (MethodInfo_t*)
f->FactoryMethod();
7755 f->IgnoreExtraArgs(ignore);
7772 return f->IsValid();
7781 return f->IFacePtr();
7845 f->SetArgArray(paramArr, nparam);
7862 f->SetFunc(ci, method, params, offset);
7871 f->SetFunc(ci, method, params, objectIsConst, offset);
7889 f->SetFuncProto(ci, method,
proto, offset, mode);
7899 f->SetFuncProto(ci, method,
proto, objectIsConst, offset, mode);
7909 llvm::SmallVector<clang::QualType, 4> funcProto;
7910 for (std::vector<TypeInfo_t*>::const_iterator iter =
proto.begin(), end =
proto.end();
7911 iter != end; ++iter) {
7912 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
7914 f->SetFuncProto(ci, method, funcProto, offset, mode);
7924 llvm::SmallVector<clang::QualType, 4> funcProto;
7925 for (std::vector<TypeInfo_t*>::const_iterator iter =
proto.begin(), end =
proto.end();
7926 iter != end; ++iter) {
7927 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
7929 f->SetFuncProto(ci, method, funcProto, objectIsConst, offset, mode);
7935 std::string wrapper_name;
7936 std::string wrapper;
7937 f->get_wrapper_code(wrapper_name, wrapper);
7956 const clang::DeclContext *ctxt =
nullptr;
7958 ctxt = clang::Decl::castToDeclContext(((
TClingClassInfo*)info)->GetDecl());
7960 ctxt =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
7965 const clang::Decl *decl =
reinterpret_cast<const clang::Decl*
>(declid);
7969 const clang::DeclContext *declDC = decl->getDeclContext();
7972 if (declDC->isTransparentContext()) {
7973 declDC = declDC->getParent();
7976 if (
const auto *declRD = llvm::dyn_cast<clang::RecordDecl>(declDC)) {
7977 if (declRD->isAnonymousStructOrUnion()) {
7978 declDC = declRD->getParent();
7982 if (
const auto *declNS = llvm::dyn_cast<clang::NamespaceDecl>(declDC)) {
7983 if (declNS->isAnonymousNamespace() || declNS->isInlineNamespace()) {
7984 declDC = declNS->getParent();
7991 return declDC->Equals(ctxt);
8102 TClinginfo->
Init(tagnum);
8175 return TClinginfo->
Next();
8223 return TClinginfo->
Size();
8231 return TClinginfo->
Tagnum();
8247 TTHREAD_TLS_DECL(std::string,
output);
8257 return TClinginfo->
Name();
8265 return TClinginfo->
Title();
8302 ClassInfo_t* base)
const
8315 return TClinginfo->
Next();
8323 return TClinginfo->
Next(onlyDirect);
8331 return TClinginfo->
Offset(address, isDerivedObject);
8344 return TClinginfo->
GetBaseOffset(TClinginfoBase, address, isDerivedObject);
8360 return (ClassInfo_t *)TClinginfo->
GetBase();
8368 return TClinginfo->
Tagnum();
8376 TTHREAD_TLS_DECL(std::string,
output);
8386 return TClinginfo->
Name();
8431 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
8432 const clang::ValueDecl* vd = llvm::dyn_cast_or_null<clang::ValueDecl>(decl);
8465 return TClinginfo->
Next();
8473 return TClinginfo->
Offset();
8521 return TClinginfo->
Name();
8529 return TClinginfo->
Title();
8536 TTHREAD_TLS_DECL(std::string,result);
8540 return result.c_str();
8547 Decl* decl =
static_cast<Decl*
>(
const_cast<void*
>(declId));
8548 ASTContext &
C = decl->getASTContext();
8549 SourceRange commentRange;
8550 decl->addAttr(
new (
C) AnnotateAttr( commentRange,
C, attribute, 0 ) );
8561 cling::Interpreter &interp,
8564 const clang::TypeDecl* td = llvm::dyn_cast<clang::TypeDecl>(decl->getDeclContext());
8567 clang::QualType qualType(td->getTypeForDecl(),0);
8569 unsigned int level = 0;
8570 for(
size_t cursor =
name.length()-1; cursor != 0; --cursor) {
8571 if (
name[cursor] ==
'>') ++level;
8572 else if (
name[cursor] ==
'<' && level) --level;
8573 else if (level == 0 &&
name[cursor] ==
':') {
8574 name.erase(0,cursor+1);
8586 const auto *FD = llvm::dyn_cast<clang::FunctionDecl>(decl);
8587 if (
const auto *USD = llvm::dyn_cast<clang::UsingShadowDecl>(decl)) {
8588 FD = llvm::dyn_cast<clang::FunctionDecl>(USD->getTargetDecl());
8591 Error(
"GetFunctionName",
"NULL Decl!");
8598 if (llvm::isa<clang::CXXConstructorDecl>(FD))
8602 }
else if (llvm::isa<clang::CXXDestructorDecl>(decl))
8607 llvm::raw_string_ostream stream(
output);
8608 auto printPolicy = decl->getASTContext().getPrintingPolicy();
8610 printPolicy.AnonymousTagLocations =
false;
8611 FD->getNameForDiagnostic(stream, printPolicy,
false);
8641 return (FuncTempInfo_t*)
const_cast<void*
>(declid);
8652 return (FuncTempInfo_t*)ft_info;
8672 if (!ft_info)
return 0;
8673 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
8674 return ft->getTemplateParameters()->size();
8683 if (!ft_info)
return 0;
8684 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
8685 return ft->getTemplateParameters()->getMinRequiredArguments();
8693 if (!ft_info)
return 0;
8698 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
8700 switch (ft->getAccess()) {
8701 case clang::AS_public:
8704 case clang::AS_protected:
8707 case clang::AS_private:
8710 case clang::AS_none:
8711 if (ft->getDeclContext()->isNamespace())
8719 const clang::FunctionDecl *fd = ft->getTemplatedDecl();
8720 if (
const clang::CXXMethodDecl *md =
8721 llvm::dyn_cast<clang::CXXMethodDecl>(fd)) {
8722 if (md->getTypeQualifiers() & clang::Qualifiers::Const) {
8725 if (md->isVirtual()) {
8731 if (
const clang::CXXConstructorDecl *cd =
8732 llvm::dyn_cast<clang::CXXConstructorDecl>(md)) {
8733 if (cd->isExplicit()) {
8737 else if (
const clang::CXXConversionDecl *cd =
8738 llvm::dyn_cast<clang::CXXConversionDecl>(md)) {
8739 if (cd->isExplicit()) {
8753 if (!ft_info)
return 0;
8758 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
8759 const clang::FunctionDecl *fd = ft->getTemplatedDecl();
8761 if (fd->isOverloadedOperator())
8763 if (llvm::isa<clang::CXXConversionDecl>(fd))
8765 if (llvm::isa<clang::CXXConstructorDecl>(fd))
8767 if (llvm::isa<clang::CXXDestructorDecl>(fd))
8769 if (fd->isInlined())
8780 if (!ft_info)
return;
8781 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
8793 if (!ft_info)
return;
8794 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
8798 if (
const RedeclarableTemplateDecl *AnnotFD
8800 if (AnnotateAttr *
A = AnnotFD->getAttr<AnnotateAttr>()) {
8801 output =
A->getAnnotation().str();
8805 if (!ft->isFromASTFile()) {
8855 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
8888 return info->
NArg();
8904 return info->
Next();
8928 return (TypeInfo_t*)info->
Type();
8936 TTHREAD_TLS_DECL(
TString, mangled_name);
8938 return mangled_name;
8954 return info->
Name();
8981 return info->
Title();
8989 return MethodInfo_MethodCallReturnType(func->fInfo);
8991 return EReturnType::kOther;
9000 if (info && info->
IsValid()) {
9002 clang::QualType QT( typeinfo->
GetQualType().getCanonicalType() );
9003 if (QT->isEnumeralType()) {
9004 return EReturnType::kLong;
9005 }
else if (QT->isPointerType()) {
9007 QT = llvm::cast<clang::PointerType>(QT)->getPointeeType();
9008 if ( QT->isCharType() ) {
9009 return EReturnType::kString;
9011 return EReturnType::kOther;
9013 }
else if ( QT->isFloatingType() ) {
9014 int sz = typeinfo->
Size();
9015 if (sz == 4 || sz == 8) {
9017 return EReturnType::kDouble;
9019 return EReturnType::kOther;
9021 }
else if ( QT->isIntegerType() ) {
9022 int sz = typeinfo->
Size();
9031 return EReturnType::kLong;
9033 return EReturnType::kOther;
9036 return EReturnType::kOther;
9039 return EReturnType::kOther;
9075 return (MethodArgInfo_t*)
9092 return info->
Next();
9116 return info->
Name();
9192 return TClinginfo->
Name();
9216 return TClinginfo->
Size();
9266 const char*
name)
const
9286 return TClinginfo->
Next();
9302 return TClinginfo->
Size();
9318 return TClinginfo->
Name();
9326 return TClinginfo->
Title();
9335 Error(
"SnapshotMutexState",
"fRecurseCount != 0 even though initial mutex state is unset!");
9351 Error(
"ForgetMutexState",
"mutex state's recurse count already 0!");
9368 std::unique_ptr<TVirtualRWMutex::StateDelta> uniqueP{typedDelta};
9385 return uniqueP.release();
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)
unsigned long long ULong64_t
TClass *(* DictFuncPtr_t)()
R__EXTERN TApplication * gApplication
R__EXTERN TClassTable * gClassTable
static void indent(ostringstream &buf, int indent_level)
The file contains facilities to work with C++ module files extensions used to store rdict files.
static bool requiresRootMap(const char *rootmapfile, cling::Interpreter *interp)
void TCling__RestoreInterpreterMutex(void *delta)
Re-apply the lock count delta that TCling__ResetInterpreterMutex() caused.
void * llvmLazyFunctionCreator(const std::string &mangled_name)
Autoload a library provided the mangled name of a missing symbol.
void TCling__TransactionRollback(const cling::Transaction &T)
static void RegisterPreIncludedHeaders(cling::Interpreter &clingInterp)
static bool hasParsedRootmapForLibrary(llvm::StringRef lib)
static std::string GetClassSharedLibsForModule(const char *cls, cling::LookupHelper &LH)
void TCling__InvalidateGlobal(const clang::Decl *D)
bool TClingLookupHelper__AutoParse(const char *cname)
Allow calling autoparsing from TMetaUtils.
void * TCling__LockCompilationDuringUserCodeExecution()
Lock the interpreter.
void TCling__UpdateListsOnUnloaded(const cling::Transaction &T)
void TCling__GetNormalizedContext(const ROOT::TMetaUtils::TNormalizedCtxt *&normCtxt)
R__DLLEXPORT clang::DeclContext * TCling__DEBUG__getDeclContext(clang::Decl *D)
ETupleOrdering
Check in what order the member of a tuple are layout.
bool TCling__LibraryLoadingFailed(const std::string &errmessage, const std::string &libStem, bool permanent, bool resolved)
Lookup libraries in LD_LIBRARY_PATH and DYLD_LIBRARY_PATH with mangled_name, which is extracted by er...
static const std::unordered_set< std::string > gIgnoredPCMNames
List of dicts that have the PCM information already in the PCH.
static Bool_t s_IsLibraryLoaded(const char *libname, cling::Interpreter *fInterpreter)
static std::string AlternateTuple(const char *classname, const cling::LookupHelper &lh)
R__DLLEXPORT void TCling__DEBUG__printName(clang::Decl *D)
R__DLLEXPORT void TCling__DEBUG__decl_dump(void *D)
bool TClingLookupHelper__ExistingTypeCheck(const std::string &tname, std::string &result)
Try hard to avoid looking up in the Cling database as this could enduce an unwanted autoparsing.
static bool HasASTFileOnDisk(clang::Module *M, const clang::Preprocessor &PP, std::string *FullFileName=nullptr)
Checks if there is an ASTFile on disk for the given module M.
R__DLLEXPORT clang::NamespaceDecl * TCling__DEBUG__DCtoNamespace(clang::DeclContext *DC)
void TCling__UnlockCompilationDuringUserCodeExecution(void *)
Unlock the interpreter.
const char * TCling__GetClassSharedLibs(const char *className)
R__DLLEXPORT clang::RecordDecl * TCling__DEBUG__DCtoRecordDecl(clang::DeclContext *DC)
static bool R__InitStreamerInfoFactory()
Helper to initialize TVirtualStreamerInfo's factor early.
int TCling__AutoParseCallback(const char *className)
int TCling_GenerateDictionary(const std::vector< std::string > &classes, const std::vector< std::string > &headers, const std::vector< std::string > &fwdDecls, const std::vector< std::string > &unknown)
R__DLLEXPORT bool TCling__TEST_isInvalidDecl(clang::Decl *D)
static bool HaveFullGlobalModuleIndex
R__DLLEXPORT void DestroyInterpreter(TInterpreter *interp)
void TCling__LibraryUnloadedRTTI(const void *dyLibHandle, const char *canonicalName)
void TCling__UpdateListsOnCommitted(const cling::Transaction &T, cling::Interpreter *)
const Decl * TCling__GetObjectDecl(TObject *obj)
static ETupleOrdering IsTupleAscending()
R__DLLEXPORT TInterpreter * CreateInterpreter(void *interpLibHandle, const char *argv[])
void TCling__RegisterRdictForLoadPCM(const std::string &pcmFileNameFullPath, llvm::StringRef *pcmContent)
R__DLLEXPORT void TCling__DEBUG__dump(clang::DeclContext *DC)
static void TCling__UpdateClassInfo(const NamedDecl *TD)
Update TClingClassInfo for a class (e.g. upon seeing a definition).
int TCling__CompileMacro(const char *fileName, const char *options)
void * TCling__ResetInterpreterMutex()
Reset the interpreter lock to the state it had before interpreter-related calls happened.
static void * LazyFunctionCreatorAutoloadForModule(const std::string &mangled_name, const cling::DynamicLibraryManager &DLM)
int TCling__AutoLoadCallback(const char *className)
static bool LoadModule(const std::string &ModuleName, cling::Interpreter &interp)
static void RegisterCxxModules(cling::Interpreter &clingInterp)
static bool IsFromRootCling()
static void ConstructorName(std::string &name, const clang::Decl *decl, cling::Interpreter &interp, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt)
void TCling__PrintStackTrace()
Print a StackTrace!
static int HandleInterpreterException(cling::MetaProcessor *metaProcessor, const char *input_line, cling::Interpreter::CompilationResult &compRes, cling::Value *result)
Let cling process a command line.
static std::string GetSharedLibImmediateDepsSlow(std::string lib, cling::Interpreter *interp, bool skipLoadedLibs=true)
This interface returns a list of dependent libraries in the form: lib libA.so libB....
static clang::ClassTemplateDecl * FindTemplateInNamespace(clang::Decl *decl)
Find a template decl within N nested namespaces, 0<=N<inf Assumes 1 and only 1 template present and 1...
static void PrintDlError(const char *dyLibName, const char *modulename)
void TCling__LibraryLoadedRTTI(const void *dyLibHandle, const char *canonicalName)
static cling::Interpreter::CompilationResult ExecAutoParse(const char *what, Bool_t header, cling::Interpreter *interpreter)
Parse the payload or header.
static GlobalModuleIndex * loadGlobalModuleIndex(SourceLocation TriggerLoc, cling::Interpreter &interp)
TObject * TCling__GetObjectAddress(const char *Name, void *&LookupCtx)
static void LoadModules(const std::vector< std::string > &modules, cling::Interpreter &interp)
Loads the C++ modules that we require to run any ROOT program.
int TCling__IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *nsDecl)
static bool hasPrecomputedLibraryDeps(llvm::StringRef lib)
void TCling__SplitAclicMode(const char *fileName, string &mode, string &args, string &io, string &fname)
void Info(const char *location, const char *msgfmt,...)
void Error(const char *location, const char *msgfmt,...)
R__EXTERN Int_t gErrorIgnoreLevel
void Warning(const char *location, const char *msgfmt,...)
void Fatal(const char *location, const char *msgfmt,...)
R__EXTERN TVirtualMutex * gInterpreterMutex
#define R__LOCKGUARD_CLING(mutex)
R__EXTERN TInterpreter * gCling
char * Form(const char *fmt,...)
typedef void((*Func_t)())
Bool_t R_ISREG(Int_t mode)
R__EXTERN TSystem * gSystem
R__EXTERN TVirtualMutex * gGlobalMutex
#define R__LOCKGUARD(mutex)
#define R__WRITE_LOCKGUARD(mutex)
#define R__READ_LOCKGUARD(mutex)
virtual std::unique_ptr< StateDelta > Rewind(const State &earlierState)=0
virtual void Apply(std::unique_ptr< StateDelta > &&delta)=0
virtual std::unique_ptr< State > GetStateBefore()=0
static Long_t ExecuteFile(const char *file, Int_t *error=0, Bool_t keep=kFALSE)
Execute a file containing a C++ macro (static method).
virtual TApplicationImp * GetApplicationImp()
virtual Bool_t IsCmdThread()
Each class (see TClass) has a linked list of its base class(es).
TClassRef is used to implement a permanent reference to a TClass object.
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
static TProtoClass * GetProtoNorm(const char *cname)
Given the class normalized name returns the TClassProto object for the class.
static DictFuncPtr_t GetDictNorm(const char *cname)
Given the normalized class name returns the Dictionary() function of a class (uses hash of name).
static TProtoClass * GetProto(const char *cname)
Given the class name returns the TClassProto object for the class.
static Bool_t Check(const char *cname, std::string &normname)
static void Add(const char *cname, Version_t id, const std::type_info &info, DictFuncPtr_t dict, Int_t pragmabits)
Add a class to the class table (this is a static function).
TClass instances represent classes, structs and namespaces in the ROOT type system.
TDataMember * GetDataMember(const char *datamember) const
Return pointer to datamember object with name "datamember".
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
EState fState
cached of the streaming method to use
std::atomic< TList * > fBase
static void AddClassToDeclIdMap(TDictionary::DeclId_t id, TClass *cl)
static: Add a TClass* to the map of classes.
TList * GetListOfFunctionTemplates(Bool_t load=kTRUE)
Return list containing the TEnums of a class.
void * DynamicCast(const TClass *base, void *obj, Bool_t up=kTRUE)
Cast obj of this class type up to baseclass cl if up is true.
static void RemoveClassDeclId(TDictionary::DeclId_t id)
Bool_t CallShowMembers(const void *obj, TMemberInspector &insp, Bool_t isTransient=kFALSE) const
Call ShowMembers() on the obj of this class type, passing insp and parent.
std::atomic< TListOfEnums * > fEnums
static Bool_t HasNoInfoOrEmuOrFwdDeclaredDecl(const char *)
virtual void PostLoadCheck()
Do the initialization that can only be done after the CINT dictionary has been fully populated and ca...
static TClass * LoadClass(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
Int_t Size() const
Return size of object of this class.
TObjArray * fStreamerInfo
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
ClassInfo_t * GetClassInfo() const
Long_t Property() const
Returns the properties of the TClass as a bit field stored as a Long_t value.
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
void ResetCaches()
To clean out all caches.
static Int_t ReadRules()
Read the class.rules files from the default location:.
Version_t GetClassVersion() const
std::atomic< Bool_t > fHasRootPcmInfo
C++ Property of the class (is abstract, has virtual table, etc.)
const char * GetDeclFileName() const
Return name of the file containing the declaration of this class.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Emulation of the CINT BaseClassInfo class.
const char * TmpltName() const
const char * Name() const
ptrdiff_t Offset(void *address=0, bool isDerivedObject=true) const
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
TClingClassInfo * GetBase() const
Emulation of the CINT CallFunc class.
long ExecInt(void *address)
void SetArgs(const char *args)
void SetFunc(const TClingClassInfo *info, const char *method, const char *arglist, long *poffset)
void ExecWithArgsAndReturn(void *address, const void *args[]=0, int nargs=0, void *ret=0)
void Exec(void *address, TInterpreterValue *interpVal=0)
TClingMethodInfo * FactoryMethod() const
bool IsAutoLoadingEnabled()
void SetAutoParsingSuspended(bool val=true)
void SetAutoLoadingEnabled(bool val=true)
Emulation of the CINT ClassInfo class.
static bool IsEnum(cling::Interpreter *interp, const char *name)
long ClassProperty() const
void Init(const char *name)
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
EDataType GetUnderlyingType() const
TClingMethodInfo GetMethodWithArgs(const char *fname, const char *arglist, long *poffset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch, EInheritanceMode imode=kWithInheritance) const
const char * TmpltName() const
const clang::Type * GetType() const
ptrdiff_t GetBaseOffset(TClingClassInfo *toBase, void *address, bool isDerivedObject)
bool IsScopedEnum() const
ROOT::TMetaUtils::EIOCtorCategory HasDefaultConstructor(bool checkio=false, std::string *type_name=nullptr) const
const clang::FunctionTemplateDecl * GetFunctionTemplate(const char *fname) const
int GetMethodNArg(const char *method, const char *proto, Bool_t objectIsConst, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
bool HasMethod(const char *name) const
TDictionary::DeclId_t GetDeclId() const
void DeleteArray(void *arena, bool dtorOnly, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
void * New(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
bool IsValidMethod(const char *method, const char *proto, Bool_t objectIsConst, long *offset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
TClingMethodInfo GetMethod(const char *fname) const
const clang::ValueDecl * GetDataMember(const char *name) const
void Destruct(void *arena, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
std::vector< std::string > GetUsingNamespaces()
bool IsBase(const char *name) const
void Delete(void *arena, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Emulation of the CINT DataMemberInfo class.
const char * TypeName() const
const char * TypeTrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
int MaxIndex(int dim) const
llvm::StringRef ValidArrayIndex() const
const char * Name() const override
long TypeProperty() const
virtual const char * Name() const
virtual bool IsValid() const
virtual const clang::Decl * GetDecl() const
Emulation of the CINT MethodInfo class.
bool IsValid() const override
const char * DefaultValue() const
const TClingTypeInfo * Type() const
const char * TypeName() const
Emulation of the CINT MethodInfo class.
std::string GetMangledName() const
const char * TypeName() const
const char * Name() const override
void * InterfaceMethod(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
const clang::FunctionDecl * GetTargetFunctionDecl() const
Get the FunctionDecl, or if this represents a UsingShadowDecl, the underlying target FunctionDecl.
const char * GetPrototype()
long ExtraProperty() const
void CreateSignature(TString &signature) const
TDictionary::DeclId_t GetDeclId() const
TClingTypeInfo * Type() const
Emulation of the CINT TypeInfo class.
std::string NormalizedName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Return the normalized name of the type (i.e.
const char * Name() const override
bool IsValid() const override
clang::QualType GetQualType() const
void Init(const char *name)
const char * TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Return the normalized name of the type (i.e.
Emulation of the CINT TypedefInfo class.
const char * TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Get the name of the underlying type of the current typedef.
long Property() const
Return a bit mask of metadata about the current typedef.
const char * Name() const override
Get the name of the current typedef.
void Init(const char *name)
Lookup named typedef and reset the iterator to point to it.
int Next()
Increment the iterator.
int Size() const
Return the size in bytes of the underlying type of the current typedef.
Bridge between cling::Value and ROOT.
bool Append(const std::string &str)
Append string to the storage if not added already.
This class defines an interface to the cling C++ interpreter.
virtual const char * MethodArgInfo_DefaultValue(MethodArgInfo_t *marginfo) const
virtual std::string CallFunc_GetWrapperCode(CallFunc_t *func) const
virtual void FuncTempInfo_Name(FuncTempInfo_t *, TString &name) const
Return the name of this function template.
virtual void FuncTempInfo_Title(FuncTempInfo_t *, TString &name) const
Return the comments associates with this function template.
virtual int TypedefInfo_Next(TypedefInfo_t *tinfo) const
virtual bool DiagnoseIfInterpreterException(const std::exception &e) const
virtual bool ClassInfo_IsValid(ClassInfo_t *info) const
virtual bool ClassInfo_IsScopedEnum(ClassInfo_t *info) const
Long_t Calc(const char *line, EErrorCode *error=0)
Directly execute an executable statement (e.g.
Bool_t HasPCMForLibrary(const char *libname) const
Return true if ROOT has cxxmodules pcm for a given library name.
virtual MethodInfo_t * MethodInfo_FactoryCopy(MethodInfo_t *minfo) const
virtual const char * TypeInfo_Name(TypeInfo_t *) const
DeclId_t GetFunction(ClassInfo_t *cl, const char *funcname)
Return pointer to cling interface function for a method of a class with a certain name.
bool LibraryLoadingFailed(const std::string &, const std::string &, bool, bool)
virtual bool ClassInfo_HasMethod(ClassInfo_t *info, const char *name) const
std::vector< void * > fRegisterModuleDyLibs
virtual MethodInfo_t * CallFunc_FactoryMethod(CallFunc_t *func) const
virtual bool MethodInfo_IsValid(MethodInfo_t *minfo) const
std::vector< std::string > fAutoLoadLibStorage
virtual const char * DataMemberInfo_TypeTrueName(DataMemberInfo_t *dminfo) const
void CreateListOfDataMembers(TClass *cl) const
Create list of pointers to data members for TClass cl.
void UnRegisterTClassUpdate(const TClass *oldcl)
If the dictionary is loaded, we can remove the class from the list (otherwise the class might be load...
void HandleNewDecl(const void *DV, bool isDeserialized, std::set< TClass * > &modifiedClasses)
void InvalidateCachedDecl(const std::tuple< TListOfDataMembers *, TListOfFunctions *, TListOfFunctionTemplates *, TListOfEnums * > &Lists, const clang::Decl *D)
Invalidate cached TCling information for the given declaration, and removed it from the appropriate o...
virtual const char * MethodInfo_TypeName(MethodInfo_t *minfo) const
bool RegisterPrebuiltModulePath(const std::string &FullPath, const std::string &ModuleMapName="module.modulemap") const
virtual Long_t TypedefInfo_Property(TypedefInfo_t *tinfo) const
virtual void MethodArgInfo_Delete(MethodArgInfo_t *marginfo) const
virtual void LoadFunctionTemplates(TClass *cl) const
Create list of pointers to function templates for TClass cl.
virtual CallFunc_t * CallFunc_Factory() const
virtual TypedefInfo_t * TypedefInfo_FactoryCopy(TypedefInfo_t *tinfo) const
std::vector< const char * > fCurExecutingMacros
void UpdateListsOnCommitted(const cling::Transaction &T)
virtual void SetAllocunlockfunc(void(*)()) const
[Place holder for Mutex Unlock] Provide the interpreter with a way to release a lock used to protect ...
virtual Long_t ClassInfo_Tagnum(ClassInfo_t *info) const
void UpdateListOfTypes()
No op: see TClingCallbacks (used to update the list of types)
const char * GetSharedLibDeps(const char *lib, bool tryDyld=false)
Get the list a libraries on which the specified lib depends.
virtual DeclId_t GetDataMemberAtAddr(const void *addr) const
Return pointer to cling DeclId for a data member with a given name.
virtual int DataMemberInfo_ArrayDim(DataMemberInfo_t *dminfo) const
virtual bool ClassInfo_IsBase(ClassInfo_t *info, const char *name) const
virtual int BaseClassInfo_Next(BaseClassInfo_t *bcinfo) const
virtual void GenericError(const char *error) const
Let the interpreter issue a generic error, and set its error state.
virtual std::string MethodArgInfo_TypeNormalizedName(MethodArgInfo_t *marginfo) const
virtual const char * ClassInfo_TmpltName(ClassInfo_t *info) const
virtual TEnum * CreateEnum(void *VD, TClass *cl) const
virtual EReturnType MethodCallReturnType(TFunction *func) const
virtual int UnloadFile(const char *path) const
virtual int Evaluate(const char *, TInterpreterValue &)
Get the interpreter value corresponding to the statement.
TObject * GetObjectAddress(const char *Name, void *&LookupCtx)
If the interpreter encounters Name, check whether that is an object ROOT could retrieve.
virtual Long_t TypeInfo_Property(TypeInfo_t *tinfo) const
DeclId_t GetFunctionWithPrototype(ClassInfo_t *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Return pointer to cling interface function for a method of a class with a certain prototype,...
bool IsClassAutoLoadingEnabled() const
Returns if class AutoLoading is currently enabled.
void InvalidateGlobal(const clang::Decl *D)
Invalidate cached TCling information for the given global declaration.
void EndOfLineAction()
It calls a "fantom" method to synchronize user keyboard input and ROOT prompt line.
DeclId_t GetFunctionWithValues(ClassInfo_t *cl, const char *method, const char *params, Bool_t objectIsConst=kFALSE)
Return pointer to cling DeclId for a method of a class with a certain prototype, i....
void UpdateListOfLoadedSharedLibraries()
void RegisterModule(const char *modulename, const char **headers, const char **includePaths, const char *payloadCode, const char *fwdDeclsCode, void(*triggerFunc)(), const FwdDeclArgsToKeepCollection_t &fwdDeclsArgToSkip, const char **classesHeaders, Bool_t lateRegistration=false, Bool_t hasCxxModule=false)
Inject the module named "modulename" into cling; load all headers.
virtual const char * DataMemberInfo_ValidArrayIndex(DataMemberInfo_t *dminfo) const
void InitRootmapFile(const char *name)
Create a resource table and read the (possibly) three resource files, i.e $ROOTSYS/etc/system<name> (...
void CreateListOfMethodArgs(TFunction *m) const
Create list of pointers to method arguments for TMethod m.
virtual void TypedefInfo_Init(TypedefInfo_t *tinfo, const char *name) const
virtual Long_t MethodInfo_ExtraProperty(MethodInfo_t *minfo) const
void LoadPCM(std::string pcmFileNameFullPath)
Tries to load a rdict PCM, issues diagnostics if it fails.
virtual ~TCling()
Destroy the interpreter interface.
void AddFriendToClass(clang::FunctionDecl *, clang::CXXRecordDecl *) const
Inject function as a friend into klass.
std::vector< MutexStateAndRecurseCount > fInitialMutex
Bool_t fCxxModulesEnabled
void RefreshClassInfo(TClass *cl, const clang::NamedDecl *def, bool alias)
Internal function. Actually do the update of the ClassInfo when seeing.
void ExecuteWithArgsAndReturn(TMethod *method, void *address, const void *args[]=0, int nargs=0, void *ret=0) const
virtual void FuncTempInfo_Delete(FuncTempInfo_t *) const
Delete the FuncTempInfo_t.
Bool_t SetSuspendAutoParsing(Bool_t value)
Suspend the Autoparsing of headers.
virtual DataMemberInfo_t * DataMemberInfo_FactoryCopy(DataMemberInfo_t *dminfo) const
virtual CallFuncIFacePtr_t CallFunc_IFacePtr(CallFunc_t *func) const
virtual void CallFunc_ExecWithReturn(CallFunc_t *func, void *address, void *ret) const
virtual MethodArgInfo_t * MethodArgInfo_Factory() const
virtual void DataMemberInfo_Delete(DataMemberInfo_t *dminfo) const
void ApplyToInterpreterMutex(void *delta)
Re-apply the lock count delta that TCling__ResetInterpreterMutex() caused.
void * LazyFunctionCreatorAutoload(const std::string &mangled_name)
Autoload a library based on a missing symbol.
virtual int LoadFile(const char *path) const
Load a source file or library called path into the interpreter.
void CodeComplete(const std::string &, size_t &, std::vector< std::string > &)
The call to Cling's tab complition.
virtual Long_t FuncTempInfo_Property(FuncTempInfo_t *) const
Return the property of the function template.
virtual TypeInfo_t * MethodInfo_Type(MethodInfo_t *minfo) const
virtual const char * MethodArgInfo_TypeName(MethodArgInfo_t *marginfo) const
Bool_t HandleNewTransaction(const cling::Transaction &T)
Helper function to increase the internal Cling count of transactions that change the AST.
virtual bool ClassInfo_HasDefaultConstructor(ClassInfo_t *info, Bool_t testio=kFALSE) const
virtual bool DataMemberInfo_IsValid(DataMemberInfo_t *dminfo) const
int ReadRootmapFile(const char *rootmapfile, TUniqueString *uniqueString=nullptr)
Read and parse a rootmapfile in its new format, and return 0 in case of success, -1 if the file has a...
Bool_t IsLoaded(const char *filename) const
Return true if the file has already been loaded by cint.
const char * GetSharedLibs()
Return the list of shared libraries loaded into the process.
virtual const char * GetTopLevelMacroName() const
Return the file name of the current un-included interpreted file.
std::map< SpecialObjectLookupCtx_t, SpecialObjectMap_t > fSpecialObjectMaps
virtual DeclId_t GetDataMemberWithValue(const void *ptrvalue) const
NOT IMPLEMENTED.
virtual bool MethodArgInfo_IsValid(MethodArgInfo_t *marginfo) const
Int_t ReloadAllSharedLibraryMaps()
Reload the library map entries coming from all the loaded shared libraries, after first unloading the...
virtual void SetErrmsgcallback(void *p) const
Set a callback to receive error messages.
virtual std::string ToString(const char *type, void *obj)
virtual const char * MethodInfo_Title(MethodInfo_t *minfo) const
virtual Long_t ClassInfo_GetBaseOffset(ClassInfo_t *fromDerived, ClassInfo_t *toBase, void *address, bool isDerivedObject) const
virtual int DataMemberInfo_TypeSize(DataMemberInfo_t *dminfo) const
virtual ClassInfo_t * ClassInfo_Factory(Bool_t all=kTRUE) const
virtual const char * MethodInfo_GetMangledName(MethodInfo_t *minfo) const
virtual bool CallFunc_IsValid(CallFunc_t *func) const
virtual const char * BaseClassInfo_TmpltName(BaseClassInfo_t *bcinfo) const
virtual void SetAlloclockfunc(void(*)()) const
[Place holder for Mutex Lock] Provide the interpreter with a way to acquire a lock used to protect cr...
virtual void MethodInfo_CreateSignature(MethodInfo_t *minfo, TString &signature) const
void SnapshotMutexState(ROOT::TVirtualRWMutex *mtx)
virtual Bool_t ClassInfo_Contains(ClassInfo_t *info, DeclId_t declid) const
Return true if the entity pointed to by 'declid' is declared in the context described by 'info'.
std::set< size_t > fPayloads
virtual const char * ClassInfo_Name(ClassInfo_t *info) const
Int_t UnloadLibraryMap(const char *library)
Unload library map entries coming from the specified library.
virtual ClassInfo_t * BaseClassInfo_ClassInfo(BaseClassInfo_t *) const
TObjArray * fRootmapFiles
virtual void CallFunc_Delete(CallFunc_t *func) const
virtual Long_t ClassInfo_ClassProperty(ClassInfo_t *info) const
cling::Interpreter * GetInterpreterImpl() const
virtual bool ClassInfo_IsLoaded(ClassInfo_t *info) const
std::vector< std::pair< TClass *, DictFuncPtr_t > > fClassesToUpdate
virtual int ClassInfo_GetMethodNArg(ClassInfo_t *info, const char *method, const char *proto, Bool_t objectIsConst=false, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
Int_t DeleteGlobal(void *obj)
Delete obj from Cling symbol table so it cannot be accessed anymore.
virtual const char * GetCurrentMacroName() const
Return the file name of the currently interpreted file, included or not.
virtual void TypeInfo_Delete(TypeInfo_t *tinfo) const
virtual Bool_t LoadText(const char *text) const
Load the declarations from text into the interpreter.
void GetInterpreterTypeName(const char *name, std::string &output, Bool_t full=kFALSE)
The 'name' is known to the interpreter, this function returns the internal version of this name (usua...
void * RewindInterpreterMutex()
Reset the interpreter lock to the state it had before interpreter-related calls happened.
virtual Long_t BaseClassInfo_Offset(BaseClassInfo_t *toBaseClassInfo, void *address, bool isDerivedObject) const
static Int_t DeepAutoLoadImpl(const char *cls)
virtual int GetSecurityError() const
Interface to cling function.
virtual UInt_t FuncTempInfo_TemplateMinReqArgs(FuncTempInfo_t *) const
Return the number of required template arguments of the function template described by ft_info.
void ResetGlobals()
Reset in Cling the list of global variables to the state saved by the last call to TCling::SaveGlobal...
virtual const char * ClassInfo_Title(ClassInfo_t *info) const
virtual Long_t BaseClassInfo_Property(BaseClassInfo_t *bcinfo) const
virtual FuncTempInfo_t * FuncTempInfo_Factory(DeclId_t declid) const
Construct a FuncTempInfo_t.
void * GetInterfaceMethod(TClass *cl, const char *method, const char *params, Bool_t objectIsConst=kFALSE)
Return pointer to cling interface function for a method of a class with parameters params (params is ...
virtual void ClassInfo_Destruct(ClassInfo_t *info, void *arena) const
virtual const char * BaseClassInfo_FullName(BaseClassInfo_t *bcinfo) const
virtual bool ClassInfo_IsEnum(const char *name) const
virtual DataMemberInfo_t * DataMemberInfo_Factory(ClassInfo_t *clinfo, TDictionary::EMemberSelection selection) const
Long_t ProcessLine(const char *line, EErrorCode *error=0)
virtual void TypedefInfo_Delete(TypedefInfo_t *tinfo) const
void SetGetline(const char *(*getlineFunc)(const char *prompt), void(*histaddFunc)(const char *line))
Set a getline function to call when input is needed.
void RewindDictionary()
Rewind Cling dictionary to the point where it was before executing the current macro.
std::map< std::string, llvm::StringRef > fPendingRdicts
virtual const char * MapCppName(const char *) const
Interface to cling function.
static void UpdateClassInfoWork(const char *name)
virtual Long_t FuncTempInfo_ExtraProperty(FuncTempInfo_t *) const
Return the property not already defined in Property See TDictionary's EFunctionProperty.
void PrintIntro()
No-op; see TRint instead.
virtual CallFunc_t * CallFunc_FactoryCopy(CallFunc_t *func) const
virtual const char * DataMemberInfo_Name(DataMemberInfo_t *dminfo) const
Bool_t Declare(const char *code)
Declare code to the interpreter, without any of the interpreter actions that could trigger a re-inter...
Int_t DeleteVariable(const char *name)
Undeclare obj called name.
virtual int ClassInfo_Next(ClassInfo_t *info) const
static void * fgSetOfSpecials
void AddIncludePath(const char *path)
Add the given path to the list of directories in which the interpreter looks for include files.
virtual void CallFunc_SetArgArray(CallFunc_t *func, Long_t *paramArr, Int_t nparam) const
virtual const char * MethodInfo_Name(MethodInfo_t *minfo) const
void ClearFileBusy()
Reset the interpreter internal state in case a previous action was not correctly terminated.
virtual const char * MethodArgInfo_Name(MethodArgInfo_t *marginfo) const
virtual Long_t ClassInfo_Property(ClassInfo_t *info) const
ROOT::TMetaUtils::TNormalizedCtxt * fNormalizedCtxt
virtual int MethodInfo_Next(MethodInfo_t *minfo) const
const char * TypeName(const char *typeDesc)
Return the absolute type of typeDesc.
void SaveContext()
Save the current Cling state.
std::set< TClass * > & GetModTClasses()
virtual bool TypeInfo_IsValid(TypeInfo_t *tinfo) const
Int_t AutoLoad(const char *classname, Bool_t knowDictNotLoaded=kFALSE)
Load library containing the specified class.
TClingCallbacks * fClingCallbacks
TString GetMangledNameWithPrototype(TClass *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Return the cling mangled name for a method of a class with a certain prototype, i....
void RegisterTClassUpdate(TClass *oldcl, DictFuncPtr_t dict)
Register classes that already existed prior to their dictionary loading and that already had a ClassI...
virtual Long_t DataMemberInfo_Property(DataMemberInfo_t *dminfo) const
void UpdateListOfGlobalFunctions()
No op: see TClingCallbacks (used to update the list of global functions)
virtual const char * MethodInfo_GetPrototype(MethodInfo_t *minfo) const
virtual bool ClassInfo_IsValidMethod(ClassInfo_t *info, const char *method, const char *proto, Long_t *offset, ROOT::EFunctionMatchMode=ROOT::kConversionMatch) const
virtual void * ClassInfo_New(ClassInfo_t *info) const
virtual void TypeInfo_Init(TypeInfo_t *tinfo, const char *funcname) const
Bool_t SetErrorMessages(Bool_t enable=kTRUE)
If error messages are disabled, the interpreter should suppress its failures and warning messages fro...
virtual const char * DataMemberInfo_Title(DataMemberInfo_t *dminfo) const
void TransactionRollback(const cling::Transaction &T)
virtual EDataType ClassInfo_GetUnderlyingType(ClassInfo_t *info) const
virtual void CallFunc_Init(CallFunc_t *func) const
virtual UInt_t FuncTempInfo_TemplateNargs(FuncTempInfo_t *) const
Return the maximum number of template arguments of the function template described by ft_info.
TString GetMangledName(TClass *cl, const char *method, const char *params, Bool_t objectIsConst=kFALSE)
Return the cling mangled name for a method of a class with parameters params (params is a string of a...
virtual void SetTempLevel(int val) const
Create / close a scope for temporaries.
virtual DeclId_t GetDataMember(ClassInfo_t *cl, const char *name) const
Return pointer to cling Decl of global/static variable that is located at the address given by addr.
void RegisterTemporary(const TInterpreterValue &value)
virtual void LoadEnums(TListOfEnums &cl) const
Create list of pointers to enums for TClass cl.
virtual void CallFunc_SetArg(CallFunc_t *func, Long_t param) const
virtual Long_t GetExecByteCode() const
This routines used to return the address of the internal wrapper function (of the interpreter) that w...
virtual void * MethodInfo_InterfaceMethod(MethodInfo_t *minfo) const
Int_t UnloadAllSharedLibraryMaps()
Unload the library map entries coming from all the loaded shared libraries.
virtual void CallFunc_IgnoreExtraArgs(CallFunc_t *func, bool ignore) const
std::vector< cling::Value > * fTemporaries
virtual Long_t MethodInfo_Property(MethodInfo_t *minfo) const
virtual std::unique_ptr< TInterpreterValue > MakeInterpreterValue() const
virtual Long_t DataMemberInfo_Offset(DataMemberInfo_t *dminfo) const
static Int_t ShallowAutoLoadImpl(const char *cls)
void LibraryLoaded(const void *dyLibHandle, const char *canonicalName)
virtual TypedefInfo_t * TypedefInfo_Factory() const
void UpdateListOfGlobals()
No op: see TClingCallbacks (used to update the list of globals)
void ClearStack()
Delete existing temporary values.
std::map< const cling::Transaction *, size_t > fTransactionHeadersMap
virtual int SetClassAutoparsing(int)
Enable/Disable the Autoparsing of headers.
Bool_t fHeaderParsingOnDemand
virtual int SetClassAutoLoading(int) const
Enable/Disable the AutoLoading of libraries.
Int_t RescanLibraryMap()
Scan again along the dynamic path for library maps.
virtual int DataMemberInfo_Next(DataMemberInfo_t *dminfo) const
void Reset()
Pressing Ctrl+C should forward here.
Int_t Load(const char *filenam, Bool_t system=kFALSE)
Load a library file in cling's memory.
void InspectMembers(TMemberInspector &, const void *obj, const TClass *cl, Bool_t isTransient)
Visit all members over members, recursing over base classes.
std::hash< std::string > fStringHashFunction
const char * GetIncludePath()
Refresh the list of include paths known to the interpreter and return it with -I prepended.
static void RemoveAndInvalidateObject(List &L, Object *O)
virtual void ClassInfo_DeleteArray(ClassInfo_t *info, void *arena, bool dtorOnly) const
virtual void GetFunctionName(const clang::Decl *decl, std::string &name) const
Long_t ExecuteMacro(const char *filename, EErrorCode *error=0)
Execute a cling macro.
virtual DeclId_t GetEnum(TClass *cl, const char *name) const
Return pointer to cling Decl of global/static variable that is located at the address given by addr.
void GetFunctionOverloads(ClassInfo_t *cl, const char *funcname, std::vector< DeclId_t > &res) const
Insert overloads of name in cl to res.
virtual void CallFunc_Exec(CallFunc_t *func, void *address) const
virtual int DisplayIncludePath(FILE *fout) const
Interface to cling function.
void RegisterLoadedSharedLibrary(const char *name)
Register a new shared library name with the interpreter; add it to fSharedLibs.
virtual void UpdateEnumConstants(TEnum *enumObj, TClass *cl) const
void SaveGlobalsContext()
Save the current Cling state of global objects.
std::unordered_set< const clang::NamespaceDecl * > fNSFromRootmaps
void ProcessClassesToUpdate()
virtual Long_t MethodArgInfo_Property(MethodArgInfo_t *marginfo) const
virtual const char * GetSTLIncludePath() const
Return the directory containing CINT's stl cintdlls.
Int_t LoadLibraryMap(const char *rootmapfile=0)
Load map between class and library.
virtual std::string MethodInfo_TypeNormalizedName(MethodInfo_t *minfo) const
void Execute(const char *function, const char *params, int *error=0)
Execute a global function with arguments params.
virtual const char * ClassInfo_FullName(ClassInfo_t *info) const
TClass * GenerateTClass(const char *classname, Bool_t emulation, Bool_t silent=kFALSE)
Generate a TClass for the given class.
virtual int TypeInfo_Size(TypeInfo_t *tinfo) const
virtual int MethodArgInfo_Next(MethodArgInfo_t *marginfo) const
ROOT::TMetaUtils::TClingLookupHelper * fLookupHelper
virtual const char * TypedefInfo_TrueName(TypedefInfo_t *tinfo) const
Bool_t fIsAutoParsingSuspended
TClass * GetClass(const std::type_info &typeinfo, Bool_t load) const
Demangle the name (from the typeinfo) and then request the class via the usual name based interface (...
DeclId_t GetDeclId(const llvm::GlobalValue *gv) const
Return pointer to cling DeclId for a global value.
Long_t ProcessLineAsynch(const char *line, EErrorCode *error=0)
Let cling process a command line asynch.
virtual std::vector< std::string > GetUsingNamespaces(ClassInfo_t *cl) const
Get the scopes representing using declarations of namespace.
Int_t SetClassSharedLibs(const char *cls, const char *libs)
Register the AutoLoading information for a class.
virtual void ClassInfo_Init(ClassInfo_t *info, const char *funcname) const
virtual TypeInfo_t * TypeInfo_FactoryCopy(TypeInfo_t *) const
Bool_t CheckClassTemplate(const char *name)
Return true if there is a class template by the given name ...
void LoadPCMImpl(TFile &pcmFile)
Tries to load a PCM from TFile; returns true on success.
Bool_t IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *nsDecl)
TObjArray * GetRootMapFiles() const
void * fPrevLoadedDynLibInfo
void UpdateListOfDataMembers(TClass *cl) const
Update the list of pointers to data members for TClass cl This is now a nop.
virtual void SetDeclAttr(DeclId_t, const char *)
virtual Long_t DataMemberInfo_TypeProperty(DataMemberInfo_t *dminfo) const
virtual const char * DataMemberInfo_TypeName(DataMemberInfo_t *dminfo) const
virtual void CallFunc_SetArgs(CallFunc_t *func, const char *param) const
virtual const char * BaseClassInfo_Name(BaseClassInfo_t *bcinfo) const
virtual void MethodInfo_Delete(MethodInfo_t *minfo) const
Interface to cling function.
virtual const char * TypeInfo_TrueName(TypeInfo_t *tinfo) const
std::set< const char * > fParsedPayloadsAddresses
ECheckClassInfo CheckClassInfo(const char *name, Bool_t autoload, Bool_t isClassOrNamespaceOnly=kFALSE)
Checks if an entity with the specified name is defined in Cling.
static void UpdateClassInfo(char *name, Long_t tagnum)
No op: see TClingCallbacks.
virtual void BaseClassInfo_Delete(BaseClassInfo_t *bcinfo) const
void ResetGlobalVar(void *obj)
Reset the Cling 'user' global objects/variables state to the state saved by the last call to TCling::...
std::unique_ptr< cling::Interpreter > fInterpreter
Bool_t IsLibraryLoaded(const char *libname) const
virtual void Initialize()
Initialize the interpreter, once TROOT::fInterpreter is set.
virtual void * FindSym(const char *entry) const
Interface to cling function.
virtual Long_t CallFunc_ExecInt(CallFunc_t *func, void *address) const
virtual int DataMemberInfo_MaxIndex(DataMemberInfo_t *dminfo, Int_t dim) const
void SetClassInfo(TClass *cl, Bool_t reload=kFALSE)
Set pointer to the TClingClassInfo in TClass.
Long_t ProcessLineSynch(const char *line, EErrorCode *error=0)
Let cling process a command line synchronously, i.e we are waiting it will be finished.
virtual int TypeInfo_RefType(TypeInfo_t *) const
cling::MetaProcessor * GetMetaProcessorImpl() const
void LoadMacro(const char *filename, EErrorCode *error=0)
Load a macro file in cling's memory.
std::set< size_t > fLookedUpClasses
virtual void CallFunc_ResetArg(CallFunc_t *func) const
virtual Long64_t CallFunc_ExecInt64(CallFunc_t *func, void *address) const
virtual Long_t BaseClassInfo_Tagnum(BaseClassInfo_t *bcinfo) const
void ResetAll()
Reset the Cling state to its initial state.
virtual void ClassInfo_Delete(ClassInfo_t *info) const
virtual Double_t CallFunc_ExecDouble(CallFunc_t *func, void *address) const
UInt_t AutoParseImplRecurse(const char *cls, bool topLevel)
Helper routine for TCling::AutoParse implementing the actual call to the parser and looping over temp...
virtual const char * TypedefInfo_Title(TypedefInfo_t *tinfo) const
void CreateListOfBaseClasses(TClass *cl) const
Create list of pointers to base class(es) for TClass cl.
void RecursiveRemove(TObject *obj)
Delete object from cling symbol table so it can not be used anymore.
virtual MethodArgInfo_t * MethodArgInfo_FactoryCopy(MethodArgInfo_t *marginfo) const
void UpdateListsOnUnloaded(const cling::Transaction &T)
Invalidate stored TCling state for declarations included in transaction ‘T’.
void UpdateClassInfoWithDecl(const clang::NamedDecl *ND)
Internal function. Inform a TClass about its new TagDecl or NamespaceDecl.
virtual const char * ClassInfo_FileName(ClassInfo_t *info) const
virtual void CallFunc_ExecWithArgsAndReturn(CallFunc_t *func, void *address, const void *args[]=0, int nargs=0, void *ret=0) const
DeclId_t GetFunctionTemplate(ClassInfo_t *cl, const char *funcname)
Return pointer to cling interface function for a method of a class with a certain name.
virtual int MethodInfo_NArg(MethodInfo_t *minfo) const
virtual FuncTempInfo_t * FuncTempInfo_FactoryCopy(FuncTempInfo_t *) const
Construct a FuncTempInfo_t.
virtual int TypedefInfo_Size(TypedefInfo_t *tinfo) const
std::unique_ptr< cling::MetaProcessor > fMetaProcessor
virtual const char * TypedefInfo_Name(TypedefInfo_t *tinfo) const
virtual void CallFunc_SetFuncProto(CallFunc_t *func, ClassInfo_t *info, const char *method, const char *proto, Long_t *Offset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
Interface to cling function.
virtual int DisplayClass(FILE *fout, const char *name, int base, int start) const
const char * GetClassSharedLibs(const char *cls)
Get the list of shared libraries containing the code for class cls.
Bool_t IsErrorMessagesEnabled() const
If error messages are disabled, the interpreter should suppress its failures and warning messages fro...
ULong64_t fTransactionCount
virtual Bool_t FuncTempInfo_IsValid(FuncTempInfo_t *) const
Check validity of a FuncTempInfo_t.
virtual BaseClassInfo_t * BaseClassInfo_Factory(ClassInfo_t *info) const
virtual bool TypedefInfo_IsValid(TypedefInfo_t *tinfo) const
virtual MethodInfo_t * MethodInfo_Factory() const
Int_t AutoParse(const char *cls)
Parse the headers relative to the class Returns 1 in case of success, 0 in case of failure.
virtual EReturnType MethodInfo_MethodCallReturnType(MethodInfo_t *minfo) const
void * GetInterfaceMethodWithPrototype(TClass *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Return pointer to cling interface function for a method of a class with a certain prototype,...
virtual TypeInfo_t * TypeInfo_Factory() const
std::map< size_t, std::vector< const char * > > fClassesHeadersMap
virtual int MethodInfo_NDefaultArg(MethodInfo_t *minfo) const
Int_t GenerateDictionary(const char *classes, const char *includes="", const char *options=0)
Generate the dictionary for the C++ classes listed in the first argument (in a semi-colon separated l...
virtual void CallFunc_SetFunc(CallFunc_t *func, ClassInfo_t *info, const char *method, const char *params, Long_t *Offset) const
void CreateListOfMethods(TClass *cl) const
Create list of pointers to methods for TClass cl.
void UpdateListOfMethods(TClass *cl) const
Update the list of pointers to method for TClass cl This is now a nop.
void RegisterRdictForLoadPCM(const std::string &pcmFileNameFullPath, llvm::StringRef *pcmContent)
Register Rdict data for future loading by LoadPCM;.
virtual int ClassInfo_Size(ClassInfo_t *info) const
static void UpdateAllCanvases()
Update all canvases at end the terminal input command.
void LibraryUnloaded(const void *dyLibHandle, const char *canonicalName)
Collection abstract base class.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
virtual Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void Add(TObject *obj)=0
All ROOT classes may have RTTI (run time type identification) support added.
Bool_t IsPersistent() const
Basic data type descriptor (datatype information is obtained from CINT).
EMemberSelection
Kinds of members to include in lists.
TList * GetListOfKeys() const override
Small helper to keep current directory context.
void GetObject(const char *namecycle, T *&ptr)
The TEnumConstant class implements the constants of the enum type.
The TEnum class implements the enum type.
const TSeqCollection * GetConstants() const
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
DeclId_t GetDeclId() const
const char * GetValue() const
const char * GetName() const
Returns name of object.
The TEnv class reads config files, by default named .rootrc.
THashList * GetTable() const
Bool_t IgnoreDuplicates(Bool_t ignore)
If set to true, no warnings in case of duplicates are issued.
virtual void SetRcName(const char *name)
virtual Int_t ReadFile(const char *fname, EEnvLevel level)
Read and parse the resource file for a certain level.
virtual TEnvRec * Lookup(const char *n) const
Loop over all resource records and return the one with name.
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=0)
Set the value of a resource or create a new resource.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Global functions class (global functions are obtained from CINT).
Global variables class (global variables are obtained from CINT).
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
TObject * Remove(TObject *obj)
Remove object from the list.
THashTable implements a hash table to store TObject's.
virtual const void * GetValAddr() const =0
This class defines an abstract interface to a generic command line interpreter.
virtual bool RegisterPrebuiltModulePath(const std::string &FullPath, const std::string &ModuleMapName="module.modulemap") const =0
virtual Bool_t HasPCMForLibrary(const char *libname) const =0
virtual Int_t AutoParse(const char *cls)=0
int(* AutoLoadCallBack_t)(const char *)
virtual const char * GetClassSharedLibs(const char *cls)=0
friend class SuspendAutoParsing
virtual Bool_t Declare(const char *code)=0
std::vector< std::pair< std::string, int > > FwdDeclArgsToKeepCollection_t
TDictionary::DeclId_t DeclId_t
virtual TObjArray * GetRootMapFiles() const =0
Book space in a file, create I/O buffers, to fill them, (un)compress them.
A collection of TDataMember objects designed for fast access given a DeclId_t and for keep track of T...
TDictionary * Find(DeclId_t id) const
Return (after creating it if necessary) the TDataMember describing the data member corresponding to t...
TClass * GetClass() const
virtual TObject * FindObject(const char *name) const
Specialize FindObject to do search for the a data member just by name or create it if its not already...
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
TEnum * Find(DeclId_t id) const
Return the TEnum corresponding to the Decl 'id' or NULL if it does not exist.
TEnum * Get(DeclId_t id, const char *name)
Return (after creating it if necessary) the TEnum describing the enum corresponding to the Decl 'id'.
TClass * GetClass() const
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TFunctionTemplate * Get(DeclId_t id)
Return (after creating it if necessary) the TMethod or TFunction describing the function correspondin...
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TFunction * Find(DeclId_t id) const
Return the TMethod or TFunction describing the function corresponding to the Decl 'id'.
virtual void Add(TObject *obj)
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
A TMemFile is like a normal TFile except that it reads and writes only from memory.
Abstract base class for accessing the data-members of a class.
const char * GetParent() const
virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr)
EObjectPointerState GetObjectValidity() const
virtual Bool_t IsTreatingNonAccessibleTypes()
void SetObjectValidity(EObjectPointerState val)
void InspectMember(const T &obj, const char *name, Bool_t isTransient)
Each ROOT method (see TMethod) has a linked list of its arguments.
const char * GetFullTypeName() const
Get full type description of method argument, e.g.: "class TDirectory*".
const char * GetDefault() const
Get default value of method argument.
Each ROOT class (see TClass) has a linked list of methods.
virtual TList * GetListOfMethodArgs()
Returns methodarg list and additionally updates fDataMember in TMethod by calling FindDataMember();.
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetName() const
Returns name of object.
Int_t GetEntriesFast() const
virtual void Expand(Int_t newSize)
Expand or shrink the array to newSize elements.
virtual void Compress()
Remove empty slots from array.
Int_t GetEntries() const
Return the number of objects in array (i.e.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
virtual TObject * Remove(TObject *obj)
Remove object from array.
TObject * At(Int_t idx) const
Collectable string class.
Mother of all ROOT objects.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
R__ALWAYS_INLINE Bool_t IsOnHeap() const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual const char * GetTitle() const
Returns title of object.
@ kInvalidObject
if object ctor succeeded but object should not be used
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Persistent version of a TClass.
static const TString & GetIncludeDir()
Get the include directory in the installation. Static utility function.
static const char * GetMacroPath()
Get macro search path. Static utility function.
virtual ~TROOT()
Clean up and free resources used by ROOT (files, network sockets, shared memory segments,...
static const std::vector< std::string > & AddExtraInterpreterArgs(const std::vector< std::string > &args)
Provide command line arguments to the interpreter construction.
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
static const char **& GetExtraInterpreterArgs()
INTERNAL function! Used by rootcling to inject interpreter arguments through a C-interface layer.
static const TString & GetLibDir()
Get the library directory in the installation. Static utility function.
Describe Streamer information for one class version.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Ssiz_t Last(char c) const
Find last occurrence of a character c.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Prepend(const char *cs)
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual void FreeDirectory(void *dirp)
Free a directory.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
virtual const char * Getenv(const char *env)
Get environment variable.
virtual const char * GetIncludePath()
Get the list of include path.
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form:
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
virtual int GetProcInfo(ProcInfo_t *info) const
Returns cpu and memory used by this process into the ProcInfo_t structure.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual const char * GetDynamicPath()
Return the dynamic path (used to find shared libraries).
virtual const char * FindDynamicLibrary(TString &lib, Bool_t quiet=kFALSE)
Find a dynamic library using the system search paths.
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual int CompileMacro(const char *filename, Option_t *opt="", const char *library_name="", const char *build_dir="", UInt_t dirmode=0)
This method compiles and loads a shared library containing the code from the file "filename".
virtual const char * WorkingDirectory()
Return working directory.
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual void Setenv(const char *name, const char *value)
Set environment variable.
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
virtual void StackTrace()
Print a stack trace.
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
virtual TVirtualMutex * Factory(Bool_t=kFALSE)=0
TVirtualPad is an abstract base class for the Pad and Canvas classes.
static void SetFactory(TVirtualStreamerInfo *factory)
static function: Set the StreamerInfo factory
@ kNeedObjectForVirtualBaseClass
Type
enumeration specifying the integration types.
RPY_EXPORTED TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
const std::string & GetPathSeparator()
const char & GetEnvPathSeparator()
R__EXTERN TROOT * gROOTLocal
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
RVec< T > Filter(const RVec< T > &v, F &&f)
Create a new collection with the elements passing the filter expressed by the predicate.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
R__EXTERN TVirtualRWMutex * gCoreMutex
V GetOffset(E val1, E val2, V iso)
RooArgSet S(const RooAbsArg &v1)
bool IsStdPairBase(std::string_view name)
bool IsStdArray(std::string_view name)
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
bool IsStdPair(std::string_view name)
std::string InsertStd(const char *tname)
bool SplitFunction(std::string_view decl, FunctionSplitInfo &result)
Split a function declaration into its different parts.
std::string GetLong64_Name(const char *original)
Replace 'long long' and 'unsigned long long' by 'Long64_t' and 'ULong64_t'.
char * DemangleTypeIdName(const std::type_info &ti, int &errorCode)
Demangle in a portable way the type id name.
const char * GetUnqualifiedName(const char *name)
Return the start of the unqualified name include in 'original'.
void Init(TClassEdit::TInterpreterLookupHelper *helper)
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)
int GetSplit(const char *type, std::vector< std::string > &output, int &nestedLoc, EModType mode=TClassEdit::kNone)
Stores in output (after emptying it) the split type.
EComplexType GetComplexType(const char *)
static constexpr double s
static constexpr double ns
static constexpr double L
constexpr Double_t E()
Base of natural log:
RAII used to store Parser, Sema, Preprocessor state for recursive parsing.
State as returned by GetStateDelta() that can be passed to Restore()
Result of splitting a function declaration into fReturnType fScopeName::fFunctionName<fFunctionTempla...
std::string fScopeName
Name of the scope qualification of the function, possibly empty.
std::vector< std::string > fElements
void ShortType(std::string &answer, int mode)
Return the absolute type of typeDesc into the string answ.
A read-only memory range which we do not control.
static void output(int code)