63#include "RConfigure.h"
64#define ROOT_compiledata_cxx
65#include "compiledata.h"
83#include "clang/AST/ASTContext.h"
84#include "clang/AST/Decl.h"
85#include "clang/AST/DeclarationName.h"
86#include "clang/AST/GlobalDecl.h"
87#include "clang/AST/RecordLayout.h"
88#include "clang/AST/DeclVisitor.h"
89#include "clang/AST/RecursiveASTVisitor.h"
90#include "clang/AST/Type.h"
91#include "clang/Basic/SourceLocation.h"
92#include "clang/Basic/Specifiers.h"
93#include "clang/Basic/TargetInfo.h"
94#include "clang/CodeGen/ModuleBuilder.h"
95#include "clang/Frontend/CompilerInstance.h"
96#include "clang/Frontend/FrontendDiagnostic.h"
97#include "clang/Lex/HeaderSearch.h"
98#include "clang/Lex/Preprocessor.h"
99#include "clang/Lex/PreprocessorOptions.h"
100#include "clang/Parse/Parser.h"
101#include "clang/Sema/Lookup.h"
102#include "clang/Sema/Sema.h"
103#include "clang/Serialization/ASTReader.h"
104#include "clang/Serialization/GlobalModuleIndex.h"
106#include "cling/Interpreter/ClangInternalState.h"
107#include "cling/Interpreter/DynamicLibraryManager.h"
108#include "cling/Interpreter/Interpreter.h"
109#include "cling/Interpreter/LookupHelper.h"
110#include "cling/Interpreter/Value.h"
111#include "cling/Interpreter/Transaction.h"
112#include "cling/MetaProcessor/MetaProcessor.h"
113#include "cling/Utils/AST.h"
114#include "cling/Utils/ParserStateRAII.h"
115#include "cling/Utils/SourceNormalization.h"
116#include "cling/Interpreter/Exception.h"
118#include <CppInterOp/CppInterOp.h>
120#include "llvm/IR/GlobalValue.h"
121#include "llvm/IR/Module.h"
123#include "llvm/Support/DynamicLibrary.h"
124#include "llvm/Support/raw_ostream.h"
125#include "llvm/Support/Path.h"
126#include "llvm/Support/Process.h"
127#include "llvm/Object/ELFObjectFile.h"
128#include "llvm/Object/ObjectFile.h"
129#include "llvm/Object/SymbolicFile.h"
130#include "llvm/Support/FileSystem.h"
145#include <unordered_map>
146#include <unordered_set>
154#define R__DLLEXPORT __attribute__ ((visibility ("default")))
162#include <mach-o/dyld.h>
163#include <mach-o/loader.h>
170#if defined(R__LINUX) || defined(R__FBSD)
177#if defined(__CYGWIN__)
178#include <sys/cygwin.h>
179#define HMODULE void *
181 __declspec(dllimport)
void * __stdcall GetCurrentProcess();
182 __declspec(dllimport)
bool __stdcall EnumProcessModules(
void *,
void **,
unsigned long,
unsigned long *);
183 __declspec(dllimport)
unsigned long __stdcall GetModuleFileNameExW(
void *,
void *,
wchar_t *,
unsigned long);
190# define STDIN_FILENO 0
193# define STDOUT_FILENO 1
196# define STDERR_FILENO 2
206#undef GetModuleFileName
207#define RTLD_DEFAULT ((void *)::GetModuleHandle(NULL))
208#define dlsym(library, function_name) ::GetProcAddress((HMODULE)library, function_name)
209#define dlopen(library_name, flags) ::LoadLibraryA(library_name)
210#define dlclose(library) ::FreeLibrary((HMODULE)library)
211#define R__DLLEXPORT __declspec(dllexport)
219 return D->getDeclContext();
222 return llvm::dyn_cast<clang::NamespaceDecl>(DC);
225 return llvm::dyn_cast<clang::RecordDecl>(DC);
228 return DC->dumpDeclContext();
237 return ((clang::Decl*)D)->dump();
240 if (clang::NamedDecl* ND = llvm::dyn_cast<clang::NamedDecl>(D)) {
243 llvm::raw_string_ostream OS(
name);
244 ND->getNameForDiagnostic(OS, D->getASTContext().getPrintingPolicy(),
247 printf(
"%s\n",
name.c_str());
255 return D->isInvalidDecl();
259 assert(info && info->IsValid());
260 return info->GetDecl()->isInvalidDecl();
263using std::string, std::vector;
264using namespace clang;
268 static const std::string gInterpreterClassDef = R
"ICF(
270#define ClassDef(name, id) \
271_ClassDefInterp_(name,id,virtual,) \
272static int DeclFileLine() { return __LINE__; }
274#define ClassDefNV(name, id) \
275_ClassDefInterp_(name,id,,) \
276static int DeclFileLine() { return __LINE__; }
277#undef ClassDefOverride
278#define ClassDefOverride(name, id) \
279_ClassDefInterp_(name,id,,override) \
280static int DeclFileLine() { return __LINE__; }
283 static const std::string gNonInterpreterClassDef = R
"ICF(
284#define __ROOTCLING__ 1
286#define ClassDef(name,id) \
287_ClassDefOutline_(name,id,virtual,) \
288static int DeclFileLine() { return __LINE__; }
290#define ClassDefNV(name, id)\
291_ClassDefOutline_(name,id,,)\
292static int DeclFileLine() { return __LINE__; }
293#undef ClassDefOverride
294#define ClassDefOverride(name, id)\
295_ClassDefOutline_(name,id,,override)\
296static int DeclFileLine() { return __LINE__; }
300 static const std::string gClassDefInterpMacro = R
"ICF(
303#define _ClassDefInterp_(name,id,virtual_keyword, overrd) \
306 static TClass *Class() { static TClass* sIsA = 0; if (!sIsA) sIsA = TClass::GetClass(#name); return sIsA; } \
307 static const char *Class_Name() { return #name; } \
308 virtual_keyword Bool_t CheckTObjectHashConsistency() const overrd { \
309 static std::atomic<UChar_t> recurseBlocker(0); \
310 if (R__likely(recurseBlocker >= 2)) { \
311 return ::ROOT::Internal::THashConsistencyHolder<decltype(*this)>::fgHashConsistency; \
312 } else if (recurseBlocker == 1) { \
314 } else if (recurseBlocker++ == 0) { \
315 ::ROOT::Internal::THashConsistencyHolder<decltype(*this)>::fgHashConsistency = \
316 ::ROOT::Internal::HasConsistentHashMember(_QUOTE_(name)) || \
317 ::ROOT::Internal::HasConsistentHashMember(*IsA()); \
319 return ::ROOT::Internal::THashConsistencyHolder<decltype(*this)>::fgHashConsistency; \
321 return false; /* unreachable */ \
323 static Version_t Class_Version() { return id; } \
324 static TClass *Dictionary() { return 0; } \
325 virtual_keyword TClass *IsA() const overrd { return name::Class(); } \
326 virtual_keyword void ShowMembers(TMemberInspector&insp) const overrd { ::ROOT::Class_ShowMembers(name::Class(), this, insp); } \
327 virtual_keyword void Streamer(TBuffer&) overrd { ::Error("Streamer", "Cannot stream interpreted class."); } \
328 void StreamerNVirtual(TBuffer&ClassDef_StreamerNVirtual_b) { name::Streamer(ClassDef_StreamerNVirtual_b); } \
329 static const char *DeclFileName() { return __FILE__; } \
330 static int ImplFileLine() { return 0; } \
331 static const char *ImplFileName() { return __FILE__; }
371 return ((
TCling*)
gCling)->LibraryLoadingFailed(errmessage, libStem, permanent, resolved);
410 static vector<const NamedDecl*> updateList;
413 if (entered) topLevel =
kFALSE;
428 updateList.push_back(TD);
431 while (!updateList.empty()) {
433 updateList.pop_back();
440 const clang::Decl* D =
static_cast<const clang::Decl*
>(enumObj->GetDeclId());
441 if(
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(D)) {
443 for (EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(),
444 EDE = ED->enumerator_end(); EDI != EDE; ++EDI) {
446 std::string constbuf;
447 if (
const NamedDecl* END = llvm::dyn_cast<NamedDecl>(*EDI)) {
448 PrintingPolicy Policy((*EDI)->getASTContext().getPrintingPolicy());
449 llvm::raw_string_ostream stream(constbuf);
451 Policy.AnonymousTagLocations =
false;
452 (END)->getNameForDiagnostic(stream, Policy,
false);
454 const char* constantName = constbuf.c_str();
458 const llvm::APSInt valAPSInt = (*EDI)->getInitVal();
459 if (valAPSInt.isSigned()) {
460 value = valAPSInt.getSExtValue();
462 value = valAPSInt.getZExtValue();
469 DataMemberInfo_t* dmInfo = (DataMemberInfo_t*) tcDmInfo;
479 if (!globals->FindObject(constantName)) {
480 globals->
Add(enumConstant);
492 TEnum* enumType =
nullptr;
493 const clang::Decl* D =
static_cast<const clang::Decl*
>(VD);
495 if (
const EnumDecl* ED = llvm::dyn_cast<EnumDecl>(D)) {
497 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
498 llvm::raw_string_ostream stream(buf);
500 Policy.AnonymousTagLocations =
false;
501 ED->getNameForDiagnostic(stream, Policy,
false);
507 const char*
name = buf.c_str();
518 const clang::Decl* D =
static_cast<const clang::Decl*
>(DV);
520 if (!D->isCanonicalDecl() && !isa<clang::NamespaceDecl>(D)
521 && !dyn_cast<clang::RecordDecl>(D))
return;
523 if (isa<clang::FunctionDecl>(D->getDeclContext())
524 || isa<clang::TagDecl>(D->getDeclContext()))
528 if (
const clang::CXXRecordDecl* RD = dyn_cast<clang::CXXRecordDecl>(D)) {
529 if (RD->getDescribedClassTemplate())
531 }
else if (
const clang::FunctionDecl* FD = dyn_cast<clang::FunctionDecl>(D)) {
532 if (FD->getDescribedFunctionTemplate())
536 if (
const RecordDecl *TD = dyn_cast<RecordDecl>(D)) {
537 if (TD->isCanonicalDecl() || TD->isThisDeclarationADefinition())
540 else if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
542 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
546 }
else if (
const NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(D)) {
551 if (!isa<TranslationUnitDecl>(ND->getDeclContext()))
555 if (isa<EnumDecl>(ND))
560 if (!(isa<VarDecl>(ND)))
564 if (
gROOT->GetListOfGlobals()->FindObject(ND->getNameAsString().c_str()))
568 gROOT->GetListOfGlobals()->Add(
new TGlobal((DataMemberInfo_t *)
570 cast<ValueDecl>(ND),
nullptr)));
602 const char* canonicalName) {
603 ((
TCling*)
gCling)->LibraryLoaded(dyLibHandle, canonicalName);
608 ((
TCling *)
gCling)->RegisterRdictForLoadPCM(pcmFileNameFullPath, pcmContent);
612 const char* canonicalName) {
613 ((
TCling*)
gCling)->LibraryUnloaded(dyLibHandle, canonicalName);
619 return ((
TCling*)
gCling)->GetObjectAddress(Name, LookupCtx);
629 auto tcling =
new TCling(
"C++",
"cling C++ Interpreter", argv, interpLibHandle);
653 return ((
TCling*)
gCling)->GetClassSharedLibs(className, skipCore);
664 string file(fileName);
670 string &args,
string &io,
string &fname)
672 string file(fileName);
673 TString f, amode, arguments, aclicio;
675 mode = amode.Data(); args = arguments.
Data();
676 io = aclicio.Data(); fname =
f.Data();
686 char *__unDName(
char *demangled,
const char *mangled,
int out_len,
687 void * (* pAlloc )(
size_t),
void (* pFree )(
void *),
688 unsigned short int flags);
700 using namespace clang;
701 if (NamespaceDecl* nsd = llvm::dyn_cast<NamespaceDecl>(decl)){
705 if (ClassTemplateDecl* ctd = llvm::dyn_cast<ClassTemplateDecl>(decl)){
718 const std::vector<std::string> &headers,
719 const std::vector<std::string> &fwdDecls,
720 const std::vector<std::string> &unknown)
726 if (classes.empty()) {
730 const std::string& className = classes[0];
732 TString fileName =
"AutoDict_";
733 std::string::const_iterator sIt;
734 for (sIt = className.begin(); sIt != className.end(); ++sIt) {
735 if (*sIt ==
'<' || *sIt ==
'>' ||
736 *sIt ==
' ' || *sIt ==
'*' ||
737 *sIt ==
',' || *sIt ==
'&' ||
745 if (classes.size() > 1) {
747 std::vector<std::string>::const_iterator it = classes.begin();
748 while ((++it) != classes.end()) {
750 chk = chk * 3 + it->at(
cursor);
763 static const std::set<std::string> sSTLTypes {
764 "vector",
"list",
"forward_list",
"deque",
"map",
"unordered_map",
"multimap",
765 "unordered_multimap",
"set",
"unordered_set",
"multiset",
"unordered_multiset",
766 "queue",
"priority_queue",
"stack",
"iterator"};
767 std::vector<std::string>::const_iterator it;
768 std::string fileContent(
"");
769 for (it = headers.begin(); it != headers.end(); ++it) {
770 fileContent +=
"#include \"" + *it +
"\"\n";
772 for (it = unknown.begin(); it != unknown.end(); ++it) {
778 while (dirbase.Length() && dirbase !=
"."
779 && dirbase !=
"include" && dirbase !=
"inc"
780 && dirbase !=
"prec_stl") {
784 fileContent +=
TString(
"#include \"") + header +
"\"\n";
787 for (it = fwdDecls.begin(); it != fwdDecls.end(); ++it) {
788 fileContent +=
"class " + *it +
";\n";
790 fileContent +=
"#ifdef __CLING__ \n";
791 fileContent +=
"#pragma link C++ nestedclasses;\n";
792 fileContent +=
"#pragma link C++ nestedtypedefs;\n";
793 for (it = classes.begin(); it != classes.end(); ++it) {
795 size_t posTemplate =
n.find(
'<');
796 std::set<std::string>::const_iterator iSTLType = sSTLTypes.end();
797 if (posTemplate != std::string::npos) {
798 n.erase(posTemplate, std::string::npos);
799 if (
n.compare(0, 5,
"std::") == 0) {
802 iSTLType = sSTLTypes.find(
n);
804 fileContent +=
"#pragma link C++ class ";
805 fileContent += *it +
"+;\n" ;
806 if (iSTLType == sSTLTypes.end()) {
809 fileContent +=
"#pragma link C++ class " + *it +
"::*+;\n" ;
812 fileContent +=
"#endif\n";
816 filePointer = fopen(fileName,
"w");
817 if (filePointer ==
nullptr) {
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 * ,
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;
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()) {
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) {
969 if ( end != tname.length() ) {
970 result += tname.substr(end,tname.length()-end);
978 if (lastPos != inner)
981 const auto enName = lastPos;
982 const auto scopeNameSize = (lastPos - inner) /
sizeof(
decltype(*lastPos)) - 2;
983 std::string scopeName{inner, scopeNameSize};
985 if (
auto scope =
static_cast<TClass *
>(
gROOT->GetListOfClasses()->FindObject(scopeName.c_str()))) {
986 auto enumTable =
dynamic_cast<const THashList *
>(scope->GetListOfEnums(
false));
987 if (enumTable && enumTable->THashList::FindObject(enName))
992 auto listOfEnums = scope->GetListOfEnums();
994 auto enumTable =
dynamic_cast<const THashList *
>(listOfEnums);
995 if (enumTable && enumTable->THashList::FindObject(enName))
1002 auto enumTable =
dynamic_cast<const THashList *
>(
gROOT->GetListOfEnums());
1003 if (enumTable && enumTable->THashList::FindObject(inner))
return true;
1044 return fContent.c_str();
1052 bool notPresent = fLinesHashSet.emplace(fHashFunc(str)).second;
1066static bool LoadModule(
const std::string &ModuleName, cling::Interpreter &interp)
1076 assert(!currentDir.empty());
1079 ::Info(
"TCling::__LoadModule",
"Preloading module %s. \n",
1080 ModuleName.c_str());
1082 return interp.loadModule(ModuleName,
true);
1088static void LoadModules(
const std::vector<std::string> &modules, cling::Interpreter &interp)
1090 for (
const auto &modName : modules)
1096 const static bool foundSymbol = dlsym(RTLD_DEFAULT,
"usedToIdentifyRootClingByDlSym");
1101static bool HasASTFileOnDisk(clang::Module *M,
const clang::Preprocessor &PP, std::string *FullFileName =
nullptr)
1103 const HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
1105 std::string ModuleFileName;
1106 if (!HSOpts.PrebuiltModulePaths.empty())
1108 ModuleFileName = PP.getHeaderSearchInfo().getPrebuiltModuleFileName(M->Name);
1110 *FullFileName = ModuleFileName;
1112 return !ModuleFileName.empty();
1118 CompilerInstance &CI = *interp.getCI();
1119 Preprocessor &PP = CI.getPreprocessor();
1120 auto ModuleManager = CI.getASTReader();
1121 assert(ModuleManager);
1126 if (ModuleIndexPath.empty())
1129 ModuleManager->resetForReload();
1130 ModuleManager->loadGlobalIndex();
1131 GlobalModuleIndex *GlobalIndex = ModuleManager->getGlobalIndex();
1136 ModuleMap &MMap = PP.getHeaderSearchInfo().getModuleMap();
1137 bool RecreateIndex =
false;
1138 for (ModuleMap::module_iterator I = MMap.module_begin(), E = MMap.module_end(); I != E; ++I) {
1139 Module *TheModule = I->second;
1144 RecreateIndex =
true;
1146 if (RecreateIndex) {
1147 cling::Interpreter::PushTransactionRAII deserRAII(&interp);
1148 clang::GlobalModuleIndex::UserDefinedInterestingIDs IDs;
1150 struct DefinitionFinder :
public RecursiveASTVisitor<DefinitionFinder> {
1151 DefinitionFinder(clang::GlobalModuleIndex::UserDefinedInterestingIDs& IDs,
1152 clang::TranslationUnitDecl* TU) : DefinitionIDs(IDs) {
1155 bool VisitNamedDecl(NamedDecl *ND) {
1156 if (!ND->isFromASTFile())
1158 if (!ND->getIdentifier())
1161 if (ND->getAccess() == AS_protected || ND->getAccess() == AS_private)
1164 if (TagDecl *TD = llvm::dyn_cast<TagDecl>(ND)) {
1165 if (TD->isCompleteDefinition())
1167 }
else if (NamespaceDecl *NSD = llvm::dyn_cast<NamespaceDecl>(ND)) {
1168 Register(NSD,
false);
1170 else if (TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(ND))
1176 clang::GlobalModuleIndex::UserDefinedInterestingIDs &DefinitionIDs;
1177 void Register(
const NamedDecl* ND,
bool AddSingleEntry =
true) {
1178 assert(ND->isFromASTFile());
1181 if (!ND->hasOwningModule()) {
1183 SourceManager &SM = ND->getASTContext().getSourceManager();
1184 SourceLocation Loc = ND->getLocation();
1185 OptionalFileEntryRef FE = SM.getFileEntryRefForID(SM.getFileID(Loc));
1187 assert(FE->getName().contains(
"input_line_"));
1192 Module *OwningModule = ND->getOwningModule()->getTopLevelModule();
1193 assert(OwningModule);
1194 assert(!ND->getName().empty() &&
"Empty name");
1195 if (AddSingleEntry && DefinitionIDs.count(ND->getName()))
1201 DefinitionIDs[ND->getName()].push_back(OwningModule->getASTFile());
1204 DefinitionFinder defFinder(IDs, CI.getASTContext().getTranslationUnitDecl());
1206 llvm::cantFail(GlobalModuleIndex::writeIndex(CI.getFileManager(),
1207 CI.getPCHContainerReader(),
1210 ModuleManager->resetForReload();
1211 ModuleManager->loadGlobalIndex();
1212 GlobalIndex = ModuleManager->getGlobalIndex();
1221 if (!clingInterp.getCI()->getLangOpts().Modules)
1225 cling::Interpreter::PushTransactionRAII deserRAII(&clingInterp);
1243 LoadModule(
"_Builtin_intrinsics", clingInterp);
1247 std::vector<std::string> CoreModules = {
"ROOT_Foundation_C",
1250 "ROOT_Foundation_Stage1_NoRTTI",
1259 std::vector<std::string> CommonModules = {
"MathCore"};
1265 std::vector<std::string> FIXMEModules = {
"Hist"};
1266 clang::CompilerInstance &CI = *clingInterp.getCI();
1267 clang::Preprocessor &PP = CI.getPreprocessor();
1268 ModuleMap &MMap = PP.getHeaderSearchInfo().getModuleMap();
1269 if (MMap.findModule(
"RInterface"))
1270 FIXMEModules.push_back(
"RInterface");
1274 GlobalModuleIndex *GlobalIndex =
nullptr;
1277 std::optional<std::string> envUseGMI = llvm::sys::Process::GetEnv(
"ROOT_USE_GMI");
1278 if (envUseGMI.has_value())
1286 GlobalIndex = CI.getASTReader()->getGlobalIndex();
1289 llvm::StringSet<> KnownModuleFileNames;
1291 GlobalIndex->getKnownModuleFileNames(KnownModuleFileNames);
1293 std::vector<std::string> PendingModules;
1294 PendingModules.reserve(256);
1295 for (
auto I = MMap.module_begin(), E = MMap.module_end(); I != E; ++I) {
1296 clang::Module *M = I->second;
1300 std::string FullASTFilePath;
1304 if (GlobalIndex && KnownModuleFileNames.count(FullASTFilePath))
1307 if (M->IsUnimportable)
1315 if (std::find(CoreModules.begin(), CoreModules.end(), M->Name) != CoreModules.end())
1323 PendingModules.push_back(M->Name);
1330 assert(clingInterp.getMacro(
"gROOT") &&
"Couldn't load gROOT macro?");
1334 clingInterp.declare(R
"CODE(
1346 std::string PreIncludes;
1347 bool hasCxxModules = clingInterp.getCI()->getLangOpts().Modules;
1353 PreIncludes +=
"#include \"RtypesCore.h\"\n";
1356 PreIncludes +=
"#include \"Rtypes.h\"\n";
1358 PreIncludes += gClassDefInterpMacro +
"\n"
1359 + gInterpreterClassDef +
"\n"
1361 "#define ClassImp(X);\n";
1364 PreIncludes +=
"#include <string>\n";
1369 PreIncludes +=
"#include <cassert>\n";
1371 PreIncludes +=
"using namespace std;\n";
1372 clingInterp.declare(PreIncludes);
1393#ifdef R__USE_CXXMODULES
1397 llvm::install_fatal_error_handler(&exceptionErrorHandler);
1401 std::vector<std::string> clingArgsStorage;
1402 clingArgsStorage.push_back(
"cling4root");
1403 for (
const char*
const* arg = argv; *arg; ++arg)
1404 clingArgsStorage.push_back(*arg);
1407 if (!fromRootCling) {
1412 clingArgsStorage.push_back(
"-I" + interpInclude);
1415 clingArgsStorage.push_back(
"-I" + interpInclude +
"/cling");
1418 clingArgsStorage.push_back(
"-I" + interpInclude +
"/cling/plugins/include");
1429 std::string pchFilename = interpInclude +
"/allDict.cxx.pch";
1434 clingArgsStorage.push_back(
"-include-pch");
1435 clingArgsStorage.push_back(pchFilename);
1438 clingArgsStorage.push_back(
"-Wno-undefined-inline");
1439 clingArgsStorage.push_back(
"-fsigned-char");
1440 clingArgsStorage.push_back(
"-fsized-deallocation");
1445 clingArgsStorage.push_back(
"-O1");
1448 clingArgsStorage.push_back(
"-mllvm");
1449 clingArgsStorage.push_back(
"-optimize-regalloc=0");
1452#ifdef CLING_WITH_ADAPTIVECPP
1455 clingArgsStorage.push_back(
"-isystem");
1456 clingArgsStorage.push_back(acppInclude);
1457 clingArgsStorage.push_back(
"-mllvm");
1458 clingArgsStorage.push_back(
"-acpp-sscp");
1463 std::optional<std::string> EnvOpt = llvm::sys::Process::GetEnv(
"EXTRA_CLING_ARGS");
1464 if (EnvOpt.has_value()) {
1465 StringRef Env(*EnvOpt);
1466 while (!Env.empty()) {
1468 std::tie(Arg, Env) = Env.split(
' ');
1469 clingArgsStorage.push_back(Arg.str());
1473 auto GetEnvVarPath = [](
const std::string &EnvVar, std::vector<std::string> &Paths) {
1474 std::optional<std::string> EnvOpt = llvm::sys::Process::GetEnv(EnvVar);
1475 if (EnvOpt.has_value()) {
1476 StringRef Env(*EnvOpt);
1477 while (!Env.empty()) {
1480 if (std::find(Paths.begin(), Paths.end(), Arg.str()) == Paths.end())
1481 Paths.push_back(Arg.str());
1487 std::vector<std::string> Paths;
1492 GetEnvVarPath(
"CLING_PREBUILT_MODULE_PATH", Paths);
1493 std::string EnvVarPath;
1494 for (
const std::string& P : Paths)
1497 gSystem->
Setenv(
"CLING_PREBUILT_MODULE_PATH", EnvVarPath.c_str());
1501 EnvOpt = llvm::sys::Process::GetEnv(
"ROOT_CLING_TIMING");
1502 if (EnvOpt.has_value())
1503 clingArgsStorage.push_back(
"-ftime-report");
1510 std::vector<std::string> ModuleMaps;
1513 GetEnvVarPath(
"CLING_MODULEMAP_FILES", ModuleMaps);
1517 if (llvm::sys::fs::exists(cwd + ModuleMapSuffix))
1518 ModuleMaps.push_back(cwd + ModuleMapSuffix);
1520 for (
const std::string& M : ModuleMaps)
1521 clingArgsStorage.push_back(
"-fmodule-map-file=" + M);
1523 std::string ModulesCachePath;
1524 EnvOpt = llvm::sys::Process::GetEnv(
"CLING_MODULES_CACHE_PATH");
1525 if (EnvOpt.has_value()){
1526 StringRef Env(*EnvOpt);
1527 assert(llvm::sys::fs::exists(Env) &&
"Path does not exist!");
1528 ModulesCachePath = Env.str();
1533 clingArgsStorage.push_back(
"-fmodules-cache-path=" + ModulesCachePath);
1536 std::vector<const char*> interpArgs;
1537 for (std::vector<std::string>::const_iterator iArg = clingArgsStorage.begin(),
1538 eArg = clingArgsStorage.end(); iArg != eArg; ++iArg)
1539 interpArgs.push_back(iArg->c_str());
1546 if (!fromRootCling) {
1548 interpArgs.push_back(
"-fmodules");
1549 interpArgs.push_back(
"-fno-implicit-module-maps");
1553 interpArgs.push_back(
"-Rmodule-build");
1559 interpArgs.push_back(
"-fno-autolink");
1564 interpArgs.push_back(
"-ffast-math");
1570 extraArgs && *extraArgs; ++extraArgs) {
1571 if (!strcmp(*extraArgs,
"-resource-dir")) {
1573 llvmResourceDir = *(++extraArgs);
1575 interpArgs.push_back(*extraArgs);
1579 std::vector<std::string> _empty;
1581 for (
const auto &arg: args)
1582 interpArgs.emplace_back(arg.c_str());
1585 cling::Interpreter::ModuleFileExtensions extensions;
1586 EnvOpt = llvm::sys::Process::GetEnv(
"ROOTDEBUG_RDICT");
1587 if (!EnvOpt.has_value())
1588 extensions.push_back(std::make_shared<TClingRdictModuleFileExtension>());
1590 fInterpreter = std::make_unique<cling::Interpreter>(interpArgs.size(),
1592 llvmResourceDir, extensions,
1605 fInterpreter->getCI()->getPreprocessorOpts().DisablePCHOrModuleValidation =
1606 DisableValidationForModuleKind::All;
1610 fInterpreter->getCI()->getLangOpts().SpellChecking =
false;
1613 auto isModulesArg = [](
const char* arg) {
return !strcmp(arg,
"-fmodules"); };
1614 bool hasModulesArg = std::find_if(interpArgs.begin(), interpArgs.end(), isModulesArg) != interpArgs.end();
1615 fInterpreter->getCI()->getLangOpts().Modules = hasModulesArg;
1620 static llvm::raw_fd_ostream fMPOuts (STDOUT_FILENO,
false);
1639 if (!fromRootCling) {
1644 fInterpreter->getRuntimeOptions().AllowRedefinition = 1;
1645 auto &Policy =
const_cast<clang::PrintingPolicy &
>(
fInterpreter->getCI()->getASTContext().getPrintingPolicy());
1649 Policy.SplitTemplateClosers =
true;
1651 Policy.SuppressDefaultTemplateArgs =
false;
1657 std::unique_ptr<TClingCallbacks>
1663 if (!fromRootCling) {
1664 cling::DynamicLibraryManager& DLM = *
fInterpreter->getDynamicLibraryManager();
1669 auto ShouldPermanentlyIgnore = [](llvm::StringRef FileName) ->
bool{
1670 llvm::StringRef stem = llvm::sys::path::stem(FileName);
1671 return stem.starts_with(
"libNew") || stem.starts_with(
"libcppyy_backend");
1674 DLM.initializeDyld(ShouldPermanentlyIgnore);
1714 assert(
GetRootMapFiles() ==
nullptr &&
"Must be called before LoadLibraryMap!");
1733 auto setFactory = []() {
1737 static bool doneFactory = setFactory();
1749 if (llvm::sys::fs::exists(pcmFileNameFullPath)) {
1750 ::Error(
"TCling::RegisterRdictForLoadPCM",
"Rdict '%s' is both in Module extension and in File system.", pcmFileNameFullPath.c_str());
1765 auto listOfKeys = pcmFile.GetListOfKeys();
1768 if (listOfKeys && ((listOfKeys->GetSize() == 0) ||
1769 ((listOfKeys->GetSize() == 1) &&
1770 !strcmp(((
TKey *)listOfKeys->At(0))->GetName(),
"EMPTY")
1777 ::Info(
"TCling::LoadPCMImpl",
"reading protoclasses for %s \n", pcmFile.GetName());
1780 pcmFile.GetObject(
"__Enums", enums);
1783 auto listOfGlobals =
gROOT->GetListOfGlobals();
1784 auto listOfEnums =
dynamic_cast<THashList *
>(
gROOT->GetListOfEnums());
1786 for (
auto selEnum : *enums) {
1787 const char *enumScope = selEnum->
GetTitle();
1788 const char *enumName = selEnum->GetName();
1789 if (strcmp(enumScope,
"") == 0) {
1792 if (!listOfEnums->THashList::FindObject(enumName)) {
1793 ((
TEnum *)selEnum)->SetClass(
nullptr);
1794 listOfEnums->Add(selEnum);
1796 for (
auto enumConstant : *
static_cast<TEnum *
>(selEnum)->GetConstants()) {
1797 if (!listOfGlobals->FindObject(enumConstant)) {
1798 listOfGlobals->Add(enumConstant);
1805 if (!nsTClassEntry) {
1808 auto listOfEnums = nsTClassEntry->fEnums.load();
1813 listOfEnums = nsTClassEntry->fEnums =
new TListOfEnums(nsTClassEntry);
1819 if (listOfEnums && !listOfEnums->THashList::FindObject(enumName)) {
1820 ((
TEnum *)selEnum)->SetClass(nsTClassEntry);
1821 listOfEnums->Add(selEnum);
1829 pcmFile.GetObject(
"__ProtoClasses", protoClasses);
1832 for (
auto obj : *protoClasses) {
1842 for (
auto proto : *protoClasses) {
1850 ::Error(
"TCling::LoadPCM",
"Inconsistent TClassTable for %s", proto->GetName());
1861 protoClasses->Clear();
1862 delete protoClasses;
1866 pcmFile.GetObject(
"__Typedefs", dataTypes);
1868 for (
auto typedf : *dataTypes)
1869 gROOT->GetListOfTypes()->
Add(typedf);
1883 assert(!pcmFileNameFullPath.empty());
1884 assert(llvm::sys::path::is_absolute(pcmFileNameFullPath));
1887 TString pcmFileName = pcmFileNameFullPath;
1895 llvm::SaveAndRestore<Int_t> SaveGDebug(
gDebug);
1898 ::Info(
"TCling::LoadPCM",
"Loading ROOT PCM %s", pcmFileName.Data());
1903 if (llvm::sys::fs::is_symlink_file(pcmFileNameFullPath))
1908 llvm::StringRef pcmContent = pendingRdict->second;
1910 std::string RDictFileOpts = pcmFileNameFullPath +
"?filetype=pcm";
1911 TMemFile pcmMemFile(RDictFileOpts.c_str(), range);
1926 if (!llvm::sys::fs::exists(pcmFileNameFullPath)) {
1927 ::Error(
"TCling::LoadPCM",
"ROOT PCM %s file does not exist",
1928 pcmFileNameFullPath.data());
1931 ::Info(
"TCling::LoadPCM",
"In-memory ROOT PCM candidate %s\n",
1932 rdict.first.c_str());
1936 if (!
gROOT->IsRootFile(pcmFileName)) {
1937 Fatal(
"LoadPCM",
"The file %s is not a ROOT as was expected\n", pcmFileName.Data());
1940 TFile pcmFile(pcmFileName +
"?filetype=pcm",
"READ");
1947 using namespace clang;
1949 class ExtLexicalStorageAdder:
public RecursiveASTVisitor<ExtLexicalStorageAdder>{
1954 bool VisitRecordDecl(clang::RecordDecl* rcd){
1956 Info(
"ExtLexicalStorageAdder",
1957 "Adding external lexical storage to class %s",
1958 rcd->getNameAsString().c_str());
1959 auto reDeclPtr = rcd->getMostRecentDecl();
1961 reDeclPtr->setHasExternalLexicalStorage();
1962 }
while ((reDeclPtr = reDeclPtr->getPreviousDecl()));
1975 const std::string &ModuleMapName )
const
1977 assert(llvm::sys::path::is_absolute(FullPath));
1978 Preprocessor &PP =
fInterpreter->getCI()->getPreprocessor();
1979 FileManager &FM = PP.getFileManager();
1982 if (
auto DE = FM.getOptionalDirectoryRef(FullPath)) {
1983 HeaderSearch &HS = PP.getHeaderSearchInfo();
1984 HeaderSearchOptions &HSOpts =
const_cast<HeaderSearchOptions&
>(HS.getHeaderSearchOpts());
1985 const auto &ModPaths = HSOpts.PrebuiltModulePaths;
1986 bool pathExists = std::find(ModPaths.begin(), ModPaths.end(), FullPath) != ModPaths.end();
1988 HSOpts.AddPrebuiltModulePath(FullPath);
1993 llvm::SmallString<256> ModuleMapFileName(DE->getName());
1994 llvm::sys::path::append(ModuleMapFileName, ModuleMapName);
1995 if (
auto FE = FM.getOptionalFileRef(ModuleMapFileName,
false,
1997 if (!HS.parseAndLoadModuleMapFile(*FE,
false))
1999 Error(
"RegisterPrebuiltModulePath",
"Could not load modulemap in %s", ModuleMapFileName.c_str());
2016 "libforward_listDict",
2024 "libunordered_setDict",
2025 "libunordered_multisetDict",
2026 "libunordered_mapDict",
2027 "libunordered_multimapDict",
2035 char dyLibError[1000];
2036 FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
2037 dyLibError,
sizeof(dyLibError), NULL);
2039 const char *dyLibError = dlerror();
2041 ::Error(
"TCling::RegisterModule",
"Cannot open shared library %s for dictionary %s:\n %s", dyLibName, modulename,
2042 (dyLibError) ? dyLibError :
"");
2062 if (ncl) ncl->PostLoadCheck();
2080 const char** headers,
2081 const char** includePaths,
2082 const char* payloadCode,
2083 const char* fwdDeclsCode,
2084 void (*triggerFunc)(),
2086 const char** classesHeaders,
2087 Bool_t lateRegistration ,
2094 if (fromRootCling)
return;
2103 bool isACLiC = strstr(modulename,
"_ACLiC_dict") !=
nullptr;
2104 if (hasHeaderParsingOnDemand && isACLiC) {
2106 Info(
"TCling::RegisterModule",
2107 "Header parsing on demand is active but this is an Aclic library. Disabling it for this library.");
2108 hasHeaderParsingOnDemand =
false;
2122 for (
const char** inclPath = includePaths; *inclPath; ++inclPath) {
2125 cling::Transaction* T =
nullptr;
2127 for (
auto& fwdDeclArgToSkipPair : fwdDeclsArgToSkip){
2128 const std::string& fwdDecl = fwdDeclArgToSkipPair.first;
2129 const int nArgsToSkip = fwdDeclArgToSkipPair.second;
2130 auto compRes =
fInterpreter->declare(fwdDecl.c_str(), &T);
2131 assert(cling::Interpreter::kSuccess == compRes &&
2132 "A fwd declaration could not be compiled");
2133 if (compRes!=cling::Interpreter::kSuccess){
2134 Warning(
"TCling::RegisterModule",
2135 "Problems in declaring string '%s' were encountered.",
2150 TString code = gNonInterpreterClassDef;
2152 code += payloadCode;
2154 std::string dyLibName = cling::DynamicLibraryManager::getSymbolLocation(triggerFunc);
2155 assert(!llvm::sys::fs::is_symlink_file(dyLibName));
2157 if (dyLibName.empty()) {
2158 ::Error(
"TCling::RegisterModule",
"Dictionary trigger function for %s not found", modulename);
2163 bool isSharedLib = cling::DynamicLibraryManager::isSharedLibrary(dyLibName);
2165 bool wasDlopened =
false;
2170 if (!lateRegistration) {
2177 void* dyLibHandle = dlopen(dyLibName.c_str(), RTLD_LAZY | RTLD_GLOBAL);
2187 if (hasHeaderParsingOnDemand && fwdDeclsCode){
2190 std::string fwdDeclsCodeLessEnums;
2194 std::string fwdDeclsLine;
2195 std::istringstream fwdDeclsCodeStr(fwdDeclsCode);
2196 std::vector<std::string> scopes;
2197 while (std::getline(fwdDeclsCodeStr, fwdDeclsLine)) {
2198 const auto enumPos = fwdDeclsLine.find(
"enum __attribute__((annotate(\"");
2200 if (enumPos != std::string::npos) {
2207 auto nsPos = fwdDeclsLine.find(
"namespace");
2208 R__ASSERT(nsPos < enumPos &&
"Inconsistent enum and enclosing scope parsing!");
2209 while (nsPos < enumPos && nsPos != std::string::npos) {
2211 const auto nsNameStart = nsPos + 10;
2212 const auto nsNameEnd = fwdDeclsLine.find(
'{', nsNameStart);
2213 const auto nsName = fwdDeclsLine.substr(nsNameStart, nsNameEnd - nsNameStart);
2214 scopes.push_back(nsName);
2215 nsPos = fwdDeclsLine.find(
"namespace", nsNameEnd);
2218 clang::DeclContext* DC =
nullptr;
2219 for (
auto &&aScope: scopes) {
2220 DC = cling::utils::Lookup::Namespace(&
fInterpreter->getSema(), aScope.c_str(), DC);
2226 if (scopes.empty() || DC) {
2230 size_t posEnumName = fwdDeclsLine.rfind(
"\"))) ");
2231 R__ASSERT(posEnumName != std::string::npos &&
"Inconsistent enum fwd decl!");
2233 while (isspace(fwdDeclsLine[posEnumName]))
2235 size_t posEnumNameEnd = fwdDeclsLine.find(
" : ", posEnumName);
2236 R__ASSERT(posEnumNameEnd != std::string::npos &&
"Inconsistent enum fwd decl (end)!");
2237 while (isspace(fwdDeclsLine[posEnumNameEnd]))
2241 std::string enumName = fwdDeclsLine.substr(posEnumName,
2242 posEnumNameEnd - posEnumName + 1);
2244 if (clang::NamedDecl* enumDecl
2245 = cling::utils::Lookup::Named(&
fInterpreter->getSema(),
2246 enumName.c_str(), DC)) {
2249 R__ASSERT(llvm::dyn_cast<clang::EnumDecl>(enumDecl) &&
"not an enum decl!");
2256 fwdDeclsCodeLessEnums += fwdDeclsLine +
"\n";
2260 if (!fwdDeclsCodeLessEnums.empty()){
2261 auto compRes =
fInterpreter->declare(fwdDeclsCodeLessEnums, &T);
2262 assert(cling::Interpreter::kSuccess == compRes &&
2263 "The forward declarations could not be compiled");
2264 if (compRes!=cling::Interpreter::kSuccess){
2265 Warning(
"TCling::RegisterModule",
2266 "Problems in compiling forward declarations for module %s: '%s'",
2267 modulename, fwdDeclsCodeLessEnums.c_str()) ;
2275 ExtLexicalStorageAdder elsa;
2276 for (
auto dciIt = T->decls_begin();dciIt!=T->decls_end();dciIt++){
2277 cling::Transaction::DelayCallInfo& dci = *dciIt;
2278 for(
auto dit = dci.m_DGR.begin(); dit != dci.m_DGR.end(); ++dit) {
2279 clang::Decl* declPtr = *dit;
2280 elsa.TraverseDecl(declPtr);
2294 for (
const char** classesHeader = classesHeaders; *classesHeader; ++classesHeader) {
2295 temp=*classesHeader;
2297 size_t theTemplateHash = 0;
2298 bool addTemplate =
false;
2299 size_t posTemplate = temp.find(
'<');
2300 if (posTemplate != std::string::npos) {
2302 std::string templateName = temp.substr(0, posTemplate);
2308 for (
const char** classesHeader_inner = classesHeader; 0!=strcmp(*classesHeader_inner,
"@"); ++classesHeader_inner,++classesHeader){
2310 if (payloadCode == *classesHeader_inner ){
2312 if (addTemplate)
fPayloads.insert(theTemplateHash);
2315 Info(
"TCling::RegisterModule",
2316 "Adding a header for %s", temp.c_str());
2322 addTemplate =
false;
2330 bool ModuleWasSuccessfullyLoaded =
false;
2332 std::string ModuleName = modulename;
2333 if (llvm::StringRef(modulename).starts_with(
"lib"))
2334 ModuleName = llvm::StringRef(modulename).substr(3).str();
2339 clang::Preprocessor &PP = TheSema.getPreprocessor();
2340 std::string ModuleMapName;
2342 ModuleMapName = ModuleName +
".modulemap";
2344 ModuleMapName =
"module.modulemap";
2352 if (!ModuleWasSuccessfullyLoaded) {
2354 clang::HeaderSearch &headerSearch = PP.getHeaderSearchInfo();
2355 clang::ModuleMap &moduleMap = headerSearch.getModuleMap();
2356 if (moduleMap.findModule(ModuleName))
2357 Info(
"TCling::RegisterModule",
"Module %s in modulemap failed to load.", ModuleName.c_str());
2362 llvm::SmallString<256> pcmFileNameFullPath(dyLibName);
2365 llvm::sys::fs::make_absolute(pcmFileNameFullPath);
2366 llvm::sys::path::remove_filename(pcmFileNameFullPath);
2367 llvm::sys::path::append(pcmFileNameFullPath,
2378 std::string pcmPath = pcmFileNameFullPath.str().str();
2379 std::string pcmRealPath = llvm::sys::fs::is_symlink_file(pcmPath)
2382 if (!ModuleWasSuccessfullyLoaded ||
fPendingRdicts.count(pcmRealPath) ||
2383 llvm::sys::fs::exists(pcmRealPath))
2391 clangDiagSuppr diagSuppr(TheSema.getDiagnostics());
2393#if defined(R__MUST_REVISIT)
2394#if R__MUST_REVISIT(6,2)
2395 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
2399 if (!ModuleWasSuccessfullyLoaded && !hasHeaderParsingOnDemand){
2402 const cling::Transaction* watermark =
fInterpreter->getLastTransaction();
2403 cling::Interpreter::CompilationResult compRes =
fInterpreter->parseForModule(code.
Data());
2409 assert(cling::Interpreter::kSuccess == compRes &&
2410 "Payload code of a dictionary could not be parsed correctly.");
2411 if (compRes!=cling::Interpreter::kSuccess) {
2412 Warning(
"TCling::RegisterModule",
2413 "Problems declaring payload for module %s.", modulename) ;
2426 if (!ModuleWasSuccessfullyLoaded && !hasHeaderParsingOnDemand) {
2429 "#undef __ROOTCLING__\n"
2430 + gInterpreterClassDef +
2435 assert(isSharedLib);
2438 dlclose(dyLibHandle);
2444 ASTContext &C = CI.getASTContext();
2452 if (IdentifierInfoLookup *External = C.Idents.getExternalIdentifierLookup()) {
2453 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
2454 for (llvm::StringRef Ident = Iter->Next(); !Ident.empty(); Ident = Iter->Next()) {
2455 std::string I = Ident.str();
2456 if (!Idents.Contains(I.data()))
2479 typedef std::vector<std::pair<TClass*,DictFuncPtr_t> >::iterator iterator;
2485 if ( i->first == oldcl ) {
2508 const char* input_line,
2509 cling::Interpreter::CompilationResult& compRes,
2513 return metaProcessor->process(input_line, compRes,
result);
2515 catch (cling::InterpreterException&
ex)
2517 Error(
"HandleInterpreterException",
"%s\n%s",
ex.what(),
"Execution of your code was aborted.");
2519 compRes = cling::Interpreter::kFailure;
2528 if (
auto ie =
dynamic_cast<const cling::InterpreterException*
>(&
e)) {
2554 gROOT->SetLineIsProcessing();
2558 gROOT->SetLineHasBeenProcessed();
2571 gROOT->SetLineIsProcessing();
2573 struct InterpreterFlagsRAII {
2574 cling::Interpreter* fInterpreter;
2575 bool fWasDynamicLookupEnabled;
2577 InterpreterFlagsRAII(cling::Interpreter* interp):
2578 fInterpreter(interp),
2579 fWasDynamicLookupEnabled(interp->isDynamicLookupEnabled())
2581 fInterpreter->enableDynamicLookup(
true);
2583 ~InterpreterFlagsRAII() {
2584 fInterpreter->enableDynamicLookup(fWasDynamicLookupEnabled);
2585 gROOT->SetLineHasBeenProcessed();
2594 cling::Interpreter::CompilationResult compRes = cling::Interpreter::kSuccess;
2595 if (!strncmp(sLine.Data(),
".L", 2) || !strncmp(sLine.Data(),
".x", 2) ||
2596 !strncmp(sLine.Data(),
".X", 2)) {
2604 aclicMode, arguments, io);
2605 if (aclicMode.Length()) {
2607 R__ASSERT(aclicMode[0]==
'+' &&
"ACLiC mode must start with a +");
2609 if (aclicMode[1]==
'+') {
2615 compRes = cling::Interpreter::kFailure;
2617 if (strncmp(sLine.Data(),
".L", 2) != 0) {
2620 if (arguments.
Length() == 0) {
2624 Ssiz_t ext = fname.Last(
'.');
2629 mod_line = function + arguments + io;
2633 }
else if (cling::DynamicLibraryManager::isSharedLibrary(fname.Data()) &&
2634 strncmp(sLine.Data(),
".L", 2) != 0) {
2637 compRes = cling::Interpreter::kFailure;
2639 if (arguments.
Length() == 0) {
2643 Ssiz_t ext = fname.Last(
'.');
2653 ext = fname.Last(
'_');
2659 mod_line = function + arguments + io;
2664 size_t unnamedMacroOpenCurly;
2667 std::string codeline;
2670 std::ifstream in(fname, std::ifstream::binary);
2672 std::getline(in, codeline);
2673 code += codeline +
"\n";
2675 unnamedMacroOpenCurly
2676 = cling::utils::isUnnamedMacro(code,
fInterpreter->getCI()->getLangOpts());
2680 if (unnamedMacroOpenCurly != std::string::npos) {
2682 unnamedMacroOpenCurly);
2692 if (0!=strncmp(sLine.Data(),
".autodict ",10) && sLine !=
".autodict") {
2697 bool isInclusionDirective = sLine.Contains(
"\n#include") || sLine.BeginsWith(
"#include");
2698 if (isInclusionDirective) {
2715 case cling::Interpreter::kSuccess: *error =
kNoError;
break;
2716 case cling::Interpreter::kFailure: *error =
kRecoverable;
break;
2717 case cling::Interpreter::kMoreInputExpected: *error =
kProcessing;
break;
2720 if (compRes == cling::Interpreter::kSuccess
2745 if (!strcmp(
option,
"autoparsed")) {
2746 std::cout <<
"Auto parsed classes:" << std::endl;
2748 std::cout <<
" " << cls << std::endl;
2750 }
else if (!strcmp(
option,
"autoloaded")) {
2751 std::cout <<
"Auto loaded libraries:" << std::endl;
2753 std::cout <<
" " << lib << std::endl;
2759 ::Info(
"TCling::Print",
"No options specified");
2779 if (path[0] ==
'-' && path[1] ==
'I')
2784 if (sPath.BeginsWith(
"/")) {
2786 snprintf(drive, 3,
"%c:", _getdrive() +
'A' - 1);
2787 sPath.Prepend(drive);
2811 static const TClassRef clRefString(
"std::string");
2812 if (clRefString == cl) {
2822 const char* cobj = (
const char*) obj;
2829 auto inspInspect = [&] (ptrdiff_t
offset){
2830 insp.Inspect(
const_cast<TClass*
>(cl), insp.GetParent(),
"_real", cobj, isTransient);
2831 insp.Inspect(
const_cast<TClass*
>(cl), insp.GetParent(),
"_imag", cobj +
offset, isTransient);
2835 switch(complexType) {
2842 inspInspect(
sizeof(
float));
2847 inspInspect(
sizeof(
double));
2852 inspInspect(
sizeof(
int));
2857 inspInspect(
sizeof(
long));
2862 static clang::PrintingPolicy
2864 if (printPol.Indentation) {
2866 printPol.Indentation = 0;
2867 printPol.SuppressInitializers =
true;
2870 const char* clname = cl->
GetName();
2873 const clang::ASTContext& astContext =
fInterpreter->getCI()->getASTContext();
2874 const clang::Decl *scopeDecl =
nullptr;
2875 const clang::Type *recordType =
nullptr;
2879 scopeDecl = clingCI->GetDecl();
2880 recordType = clingCI->GetType();
2882 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
2884 scopeDecl = lh.findScope(clname, cling::LookupHelper::NoDiagnostics,
2888 Error(
"InspectMembers",
"Cannot find Decl for class %s", clname);
2891 const clang::CXXRecordDecl* recordDecl
2892 = llvm::dyn_cast<const clang::CXXRecordDecl>(scopeDecl);
2894 Error(
"InspectMembers",
"Cannot find Decl for class %s is not a CXXRecordDecl.", clname);
2903 astContext.getASTRecordLayout(recordDecl);
2905 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2906 eField = recordDecl->field_end(); iField != eField; ++iField) {}
2909 const clang::ASTRecordLayout& recLayout
2910 = astContext.getASTRecordLayout(recordDecl);
2917 if (cl->
Size() != recLayout.getSize().getQuantity()) {
2918 Error(
"InspectMembers",
"TClass and cling disagree on the size of the class %s, respectively %d %lld\n",
2922 unsigned iNField = 0;
2925 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2926 eField = recordDecl->field_end(); iField != eField;
2927 ++iField, ++iNField) {
2930 clang::QualType memberQT = iField->getType();
2935 memberQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, memberQT,
fNormalizedCtxt->
GetConfig(),
false );
2936 if (memberQT.isNull()) {
2937 std::string memberName;
2938 llvm::raw_string_ostream stream(memberName);
2940 printPol.AnonymousTagLocations =
false;
2941 iField->getNameForDiagnostic(stream, printPol,
true );
2943 Error(
"InspectMembers",
2944 "Cannot retrieve QualType for member %s while inspecting class %s",
2945 memberName.c_str(), clname);
2948 const clang::Type* memType = memberQT.getTypePtr();
2950 std::string memberName;
2951 llvm::raw_string_ostream stream(memberName);
2953 printPol.AnonymousTagLocations =
false;
2954 iField->getNameForDiagnostic(stream, printPol,
true );
2956 Error(
"InspectMembers",
2957 "Cannot retrieve Type for member %s while inspecting class %s",
2958 memberName.c_str(), clname);
2962 const clang::Type* memNonPtrType = memType;
2963 Bool_t ispointer =
false;
2964 if (memNonPtrType->isPointerType()) {
2966 clang::QualType ptrQT
2967 = memNonPtrType->getAs<clang::PointerType>()->getPointeeType();
2972 ptrQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, ptrQT,
fNormalizedCtxt->
GetConfig(),
false );
2973 if (ptrQT.isNull()) {
2974 std::string memberName;
2975 llvm::raw_string_ostream stream(memberName);
2977 printPol.AnonymousTagLocations =
false;
2978 iField->getNameForDiagnostic(stream, printPol,
true );
2980 Error(
"InspectMembers",
2981 "Cannot retrieve pointee Type for member %s while inspecting class %s",
2982 memberName.c_str(), clname);
2985 memNonPtrType = ptrQT.getTypePtr();
2989 llvm::SmallString<8> arraySize;
2990 const clang::ArrayType* arrType = memNonPtrType->getAsArrayTypeUnsafe();
2991 unsigned arrLevel = 0;
2992 bool haveErrorDueToArray =
false;
2996 const clang::ConstantArrayType* constArrType =
2997 clang::dyn_cast<clang::ConstantArrayType>(arrType);
2999 constArrType->getSize().toStringUnsigned(arraySize);
3002 clang::QualType subArrQT = arrType->getElementType();
3003 if (subArrQT.isNull()) {
3004 std::string memberName;
3005 llvm::raw_string_ostream stream(memberName);
3007 printPol.AnonymousTagLocations =
false;
3008 iField->getNameForDiagnostic(stream, printPol,
true );
3010 Error(
"InspectMembers",
3011 "Cannot retrieve QualType for array level %d (i.e. element type of %s) for member %s while inspecting class %s",
3012 arrLevel, subArrQT.getAsString(printPol).c_str(),
3013 memberName.c_str(), clname);
3014 haveErrorDueToArray =
true;
3017 arrType = subArrQT.getTypePtr()->getAsArrayTypeUnsafe();
3019 if (haveErrorDueToArray) {
3024 std::string fieldName;
3025 if (memType->isPointerType()) {
3030 std::string ioname(iField->getName());
3032 fieldName += ioname;
3033 fieldName += arraySize;
3038 clang::CharUnits
offset(astContext.toCharUnitsFromBits(recLayout.getFieldOffset(iNField)));
3039 ptrdiff_t fieldOffset =
offset.getQuantity();
3048 if (!insp.IsTreatingNonAccessibleTypes()){
3049 auto iFiledQtype = iField->getType();
3050 if (
auto tagDecl = iFiledQtype->getAsTagDecl()){
3051 auto declAccess = tagDecl->getAccess();
3052 if (declAccess == AS_private || declAccess == AS_protected) {
3058 insp.Inspect(
const_cast<TClass*
>(cl), insp.GetParent(), fieldName.c_str(), cobj + fieldOffset, isTransient);
3061 const clang::CXXRecordDecl* fieldRecDecl = memNonPtrType->getAsCXXRecordDecl();
3062 if (fieldRecDecl && !fieldRecDecl->isAnonymousStructOrUnion()) {
3065 std::string sFieldRecName;
3068 clang::QualType(memNonPtrType,0),
3076 Bool_t transient = isTransient || !mbr || !mbr->IsPersistent();
3077 if (!mbr || !mbr->IsPersistent())
3078 insp.IncrementNestedTransient();
3079 insp.InspectMember(sFieldRecName.c_str(), cobj + fieldOffset,
3080 (fieldName +
'.').c_str(), transient);
3081 if (!mbr || !mbr->IsPersistent())
3082 insp.DecrementNestedTransient();
3090 unsigned iNBase = 0;
3091 for (clang::CXXRecordDecl::base_class_const_iterator iBase
3092 = recordDecl->bases_begin(), eBase = recordDecl->bases_end();
3093 iBase != eBase; ++iBase, ++iNBase) {
3094 clang::QualType baseQT = iBase->getType();
3095 if (baseQT.isNull()) {
3096 Error(
"InspectMembers",
3097 "Cannot find QualType for base number %d while inspecting class %s",
3101 const clang::CXXRecordDecl* baseDecl
3102 = baseQT->getAsCXXRecordDecl();
3104 Error(
"InspectMembers",
3105 "Cannot find CXXRecordDecl for base number %d while inspecting class %s",
3110 std::string sBaseName;
3112 std::vector<TClass*> foundClasses;
3114 if (foundClasses.size()==1){
3115 baseCl=foundClasses[0];
3128 std::string qualNameForDiag;
3130 Error(
"InspectMembers",
3131 "Cannot find TClass for base class %s", qualNameForDiag.c_str() );
3136 if (iBase->isVirtual()) {
3139 Error(
"InspectMembers",
3140 "Base %s of class %s is virtual but no object provided",
3141 sBaseName.c_str(), clname);
3149 baseOffset = ci->
GetBaseOffset(baseCi,
const_cast<void*
>(obj),
3151 if (baseOffset == -1) {
3152 Error(
"InspectMembers",
3153 "Error calculating offset of virtual base %s of class %s",
3154 sBaseName.c_str(), clname);
3157 Error(
"InspectMembers",
3158 "Cannot calculate offset of virtual base %s of class %s",
3159 sBaseName.c_str(), clname);
3164 baseOffset = recLayout.getBaseClassOffset(baseDecl).getQuantity();
3167 if (baseCl->IsLoaded()) {
3173 baseCl->CallShowMembers(cobj + baseOffset,
3208 class EnableAutoLoadingForJITSymbolsRAII {
3210 bool fOldValue =
false;
3213 EnableAutoLoadingForJITSymbolsRAII(
TClingCallbacks *callbacks) : fCallbacks(callbacks)
3220 ~EnableAutoLoadingForJITSymbolsRAII()
3249 bool oldDynLookup =
fInterpreter->isDynamicLookupEnabled();
3278 return fInterpreter->getDynamicLibraryManager()->isLibraryLoaded(tLibName.Data());
3293 llvm::StringRef ModuleName(libname);
3294 ModuleName = llvm::sys::path::stem(ModuleName);
3295 ModuleName.consume_front(
"lib");
3303 clang::ModuleMap &moduleMap =
fInterpreter->getCI()->getPreprocessor().getHeaderSearchInfo().getModuleMap();
3304 clang::Module *M = moduleMap.findModule(ModuleName);
3305 return M && !M->IsUnimportable && M->getASTFile();
3324 size_t at = std::string::npos;
3325 while ((at = file_name.find(
"/./")) != std::string::npos)
3326 file_name.replace(at, 3,
"/");
3328 std::string filesStr =
"";
3329 llvm::raw_string_ostream filesOS(filesStr);
3330 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
3331 cling::ClangInternalState::printIncludedFiles(filesOS, SM);
3334 llvm::SmallVector<llvm::StringRef, 100> files;
3335 llvm::StringRef(filesStr).split(files,
"\n");
3337 std::set<std::string> fileMap;
3338 llvm::StringRef file_name_ref(file_name);
3340 for (llvm::SmallVector<llvm::StringRef, 100>::const_iterator
3341 iF = files.begin(), iE = files.end(); iF != iE; ++iF) {
3342 if ((*iF) == file_name_ref)
return kTRUE;
3343 fileMap.insert(iF->str());
3346 if (fileMap.empty())
return kFALSE;
3349 TString sFilename(file_name.c_str());
3351 && fileMap.count(sFilename.Data())) {
3357 incPath.Append(
":").Prepend(
" ");
3358 incPath.ReplaceAll(
" -I",
":");
3359 while (incPath.Index(
" :") != -1) {
3360 incPath.ReplaceAll(
" :",
":");
3362 incPath.Prepend(
".:");
3363 sFilename = file_name.c_str();
3365 && fileMap.count(sFilename.Data())) {
3374 clang::ConstSearchDirIterator *CurDir =
nullptr;
3375 clang::Preprocessor &PP =
fInterpreter->getCI()->getPreprocessor();
3376 clang::HeaderSearch &HS = PP.getHeaderSearchInfo();
3377 auto FE = HS.LookupFile(file_name.c_str(),
3378 clang::SourceLocation(),
3381 clang::ArrayRef<std::pair<clang::OptionalFileEntryRef,
3382 clang::DirectoryEntryRef>>(),
3395 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
3397 clang::FileID FID = SM.translateFile(*FE);
3398 if (!FID.isInvalid() && FID.getHashValue() == 0)
3401 clang::SrcMgr::SLocEntry SLocE = SM.getSLocEntry(FID);
3402 if (SLocE.isFile() && !SLocE.getFile().getContentCache().getBufferIfLoaded())
3404 if (!FID.isInvalid())
3408 sFilename = FE->getName().str();
3410 && fileMap.count(sFilename.Data())) {
3418#if defined(R__MACOSX)
3426static bool R__UpdateLibFileForLinking(
TString &lib)
3428 const char *mapfile =
nullptr;
3430 mapfile =
"/System/Library/dyld/dyld_shared_cache_x86_64.map";
3432 mapfile =
"/System/Library/dyld/dyld_shared_cache_arm64e.map";
3434 #error unsupported architecture
3436 if (std::ifstream cacheMap{mapfile}) {
3438 while (getline(cacheMap,
line)) {
3439 if (
line.find(lib) != std::string::npos) {
3451#if defined (R__LINUX) || defined (R__FBSD)
3457static int callback_for_dl_iterate_phdr(
struct dl_phdr_info *info,
size_t size,
void *
data)
3460 static std::unordered_set<
decltype(info->dlpi_addr)> sKnownLoadedLibBaseAddrs;
3462 auto newLibs =
static_cast<std::vector<std::string>*
>(
data);
3463 if (!sKnownLoadedLibBaseAddrs.count(info->dlpi_addr)) {
3465 if (info->dlpi_name && info->dlpi_name[0]
3470 && strncmp(info->dlpi_name,
"[vdso]", 6)
3474 && strncmp(info->dlpi_name,
"/libexec/ld-elf.so.1", 20)
3476 && strncmp(info->dlpi_name,
"linux-vdso.so", 13)
3477 && strncmp(info->dlpi_name,
"linux-vdso32.so", 15)
3478 && strncmp(info->dlpi_name,
"linux-vdso64.so", 15)
3479 && strncmp(info->dlpi_name,
"linux-gate.so", 13))
3480 newLibs->emplace_back(info->dlpi_name);
3481 sKnownLoadedLibBaseAddrs.insert(info->dlpi_addr);
3494#if defined(R__WIN32) || defined(__CYGWIN__)
3495 HMODULE hModules[1024];
3497 unsigned long cbModules;
3499 hProcess = (
void *)::GetCurrentProcess();
3500 ::EnumProcessModules(hProcess, hModules,
sizeof(hModules), &cbModules);
3502 for (i = 1; i < (cbModules /
sizeof(
void *)); i++) {
3503 static const int bufsize = 260;
3504 wchar_t winname[bufsize];
3505 char posixname[bufsize];
3506 ::GetModuleFileNameExW(hProcess, hModules[i], winname, bufsize);
3507#if defined(__CYGWIN__)
3508 cygwin_conv_path(CCP_WIN_W_TO_POSIX, winname, posixname, bufsize);
3510 std::wstring wpath = winname;
3511 std::replace(wpath.begin(), wpath.end(),
'\\',
'/');
3512 string path(wpath.begin(), wpath.end());
3513 strncpy(posixname, path.c_str(), bufsize);
3519#elif defined(R__MACOSX)
3523 while (
const mach_header* mh = _dyld_get_image_header(imageIndex)) {
3525 if (mh->filetype == MH_DYLIB) {
3526 if (
const char* imageName = _dyld_get_image_name(imageIndex)) {
3534#elif defined(R__LINUX) || defined(R__FBSD)
3538 std::vector<std::string> newLibs;
3539 dl_iterate_phdr(callback_for_dl_iterate_phdr, &newLibs);
3540 for (
auto &&lib: newLibs)
3543 Error(
"TCling::UpdateListOfLoadedSharedLibraries",
3544 "Platform not supported!");
3550static bool StartsWithStrLit(
const char *haystack,
const char (&needle)[
N]) {
3551 return !strncmp(haystack, needle,
N - 1);
3574 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
3575 if (!DLM->isLibraryLoaded(
filename)) {
3576 DLM->loadLibrary(
filename,
true ,
true );
3579#if defined(R__MACOSX)
3581 auto lenFilename = strlen(
filename);
3582 auto isInMacOSSystemDir = [](
const char *fn) {
3583 return StartsWithStrLit(fn,
"/usr/lib/") || StartsWithStrLit(fn,
"/System/Library/");
3585 if (!strcmp(
filename,
"cl_kernels")
3588 || StartsWithStrLit(
filename,
"/usr/lib/system/")
3589 || StartsWithStrLit(
filename,
"/usr/lib/libc++")
3590 || StartsWithStrLit(
filename,
"/System/Library/Frameworks/")
3591 || StartsWithStrLit(
filename,
"/System/Library/PrivateFrameworks/")
3592 || StartsWithStrLit(
filename,
"/System/Library/CoreServices/")
3593 || StartsWithStrLit(
filename,
"/usr/lib/libSystem")
3594 || StartsWithStrLit(
filename,
"/usr/lib/libstdc++")
3595 || StartsWithStrLit(
filename,
"/usr/lib/libicucore")
3596 || StartsWithStrLit(
filename,
"/usr/lib/libbsm")
3597 || StartsWithStrLit(
filename,
"/usr/lib/libobjc")
3598 || StartsWithStrLit(
filename,
"/usr/lib/libresolv")
3599 || StartsWithStrLit(
filename,
"/usr/lib/libauto")
3600 || StartsWithStrLit(
filename,
"/usr/lib/libcups")
3601 || StartsWithStrLit(
filename,
"/usr/lib/libDiagnosticMessagesClient")
3602 || StartsWithStrLit(
filename,
"/usr/lib/liblangid")
3603 || StartsWithStrLit(
filename,
"/usr/lib/libCRFSuite")
3604 || StartsWithStrLit(
filename,
"/usr/lib/libpam")
3605 || StartsWithStrLit(
filename,
"/usr/lib/libOpenScriptingUtil")
3606 || StartsWithStrLit(
filename,
"/usr/lib/libextension")
3607 || StartsWithStrLit(
filename,
"/usr/lib/libAudioToolboxUtility")
3608 || StartsWithStrLit(
filename,
"/usr/lib/liboah")
3609 || StartsWithStrLit(
filename,
"/usr/lib/libRosetta")
3610 || StartsWithStrLit(
filename,
"/usr/lib/libCoreEntitlements")
3611 || StartsWithStrLit(
filename,
"/usr/lib/libssl.")
3612 || StartsWithStrLit(
filename,
"/usr/lib/libcrypto.")
3618 || StartsWithStrLit(
filename,
"/usr/lib/system/libsystem_kernel")
3619 || StartsWithStrLit(
filename,
"/usr/lib/system/libsystem_platform")
3620 || StartsWithStrLit(
filename,
"/usr/lib/system/libsystem_pthread")
3625 || (lenFilename > 4 && !strcmp(
filename + lenFilename - 4,
".tbd")))
3628 R__UpdateLibFileForLinking(sFileName);
3630#elif defined(__CYGWIN__)
3632 static const int bufsize = 260;
3633 char posixwindir[bufsize];
3634 char *windir = std::getenv(
"WINDIR");
3636 cygwin_conv_path(CCP_WIN_A_TO_POSIX, windir, posixwindir, bufsize);
3638 snprintf(posixwindir,
sizeof(posixwindir),
"/Windows/");
3639 if (strstr(
filename, posixwindir) ||
3642#elif defined(R__WIN32)
3645#elif defined (R__LINUX)
3669 assert(!
IsFromRootCling() &&
"Trying to load library from rootcling!");
3673 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
3674 std::string canonLib = DLM->lookupLibrary(
filename);
3675 cling::DynamicLibraryManager::LoadLibResult res
3676 = cling::DynamicLibraryManager::kLoadLibNotFound;
3677 if (!canonLib.empty()) {
3679 res = DLM->loadLibrary(
filename, system,
true);
3683 cling::Interpreter::CompilationResult compRes;
3685 if (compRes == cling::Interpreter::kSuccess)
3686 res = cling::DynamicLibraryManager::kLoadLibSuccess;
3690 if (res == cling::DynamicLibraryManager::kLoadLibSuccess) {
3694 case cling::DynamicLibraryManager::kLoadLibSuccess:
return 0;
3695 case cling::DynamicLibraryManager::kLoadLibAlreadyLoaded:
return 1;
3745 Warning(
"Calc",
"waiting for cling thread to free");
3748 gROOT->SetLineIsProcessing();
3755 cling::Value valRef;
3756 cling::Interpreter::CompilationResult cr = cling::Interpreter::kFailure;
3760 catch (cling::InterpreterException&
ex)
3762 Error(
"Calc",
"%s.\n%s",
ex.what(),
"Evaluation of your expression was aborted.");
3764 cr = cling::Interpreter::kFailure;
3767 if (cr != cling::Interpreter::kSuccess) {
3775 if (!valRef.isValid()) {
3784 if (valRef.isVoid()) {
3791 gROOT->SetLineHasBeenProcessed();
3801 void (*histaddFunc)(
const char*
line))
3806#if defined(R__MUST_REVISIT)
3807#if R__MUST_REVISIT(6,2)
3808 Warning(
"SetGetline",
"Cling should support the equivalent of SetGetlineFunc(getlineFunc, histaddFunc)");
3821 if ((std::distance(T.decls_begin(), T.decls_end()) != 1)
3822 || T.deserialized_decls_begin() != T.deserialized_decls_end()
3823 || T.macros_begin() != T.macros_end()
3824 || ((!T.getFirstDecl().isNull()) && ((*T.getFirstDecl().begin()) != T.getWrapperFD()))) {
3847 std::set<TObject*>::iterator iSpecial = ((std::set<TObject*>*)
fgSetOfSpecials)->find(obj);
3865#if defined(R__MUST_REVISIT)
3866#if R__MUST_REVISIT(6,2)
3868 Warning(
"Reset",
"Cling should support the equivalent of scratch_upto(&fDictPos)");
3878#if defined(R__MUST_REVISIT)
3879#if R__MUST_REVISIT(6,2)
3881 Warning(
"ResetAll",
"Cling should support the equivalent of complete reset (unload everything but the startup decls.");
3908#if defined(R__MUST_REVISIT)
3909#if R__MUST_REVISIT(6,2)
3911 Warning(
"ResetGlobalVar",
"Cling should support the equivalent of resetglobalvar(obj)");
3923#if defined(R__MUST_REVISIT)
3924#if R__MUST_REVISIT(6,2)
3926 Warning(
"RewindDictionary",
"Cling should provide a way to revert transaction similar to rewinddictionary()");
3937#if defined(R__MUST_REVISIT)
3938#if R__MUST_REVISIT(6,2)
3940 Warning(
"DeleteGlobal",
"Cling should provide the equivalent of deleteglobal(obj), see also DeleteVariable.");
3952#if defined(R__MUST_REVISIT)
3953#if R__MUST_REVISIT(6,2)
3954 Warning(
"DeleteVariable",
"should do more that just reseting the value to zero");
3959 llvm::StringRef srName(
name);
3960 const char* unscopedName =
name;
3961 llvm::StringRef::size_type posScope = srName.rfind(
"::");
3962 const clang::DeclContext* declCtx =
nullptr;
3963 if (posScope != llvm::StringRef::npos) {
3964 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
3965 const clang::Decl* scopeDecl
3966 = lh.findScope(srName.substr(0, posScope),
3967 cling::LookupHelper::WithDiagnostics);
3969 Error(
"DeleteVariable",
"Cannot find enclosing scope for variable %s",
3973 declCtx = llvm::dyn_cast<clang::DeclContext>(scopeDecl);
3975 Error(
"DeleteVariable",
3976 "Enclosing scope for variable %s is not a declaration context",
3980 unscopedName += posScope + 2;
3984 clang::NamedDecl* nVarDecl
3985 = cling::utils::Lookup::Named(&
fInterpreter->getSema(), unscopedName, declCtx);
3987 Error(
"DeleteVariable",
"Unknown variable %s",
name);
3990 clang::VarDecl* varDecl = llvm::dyn_cast<clang::VarDecl>(nVarDecl);
3992 Error(
"DeleteVariable",
"Entity %s is not a variable",
name);
3996 clang::QualType qType = varDecl->getType();
3997 const clang::Type*
type = qType->getUnqualifiedDesugaredType();
4000 if (
type->isPointerType()) {
4001 int** ppInt = (
int**)
fInterpreter->getAddressOfGlobal(GlobalDecl(varDecl));
4003 if (ppInt) *ppInt =
nullptr;
4013#if defined(R__MUST_REVISIT)
4014#if R__MUST_REVISIT(6,2)
4016 Warning(
"SaveContext",
"Cling should provide a way to record a state watermark similar to store_dictposition(&fDictPos)");
4026#if defined(R__MUST_REVISIT)
4027#if R__MUST_REVISIT(6,2)
4029 Warning(
"SaveGlobalsContext",
"Cling should provide a way to record a watermark for the list of global variable similar to store_dictposition(&fDictPosGlobals)");
4077 std::tuple<int,double>
value;
4081 size_t offset0 = ((
char*)&(std::get<0>(
value))) - ((
char*)&
value);
4082 size_t offset1 = ((
char*)&(std::get<1>(
value))) - ((
char*)&
value);
4084 size_t ascOffset0 = ((
char*)&(asc._0)) - ((
char*)&asc);
4085 size_t ascOffset1 = ((
char*)&(asc._1)) - ((
char*)&asc);
4087 size_t desOffset0 = ((
char*)&(des._0)) - ((
char*)&des);
4088 size_t desOffset1 = ((
char*)&(des._1)) - ((
char*)&des);
4090 if (offset0 == ascOffset0 && offset1 == ascOffset1) {
4092 }
else if (offset0 == desOffset0 && offset1 == desOffset1) {
4102 std::string alternateName =
"TEmulatedTuple";
4103 alternateName.append( classname + 5 );
4105 std::string fullname =
"ROOT::Internal::" + alternateName;
4106 if (lh.findScope(fullname, cling::LookupHelper::NoDiagnostics,
4112 auto iter = tupleContent.fElements.begin() + 1;
4113 auto theEnd = tupleContent.fElements.end() - 1;
4114 auto deleter = [](TypeInfo_t *
type) {
4117 std::unique_ptr<TypeInfo_t,
decltype(deleter)>
type{
gInterpreter->TypeInfo_Factory(), deleter };
4118 while (iter != theEnd) {
4122 Error(
"Load",
"Could not declare alternate type for %s since %s (or one of its context) is private or protected",
4123 classname, iter->c_str());
4130 std::string guard_name;
4132 std::ostringstream guard;
4133 guard <<
"ROOT_INTERNAL_TEmulated_";
4134 guard << guard_name;
4136 std::ostringstream alternateTuple;
4137 std::ostringstream initializers;
4139 alternateTuple <<
"#ifndef " << guard.str() <<
"\n";
4140 alternateTuple <<
"#define " << guard.str() <<
"\n";
4141 alternateTuple <<
"namespace ROOT { namespace Internal {\n";
4142 alternateTuple <<
"template <class... Types> struct TEmulatedTuple;\n";
4143 alternateTuple <<
"template <> struct " << alternateName <<
" {\n";
4148 unsigned int nMember = 0;
4149 auto iter = tupleContent.fElements.begin() + 1;
4150 auto theEnd = tupleContent.fElements.end() - 1;
4152 while (iter != theEnd) {
4153 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
4154 initializers <<
" " << sep <<
" _" << nMember <<
"(std::get<" << nMember <<
">(std::forward<Tuple>(t)))\n";
4162 unsigned int nMember = tupleContent.fElements.size() - 3;
4163 auto iter = tupleContent.fElements.rbegin() + 1;
4164 auto theEnd = tupleContent.fElements.rend() - 1;
4166 while (iter != theEnd) {
4167 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
4168 initializers <<
" " << sep <<
" _" << nMember <<
"(std::get<" << nMember <<
">(std::forward<Tuple>(t)))\n";
4176 Fatal(
"TCling::SetClassInfo::AlternateTuple",
4177 "Layout of std::tuple on this platform is unexpected.");
4183 alternateTuple <<
" TEmulatedTuple() = default;\n";
4186 alternateTuple <<
" template <typename Tuple>\n";
4187 alternateTuple <<
" TEmulatedTuple(Tuple&& t)\n";
4188 alternateTuple << initializers.str();
4189 alternateTuple <<
" {}\n";
4191 alternateTuple <<
"};\n";
4192 alternateTuple <<
"}}\n";
4193 alternateTuple <<
"#endif\n";
4198 Error(
"Load",
"Could not declare %s",alternateName.c_str());
4201 alternateName =
"ROOT::Internal::" + alternateName;
4202 return alternateName;
4216 std::unique_ptr<TClingClassInfo> providedInfo{(
TClingClassInfo *)classInfo};
4221 providedInfo.reset();
4253 auto SetWithoutClassInfoState = [](
TClass *cl)
4266 if (strncmp(cl->
GetName(),
"tuple<",std::char_traits<char>::length(
"tuple<"))==0) {
4269 providedInfo.reset();
4272 if (reload ||
name.empty()) {
4274 SetWithoutClassInfoState(cl);
4286 if (!info->IsValid()) {
4287 SetWithoutClassInfoState(cl);
4304 zombieCandidate =
kTRUE;
4306 if (!info->IsLoaded()) {
4311 zombieCandidate =
kTRUE;
4367 Bool_t isClassOrNamespaceOnly ,
4368 ClassInfo_t **classInfo )
4372 *classInfo =
nullptr;
4373 static const char *anonEnum =
"anonymous enum ";
4374 static const int cmplen = strlen(anonEnum);
4389 && fundType->GetType() > 0) {
4401 const char *classname =
name;
4404 class MaybeSuspendAutoLoadParse {
4405 int fStoreAutoLoad = 0;
4406 int fStoreAutoParse = 0;
4407 bool fSuspendedAutoParse =
false;
4409 MaybeSuspendAutoLoadParse(
int autoload) {
4410 fStoreAutoLoad = ((
TCling*)
gCling)->SetClassAutoLoading(autoload);
4414 fSuspendedAutoParse =
true;
4415 fStoreAutoParse = ((
TCling*)
gCling)->SetSuspendAutoParsing(
true);
4418 ~MaybeSuspendAutoLoadParse() {
4419 if (fSuspendedAutoParse)
4420 ((
TCling*)
gCling)->SetSuspendAutoParsing(fStoreAutoParse);
4421 ((
TCling*)
gCling)->SetClassAutoLoading(fStoreAutoLoad);
4425 MaybeSuspendAutoLoadParse autoLoadParseRAII( autoload );
4427 autoLoadParseRAII.SuspendAutoParsing();
4436 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
4437 const clang::Type *
type =
nullptr;
4438 const clang::Decl *decl
4439 = lh.findScope(classname,
4440 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4441 : cling::LookupHelper::NoDiagnostics,
4447 const clang::Type *typeFromStd =
nullptr;
4449 decl = lh.findScope(buf,
gDebug > 5 ? cling::LookupHelper::WithDiagnostics : cling::LookupHelper::NoDiagnostics,
4450 &typeFromStd,
false);
4451 if (decl || typeFromStd)
4457 auto provideClassInfo = [
this, classInfo, &decl, &
type] {
4458 if (classInfo && decl && !decl->isInvalidDecl())
4475 clang::ClassTemplateSpecializationDecl *tmpltDecl =
4476 llvm::dyn_cast_or_null<clang::ClassTemplateSpecializationDecl>
4477 (
type->getAsCXXRecordDecl());
4478 if (tmpltDecl && !tmpltDecl->getPointOfInstantiation().isValid()) {
4489 if (!tci.IsValid()) {
4495 if (tci.Property() & propertiesMask) {
4496 bool hasClassDefInline =
false;
4497 if (isClassOrNamespaceOnly) {
4500 auto hasDictionary = tci.GetMethod(
"Dictionary",
"",
false,
nullptr,
ROOT::kExactMatch);
4501 auto implLineFunc = tci.GetMethod(
"ImplFileLine",
"",
false,
nullptr,
ROOT::kExactMatch);
4503 if (hasDictionary.IsValid() && implLineFunc.IsValid()) {
4505 bool success =
false;
4506 std::tie(success, lineNumber) =
4508 hasClassDefInline = success && (lineNumber == -1);
4517 if (hasClassDefInline)
4557 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
4560 const clang::Decl *decl
4561 = lh.findClassTemplate(
name,
4562 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4563 : cling::LookupHelper::NoDiagnostics);
4565 std::string strname =
"std::";
4567 decl = lh.findClassTemplate(strname,
4568 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4569 : cling::LookupHelper::NoDiagnostics);
4571 return nullptr != decl;
4596 listOfBase->Add(
new TBaseClass((BaseClassInfo_t *)
a, cl));
4600 cl->
fBase = listOfBase;
4616 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
4619 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
4622 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
4623 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
4624 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(), declEnd = allDeclContexts.end();
4625 declIter != declEnd; ++declIter) {
4627 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
4628 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
4629 if (
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(*DI)) {
4632 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
4633 llvm::raw_string_ostream stream(buf);
4635 Policy.AnonymousTagLocations =
false;
4636 ED->getNameForDiagnostic(stream, Policy,
false);
4640 const char*
name = buf.c_str();
4642 enumList.Get(ED,
name);
4664 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
4668 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
4671 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
4672 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
4673 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(),
4674 declEnd = allDeclContexts.end(); declIter != declEnd; ++declIter) {
4676 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
4677 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
4678 if (
const clang::FunctionTemplateDecl* FTD = dyn_cast<clang::FunctionTemplateDecl>(*DI)) {
4679 funcTempList->Get(FTD);
4692 return ci->GetUsingNamespaces();
4737 if (
m->fMethodArgs) {
4748 m->fMethodArgs = arglist;
4793 if (llvm::isa<clang::NamespaceDecl>(cli->GetDecl())) {
4800 if (!mi.IsValid()) {
4802 Error(
"GenerateTClass",
4803 "Cannot find %s::Class_Version()! Class version might be wrong.",
4810 if (newvers == -1) {
4817 callfunc.SetFunc(&mi);
4818 newvers = callfunc.ExecInt(
nullptr);
4820 Error(
"GenerateTClass",
4821 "Cannot invoke %s::Class_Version()! Class version might be wrong.",
4825 if (newvers != oldvers) {
4842static void GenerateTClass_GatherInnerIncludes(cling::Interpreter *interp,
TString &includes,
TClingClassInfo *info)
4844 includes += info->FileName();
4846 const clang::ClassTemplateSpecializationDecl *templateCl
4847 = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(info->GetDecl());
4849 for(
unsigned int i=0; i < templateCl->getTemplateArgs().
size(); ++i) {
4850 const clang::TemplateArgument &arg( templateCl->getTemplateArgs().get(i) );
4851 if (arg.getKind() == clang::TemplateArgument::Type) {
4854 if (!uType->isFundamentalType() && !uType->isEnumeralType()) {
4856 const clang::CXXRecordDecl *argdecl = uType->getAsCXXRecordDecl();
4859 TClingClassInfo subinfo(interp,*(argdecl->getASTContext().getRecordType(argdecl).getTypePtr()));
4860 GenerateTClass_GatherInnerIncludes(interp, includes, &subinfo);
4863 llvm::raw_string_ostream OS(Result);
4864 arg.print(argdecl->getASTContext().getPrintingPolicy(),OS);
4865 Warning(
"TCling::GenerateTClass",
"Missing header file for %s",OS.str().c_str());
4880 if (!info || !info->IsValid()) {
4881 Fatal(
"GenerateTClass",
"Requires a valid ClassInfo object");
4886 std::string classname;
4890 Info(
"GenerateTClass",
"Will (try to) generate the compiled TClass for %s.",classname.c_str());
4894 GenerateTClass_GatherInnerIncludes(
fInterpreter,includes,info);
4900 Error(
"GenerateTClass",
"Even though the dictionary generation for %s seemed successful we can't find the TClass bootstrap!",classname.c_str());
4904 if (cl ==
nullptr) {
4906 cl =
new TClass(classinfo, version,
nullptr,
nullptr, -1, -1, silent);
4911 cl =
new TClass(classinfo, 1,
nullptr,
nullptr, -1, -1, silent);
4936 if (classes ==
nullptr || classes[0] == 0) {
4937 Error(
"TCling::GenerateDictionary",
"Cannot generate dictionary without passing classes.");
4941 std::vector<std::string> listClasses;
4943 const char* current = classes, *prev = classes;
4947 if (*current ==
';') {
4948 listClasses.push_back(std::string(prev, current - prev));
4951 else if (*(current + 1) == 0) {
4952 listClasses.push_back(std::string(prev, current + 1 - prev));
4956 std::vector<std::string> listIncludes;
4960 const char* current = includes, *prev = includes;
4964 if (*current ==
';') {
4965 listIncludes.push_back(std::string(prev, current - prev));
4968 else if (*(current + 1) == 0) {
4969 listIncludes.push_back(std::string(prev, current + 1 - prev));
4975 std::vector<std::string>(), std::vector<std::string>());
4999 if (
const ValueDecl* decl = (
const ValueDecl*)
d){
5002 if (hasIoName && ioName !=
name)
return nullptr;
5014 using namespace clang;
5016 DeclarationName DName = &SemaR.Context.Idents.get(
name);
5018 LookupResult
R(SemaR, DName, SourceLocation(), Sema::LookupOrdinaryName,
5019 RedeclarationKind::ForExternalRedeclaration);
5021 cling::utils::Lookup::Named(&SemaR,
R);
5023 LookupResult::Filter F =
R.makeFilter();
5025 while (F.hasNext()) {
5026 NamedDecl *D = F.next();
5027 if (isa<VarDecl>(D) || isa<FieldDecl>(D) || isa<EnumConstantDecl>(D) ||
5028 isa<IndirectFieldDecl>(D))
5034 if (
R.isSingleResult())
5035 return R.getFoundDecl();
5047 const clang::Decl* possibleEnum =
nullptr;
5052 const clang::DeclContext* dc =
nullptr;
5053 if (
const clang::Decl* D = cci->GetDecl()) {
5054 if (!(dc = dyn_cast<clang::NamespaceDecl>(D))) {
5055 dc = dyn_cast<clang::RecordDecl>(D);
5062 possibleEnum = cling::utils::Lookup::Tag(&
fInterpreter->getSema(),
name, dc);
5064 Error(
"TCling::GetEnum",
"DeclContext not found for %s .\n",
name);
5073 if (possibleEnum && (possibleEnum != (clang::Decl*)-1)
5074 && isa<clang::EnumDecl>(possibleEnum)) {
5075 return possibleEnum;
5085 if (!gv)
return nullptr;
5087 llvm::StringRef mangled_name = gv->getName();
5096 d = gcl.GetDataMember(mangled_name.str().c_str());
5102 std::string scopename(demangled_name_c);
5103 free(demangled_name_c);
5109 std::string dataname;
5111 if (!strncmp(scopename.c_str(),
"typeinfo for ",
sizeof(
"typeinfo for ")-1)) {
5112 scopename.erase(0,
sizeof(
"typeinfo for ")-1);
5113 }
else if (!strncmp(scopename.c_str(),
"vtable for ",
sizeof(
"vtable for ")-1)) {
5114 scopename.erase(0,
sizeof(
"vtable for ")-1);
5117 std::string::size_type pos = scopename.rfind(
'(');
5118 if (pos != std::string::npos) {
5122 pos = scopename.rfind(
':');
5123 if (pos != std::string::npos) {
5124 if ((pos != 0) && (scopename[pos-1] ==
':')) {
5125 dataname = scopename.substr(pos+1);
5126 scopename.erase(pos-1);
5130 dataname = scopename;
5138 if (scopename.size()) {
5144 d = gcl.GetDataMember(dataname.c_str());
5154 Error(
"GetDataMemberWithValue()",
"not implemented");
5164 Error(
"GetDataMemberAtAddr()",
"not implemented");
5174 const char* params,
Bool_t objectIsConst )
5190 TString mangled_name( mi->GetMangledName() );
5192 return mangled_name;
5201 const char* proto,
Bool_t objectIsConst ,
5207 GetMethod(method, proto, objectIsConst,
nullptr ,
mode).GetMangledName();
5210 return gcl.GetMethod(method, proto, objectIsConst,
nullptr ,
mode).GetMangledName();
5219 const char* params,
Bool_t objectIsConst )
5250 f = gcl.GetMethod(method).GetDeclId();
5260 std::vector<DeclId_t>& res)
const
5263 clang::ASTContext& Ctx = S.Context;
5264 const clang::Decl* CtxDecl
5266 Ctx.getTranslationUnitDecl();
5267 auto RecDecl = llvm::dyn_cast<const clang::RecordDecl>(CtxDecl);
5268 const clang::DeclContext* DeclCtx = RecDecl;
5271 DeclCtx = dyn_cast<clang::NamespaceDecl>(CtxDecl);
5272 if (!DeclCtx)
return;
5274 clang::DeclarationName DName;
5279 if (RecDecl->getNameAsString() == funcname) {
5280 clang::CanQualType QT = Ctx.getCanonicalTagType(RecDecl);
5281 DName = Ctx.DeclarationNames.getCXXConstructorName(QT);
5282 }
else if (funcname[0] ==
'~' && RecDecl->getNameAsString() == funcname + 1) {
5283 clang::CanQualType QT = Ctx.getCanonicalTagType(RecDecl);
5284 DName = Ctx.DeclarationNames.getCXXDestructorName(QT);
5286 DName = &Ctx.Idents.get(funcname);
5289 DName = &Ctx.Idents.get(funcname);
5293 clang::LookupResult
R(S, DName, clang::SourceLocation(), Sema::LookupOrdinaryName,
5294 RedeclarationKind::NotForRedeclaration);
5295 R.suppressDiagnostics();
5296 S.LookupQualifiedName(
R,
const_cast<DeclContext*
>(DeclCtx));
5297 if (
R.empty())
return;
5299 res.reserve(res.size() + (
R.end() -
R.begin()));
5300 for (clang::LookupResult::iterator IR =
R.begin(), ER =
R.end();
5302 if (
const clang::FunctionDecl* FD
5303 = llvm::dyn_cast<const clang::FunctionDecl>(*IR)) {
5304 if (!FD->getDescribedFunctionTemplate()) {
5307 }
else if (
const auto *USD = llvm::dyn_cast<const clang::UsingShadowDecl>(*IR)) {
5309 if (llvm::isa<clang::FunctionDecl>(USD->getTargetDecl())) {
5330 GetMethod(method, proto, objectIsConst,
nullptr ,
mode).InterfaceMethod();
5334 f = gcl.GetMethod(method, proto, objectIsConst,
nullptr ,
mode).InterfaceMethod();
5356 f = gcl.GetMethod(method, params, objectIsConst,
nullptr ).GetDeclId();
5379 f = gcl.GetMethod(method, proto, objectIsConst,
nullptr ,
mode).GetDeclId();
5398 f = gcl.GetFunctionTemplate(
name);
5469 const char* params,
Bool_t objectIsConst,
int* error)
5489 const char* params,
int* error)
5491 Execute(obj,cl,method,params,
false,error);
5506 Error(
"Execute",
"No method was defined");
5509 TList* argList = method->GetListOfMethodArgs();
5515 if (argc > nparms) {
5516 Error(
"Execute",
"Too many parameters to call %s, got %d but expected at most %d.",method->GetName(),argc,nparms);
5519 if (nparms != argc) {
5529 Int_t firstDefault = -1;
5530 for (
Int_t i = 0; i < nparms; i ++) {
5537 if (firstDefault >= 0) {
5538 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);
5540 Error(
"Execute",
"Too few arguments to call %s, got only %d but expected %d.",method->GetName(),argc,nparms);
5546 const char* listpar =
"";
5551 for (
Int_t i = 0; i < argc; i ++) {
5560 chpar += (nxtpar->String()).ReplaceAll(
"\"",
"\\\"");
5567 complete += nxtpar->String();
5570 listpar = complete.Data();
5588 const CXXMethodDecl * mdecl = dyn_cast<CXXMethodDecl>(minfo->GetTargetFunctionDecl());
5597 const void* args[] ,
5602 Error(
"ExecuteWithArgsAndReturn",
"No method was defined");
5629 Warning(
"GetTopLevelMacroName",
"Must change return type!");
5676#if defined(R__MUST_REVISIT)
5677#if R__MUST_REVISIT(6,0)
5678 Warning(
"GetCurrentMacroName",
"Must change return type!");
5691 TTHREAD_TLS_DECL(std::string,t);
5693 if (!strstr(typeDesc,
"(*)(")) {
5694 const char *s = strchr(typeDesc,
' ');
5695 const char *template_start = strchr(typeDesc,
'<');
5696 if (!strcmp(typeDesc,
"long long")) {
5699 else if (!strncmp(typeDesc,
"unsigned ", s + 1 - typeDesc)) {
5706 else if (s && (template_start ==
nullptr || (s < template_start))) {
5716 auto l = t.length();
5717 while (
l > 0 && (t[
l - 1] ==
'*' || t[
l - 1] ==
'&'))
5725 assert(rootmapfile && *rootmapfile);
5727 llvm::StringRef libName = llvm::sys::path::filename(rootmapfile);
5728 libName.consume_back(
".rootmap");
5730 return !
gInterpreter->HasPCMForLibrary(libName.str().c_str());
5741 if (!(rootmapfile && *rootmapfile))
5748 const std::map<char, unsigned int> keyLenMap = {{
'c',6},{
'n',10},{
't',8},{
'h',7},{
'e',5},{
'v',4}};
5750 std::string rootmapfileNoBackslash(rootmapfile);
5752 std::replace(rootmapfileNoBackslash.begin(), rootmapfileNoBackslash.end(),
'\\',
'/');
5759 std::string lineDirective = std::string(
"\n#line 2 \"Forward declarations from ") + rootmapfileNoBackslash +
"\"\n";
5761 std::ifstream file(rootmapfileNoBackslash);
5764 std::string lib_name;
5766 bool newFormat =
false;
5767 while (getline(file,
line,
'\n')) {
5768 if (!newFormat && (
line.compare(0, 8,
"Library.") == 0 ||
line.compare(0, 8,
"Declare.") == 0)) {
5774 if (
line.compare(0, 9,
"{ decls }") == 0) {
5777 while (getline(file,
line,
'\n')) {
5780 if (!uniqueString) {
5781 Error(
"ReadRootmapFile",
"Cannot handle \"{ decls }\" sections in custom rootmap file %s",
5782 rootmapfileNoBackslash.c_str());
5785 if (!lineDirective.empty())
5786 uniqueString->Append(lineDirective);
5787 uniqueString->Append(
line +
'\n');
5790 const char firstChar =
line[0];
5791 if (firstChar ==
'[') {
5793 auto brpos =
line.find(
']');
5794 if (brpos == string::npos)
5796 lib_name =
line.substr(1, brpos - 1);
5798 lib_name.erase(lib_name.find_last_not_of(
' ') + 1);
5799 lib_name.erase(0, lib_name.find_first_not_of(
' '));
5801 TString lib_nameTstr(lib_name.c_str());
5802 TObjArray *tokens = lib_nameTstr.Tokenize(
" ");
5806 Info(
"ReadRootmapFile",
"%s: New section for %s", rootmapfile, lib_nameTstr.Data());
5808 Info(
"ReadRootmapFile",
"%s: Section for %s (library does not exist)", rootmapfile, lib_nameTstr.Data());
5814 auto keyLenIt = keyLenMap.find(firstChar);
5815 if (keyLenIt == keyLenMap.end())
5817 unsigned int keyLen = keyLenIt->second;
5819 const char *keyname =
line.c_str() + keyLen;
5821 Info(
"ReadRootmapFile",
"%s: class %s in %s", rootmapfile, keyname, lib_name.c_str());
5824 if (lib_name != isThere->GetValue()) {
5825 if (firstChar ==
'n') {
5827 Info(
"ReadRootmapFile",
5828 "While processing %s, namespace %s was found to be associated to %s although it is already "
5830 rootmapfile, keyname, lib_name.c_str(), isThere->GetValue());
5831 }
else if (firstChar ==
'h') {
5833 lib_name += isThere->GetValue();
5837 "While processing %s, %s %s was found to be associated to %s although it is already "
5839 rootmapfile,
line.substr(0, keyLen - 1).c_str(), keyname, lib_name.c_str(),
5840 isThere->GetValue());
5844 Info(
"ReadRootmapFile",
"While processing %s, key %s was found to be already defined for %s",
5845 rootmapfile, keyname, lib_name.c_str());
5906 using namespace clang;
5908 class ExtVisibleStorageAdder:
public RecursiveASTVisitor<ExtVisibleStorageAdder>{
5914 ExtVisibleStorageAdder(std::unordered_set<const NamespaceDecl*>& nsSet): fNSSet(nsSet) {};
5915 bool VisitNamespaceDecl(NamespaceDecl* nsDecl) {
5920 nsDecl->setHasExternalVisibleStorage();
5921 fNSSet.insert(nsDecl);
5924 bool VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl* specDecl) {
5927 if (specDecl->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
5929 specDecl->setHasExternalLexicalStorage();
5941 std::unordered_set<const NamespaceDecl*>& fNSSet;
5979 TObjArray* paths = ldpath.Tokenize(
";");
5981 TObjArray* paths = ldpath.Tokenize(
":");
5984 for (
Int_t i = 0; i < paths->GetEntriesFast(); i++) {
5988 for (
Int_t j = 0; j < i; j++) {
5999 Info(
"LoadLibraryMap",
"%s",
d.Data());
6004 if (
f.EndsWith(
".rootmap")) {
6010 Info(
"LoadLibraryMap",
" rootmap file: %s",
p.Data());
6028 if (
f.BeginsWith(
"rootmap")) {
6033 Warning(
"LoadLibraryMap",
"please rename %s to end with \".rootmap\"",
p.Data());
6046 if (rootmapfile && *rootmapfile) {
6053 else if (res == -3) {
6063 while ((rec = (
TEnvRec*) next())) {
6065 if (!strncmp(cls.Data(),
"Library.", 8) && cls.Length() > 8) {
6067 TString libs = rec->GetValue();
6072 TObjArray* tokens = libs.Tokenize(delim);
6077 cls.ReplaceAll(
"@@",
"::");
6080 cls.ReplaceAll(
"-",
" ");
6084 Info(
"LoadLibraryMap",
"class %s in %s", cls.Data(), wlib);
6087 Info(
"LoadLibraryMap",
"class %s in %s (library does not exist)", cls.Data(), lib);
6093 else if (!strncmp(cls.Data(),
"Declare.", 8) && cls.Length() > 8) {
6097 cls.ReplaceAll(
"-",
" ");
6103 cling::Transaction* T =
nullptr;
6104 auto compRes=
fInterpreter->declare(uniqueString.Data(), &T);
6105 assert(cling::Interpreter::kSuccess == compRes &&
"A declaration in a rootmap could not be compiled");
6107 if (compRes!=cling::Interpreter::kSuccess){
6109 "Problems in %s declaring '%s' were encountered.", rootmapfile, uniqueString.Data()) ;
6114 for (
auto declIt = T->decls_begin(); declIt < T->decls_end(); ++declIt) {
6115 if (declIt->m_DGR.isSingleDecl()) {
6116 if (Decl* D = declIt->m_DGR.getSingleDecl()) {
6117 if (clang::isa<TagDecl>(D) || clang::isa<NamespaceDecl>(D)) {
6118 evsAdder.TraverseDecl(D);
6151 const TObjArray* sharedLibL = sharedLibLStr.Tokenize(
" ");
6152 const Int_t nrSharedLibs = sharedLibL->GetEntriesFast();
6153 for (
Int_t ilib = 0; ilib < nrSharedLibs; ilib++) {
6160 TString rootMapBaseStr = sharedLibBaseStr;
6161 if (sharedLibBaseStr.EndsWith(
".dll")) {
6164 else if (sharedLibBaseStr.EndsWith(
".DLL")) {
6167 else if (sharedLibBaseStr.EndsWith(
".so")) {
6170 else if (sharedLibBaseStr.EndsWith(
".sl")) {
6173 else if (sharedLibBaseStr.EndsWith(
".dl")) {
6176 else if (sharedLibBaseStr.EndsWith(
".a")) {
6180 Error(
"ReloadAllSharedLibraryMaps",
"Unknown library type %s", sharedLibBaseStr.Data());
6184 rootMapBaseStr +=
".rootmap";
6187 Error(
"ReloadAllSharedLibraryMaps",
"Could not find rootmap %s in path", rootMapBaseStr.Data());
6194 Error(
"ReloadAllSharedLibraryMaps",
"Error loading map %s", rootMap);
6212 const TObjArray* sharedLibL = sharedLibLStr.Tokenize(
" ");
6213 for (
Int_t ilib = 0; ilib < sharedLibL->GetEntriesFast(); ilib++) {
6229 if (!
fMapfile || !library || !*library) {
6233 Ssiz_t idx = libname.Last(
'.');
6235 libname.Remove(idx);
6237 size_t len = libname.Length();
6242 while ((rec = (
TEnvRec *) next())) {
6244 if (cls.Length() > 2) {
6246 TString libs = rec->GetValue();
6251 TObjArray* tokens = libs.Tokenize(delim);
6253 if (!strncmp(cls.Data(),
"Library.", 8) && cls.Length() > 8) {
6257 cls.ReplaceAll(
"@@",
"::");
6260 cls.ReplaceAll(
"-",
" ");
6262 if (!strncmp(lib, libname.Data(),
len)) {
6264 Error(
"UnloadLibraryMap",
"entry for <%s, %s> not found in library map table", cls.Data(), lib);
6272 TString library_rootmap(library);
6273 if (!library_rootmap.EndsWith(
".rootmap"))
6274 library_rootmap.Append(
".rootmap");
6325 if (err)
return nullptr;
6327 free(demangled_name);
6345 std::string demangled_name(demangled_name_c);
6346 free(demangled_name_c);
6373 if (!deplibs.IsNull()) {
6375 TObjArray* tokens = deplibs.Tokenize(delim);
6376 for (
Int_t i = (tokens->GetEntriesFast() - 1); i > 0; --i) {
6378 if (
gROOT->LoadClass(cls, deplib) == 0) {
6381 "loaded dependent library %s for %s", deplib, cls);
6386 "failure loading dependent library %s for %s",
6391 if (lib && lib[0]) {
6392 if (
gROOT->LoadClass(cls, lib) == 0) {
6395 "loaded library %s for %s", lib, cls);
6401 "failure loading library %s for %s", lib, cls);
6416 bool nameIsNormalized)
6422 if (!visited.insert(std::string(cls)).second)
6432 for (
auto element : proto->GetData()) {
6433 if (element->IsBasic())
6435 const char *subtypename = element->GetTypeName();
6451 if (classinfo &&
gInterpreter->ClassInfo_IsValid(classinfo)
6455 while (
gInterpreter->DataMemberInfo_Next(memberinfo)) {
6488 Info(
"TCling::AutoLoad",
"Explicitly disabled (the class name is %s)", cls);
6508 Info(
"TCling::AutoLoad",
6509 "Trying to autoload for %s", cls);
6514 Info(
"TCling::AutoLoad",
6515 "Disabled due to gROOT or gInterpreter being invalid/not ready (the class name is %s)", cls);
6536 std::unordered_set<std::string> visited;
6545 cling::Interpreter *interpreter)
6547 std::string code = gNonInterpreterClassDef ;
6554 code += (
"#include \"");
6558 code += (
"#ifdef __ROOTCLING__\n"
6559 "#undef __ROOTCLING__\n"
6560 + gInterpreterClassDef +
6563 cling::Interpreter::CompilationResult cr;
6569 Sema &SemaR = interpreter->getSema();
6571 clangDiagSuppr diagSuppr(SemaR.getDiagnostics());
6573 #if defined(R__MUST_REVISIT)
6574 #if R__MUST_REVISIT(6,2)
6575 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
6579 cr = interpreter->parseForModule(code);
6597 Int_t nHheadersParsed = 0;
6598 unsigned long offset = 0;
6599 if (strncmp(cls,
"const ", 6) == 0) {
6604 bool skipFirstEntry =
false;
6605 std::vector<std::string> autoparseKeys;
6606 if (strchr(cls,
'<')) {
6612 if (!autoparseKeys.empty() && !autoparseKeys[0].empty()) {
6617 TString templateName(autoparseKeys[0]);
6618 auto tokens = templateName.Tokenize(
"::");
6619 clang::NamedDecl* previousScopeAsNamedDecl =
nullptr;
6620 clang::DeclContext* previousScopeAsContext =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
6622 previousScopeAsContext =
fInterpreter->getSema().getStdNamespace();
6623 auto nTokens = tokens->GetEntriesFast();
6624 for (
Int_t tk = 0; tk < nTokens; ++tk) {
6625 auto scopeObj = tokens->UncheckedAt(tk);
6626 auto scopeName = ((
TObjString*) scopeObj)->String().Data();
6627 previousScopeAsNamedDecl = cling::utils::Lookup::Named(&
fInterpreter->getSema(), scopeName, previousScopeAsContext);
6629 if ((clang::NamedDecl*)-1 == previousScopeAsNamedDecl)
break;
6630 previousScopeAsContext = llvm::dyn_cast_or_null<clang::DeclContext>(previousScopeAsNamedDecl);
6631 if (!previousScopeAsContext)
break;
6635 if ((clang::NamedDecl*)-1 != previousScopeAsNamedDecl) {
6636 if (
auto templateDecl = llvm::dyn_cast_or_null<clang::ClassTemplateDecl>(previousScopeAsNamedDecl)) {
6637 if (
auto templatedDecl = templateDecl->getTemplatedDecl()) {
6638 skipFirstEntry = templatedDecl->hasDefinition();
6645 if (topLevel) autoparseKeys.emplace_back(cls);
6647 for (
const auto & apKeyStr : autoparseKeys) {
6648 if (skipFirstEntry) {
6649 skipFirstEntry=
false;
6652 if (apKeyStr.empty())
continue;
6653 const char *apKey = apKeyStr.c_str();
6657 Info(
"TCling::AutoParse",
6658 "Starting autoparse for %s\n", apKey);
6663 const cling::Transaction *T =
fInterpreter->getCurrentTransaction();
6665 auto const &hNamesPtrs = iter->second;
6667 Info(
"TCling::AutoParse",
6668 "We can proceed for %s. We have %s headers.", apKey, std::to_string(hNamesPtrs.size()).c_str());
6670 for (
auto & hName : hNamesPtrs) {
6672 if (0 !=
fPayloads.count(normNameHash)) {
6673 float initRSSval=0.f, initVSIZEval=0.f;
6675 (void) initVSIZEval;
6678 "Parsing full payload for %s", apKey);
6681 initRSSval = 1
e-3*info.fMemResident;
6682 initVSIZEval = 1
e-3*info.fMemVirtual;
6685 if (cRes != cling::Interpreter::kSuccess) {
6686 if (hName[0] ==
'\n')
6687 Error(
"AutoParse",
"Error parsing payload code for class %s with content:\n%s", apKey, hName);
6694 float endRSSval = 1
e-3*info.fMemResident;
6695 float endVSIZEval = 1
e-3*info.fMemVirtual;
6696 Info(
"Autoparse",
">>> RSS key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initRSSval, endRSSval, endRSSval-initRSSval);
6697 Info(
"Autoparse",
">>> VSIZE key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initVSIZEval, endVSIZEval, endVSIZEval-initVSIZEval);
6703 "Parsing single header %s", hName);
6706 if (cRes != cling::Interpreter::kSuccess) {
6707 Error(
"AutoParse",
"Error parsing headerfile %s for class %s.", hName, apKey);
6719 if (strchr(apKey,
'<')) {
6726 if (nHheadersParsed) {
6730 Info(
"AutoParse",
"Parsed %d headers for %s", nHheadersParsed, cls);
6732 return nHheadersParsed;
6742 if (llvm::StringRef(cls).contains(
"(lambda)"))
6756 Info(
"TCling::AutoParse",
6757 "Trying to autoparse for %s", cls);
6779 return nHheadersParsed > 0 ? 1 : 0;
6787 StringRef errMsg(errmessage);
6788 if (errMsg.contains(
"undefined symbol: ")) {
6790 std::string mangled_name = std::string(errMsg.split(
"undefined symbol: ").second);
6791 void* res = ((
TCling*)
gCling)->LazyFunctionCreatorAutoload(mangled_name);
6792 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
6793 if (res && DLM && (DLM->loadLibrary(libStem, permanent, resolved) == cling::DynamicLibraryManager::kLoadLibSuccess))
6812 if (
void* Addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(dlsym_mangled_name))
6815 const cling::DynamicLibraryManager &DLM = *
GetInterpreterImpl()->getDynamicLibraryManager();
6818 auto LibLoader = [](
const std::string& LibName) ->
bool {
6819 if (
gSystem->
Load(LibName.c_str(),
"",
false) < 0) {
6820 ::Error(
"TCling__LazyFunctionCreatorAutoloadForModule",
6821 "Failed to load library %s", LibName.c_str());
6827 std::string libName = DLM.searchLibrariesForSymbol(mangled_name,
6830 assert(!llvm::StringRef(libName).starts_with(
"libNew") &&
"We must not resolve symbols from libNew!");
6832 if (libName.empty())
6835 if (!LibLoader(libName))
6839 return llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(dlsym_mangled_name);
6859 const NamedDecl *oldDef = llvm::dyn_cast_or_null<NamedDecl>(cci->GetDecl());
6860 if (!oldDef || (def && def != oldDef)) {
6864 if (cci->GetType()) {
6866 cci->Init(*cci->GetType());
6869 Error(
"RefreshClassInfo",
"Should not need to update the classInfo a non type decl: %s", oldDef->getNameAsString().c_str());
6875 if (strncmp(cl->
GetName(),
"tuple<",strlen(
"tuple<"))==0) {
6890 if (!alias && def !=
nullptr)
6912 const TagDecl *td = dyn_cast<TagDecl>(ND);
6913 const NamespaceDecl *ns = dyn_cast<NamespaceDecl>(ND);
6914 const NamedDecl *canon =
nullptr;
6917 TagDecl* tdDef =
nullptr;
6919 canon = tdDef = td->getDefinition();
6923 if (!tdDef->isCompleteDefinition() || llvm::isa<clang::FunctionDecl>(tdDef->getDeclContext())) {
6929 auto declName = tdDef->getNameAsString();
6940 clang::QualType
type = tdDef->getASTContext().getCanonicalTagType(tdDef);
6943 canon = ns->getCanonicalDecl();
6944 name = ND->getQualifiedNameAsString();
6946 name = ND->getQualifiedNameAsString();
6995 std::set<TClass*> modifiedTClasses;
7000 bool isTUTransaction =
false;
7001 if (!T.empty() && T.decls_begin() + 1 == T.decls_end() && !T.hasNestedTransactions()) {
7002 clang::Decl* FirstDecl = *(T.decls_begin()->m_DGR.begin());
7003 if (llvm::isa<clang::TranslationUnitDecl>(FirstDecl)) {
7006 isTUTransaction =
true;
7010 std::set<const void*> TransactionDeclSet;
7011 if (!isTUTransaction && T.decls_end() - T.decls_begin()) {
7012 const clang::Decl* WrapperFD = T.getWrapperFD();
7013 for (cling::Transaction::const_iterator I = T.decls_begin(), E = T.decls_end();
7015 if (I->m_Call != cling::Transaction::kCCIHandleTopLevelDecl
7016 && I->m_Call != cling::Transaction::kCCIHandleTagDeclDefinition)
7019 for (DeclGroupRef::const_iterator DI = I->m_DGR.begin(),
7020 DE = I->m_DGR.end(); DI != DE; ++DI) {
7021 if (*DI == WrapperFD)
7023 TransactionDeclSet.insert(*DI);
7024 ((
TCling*)
gCling)->HandleNewDecl(*DI,
false, modifiedTClasses);
7031 for (cling::Transaction::const_iterator I = T.deserialized_decls_begin(),
7032 E = T.deserialized_decls_end(); I != E; ++I) {
7033 for (DeclGroupRef::const_iterator DI = I->m_DGR.begin(),
7034 DE = I->m_DGR.end(); DI != DE; ++DI)
7035 if (TransactionDeclSet.find(*DI) == TransactionDeclSet.end()) {
7051 std::vector<TClass*> modifiedTClassesDiff(modifiedTClasses.size());
7052 std::vector<TClass*>::iterator it;
7053 it = set_difference(modifiedTClasses.begin(), modifiedTClasses.end(),
7056 modifiedTClassesDiff.begin());
7057 modifiedTClassesDiff.resize(it - modifiedTClassesDiff.begin());
7060 ((
TCling*)
gCling)->GetModTClasses().insert(modifiedTClassesDiff.begin(),
7061 modifiedTClassesDiff.end());
7062 for (std::vector<TClass*>::const_iterator I = modifiedTClassesDiff.begin(),
7063 E = modifiedTClassesDiff.end(); I != E; ++I) {
7065 if (!
gROOT->GetListOfClasses()->FindObject(*I)) {
7087 cling::Transaction::const_nested_iterator iNested = T.nested_begin();
7088 for (cling::Transaction::const_iterator I = T.decls_begin(), E = T.decls_end();
7090 if (I->m_Call == cling::Transaction::kCCIHandleVTable)
7092 if (I->m_Call == cling::Transaction::kCCINone) {
7098 for (
auto &D : I->m_DGR)
7124 if (D->isFromASTFile())
7132 if (isa<VarDecl>(D) || isa<FieldDecl>(D) || isa<EnumConstantDecl>(D)) {
7134 if (LODM.GetClass())
7138 }
else if (isa<FunctionDecl>(D)) {
7140 }
else if (isa<FunctionTemplateDecl>(D)) {
7142 }
else if (isa<EnumDecl>(D)) {
7153 }
else if (isa<RecordDecl>(D) || isa<NamespaceDecl>(D)) {
7154 if (isa<RecordDecl>(D) && !cast<RecordDecl>(D)->isCompleteDefinition())
7157 std::vector<TClass *> Classes;
7160 for (
auto &C : Classes) {
7165 for (
auto &I : cast<DeclContext>(D)->decls())
7169 if (D->getKind() != Decl::Namespace || cast<NamespaceDecl>(D)->isFirstDecl())
7170 C->ResetClassInfo();
7182 std::size_t normNameHash = triter->second;
7188 auto const &hNamesPtrs = iter->second;
7189 for (
auto &hName : hNamesPtrs) {
7191 Info(
"TransactionRollback",
7192 "Restoring ability to autoaparse: %s", hName);
7229 using namespace clang;
7230 if (
const Decl *D = LH.findScope(cls, cling::LookupHelper::NoDiagnostics,
7232 if (!D->isFromASTFile()) {
7234 Warning(
"GetClassSharedLibsForModule",
"Decl found for %s is not part of a module", cls);
7237 class ModuleCollector :
public ConstDeclVisitor<ModuleCollector> {
7238 llvm::DenseSet<Module *> &m_TopLevelModules;
7241 ModuleCollector(llvm::DenseSet<Module *> &TopLevelModules) : m_TopLevelModules(TopLevelModules) {}
7242 void Collect(
const Decl *D) { Visit(D); }
7244 void VisitDecl(
const Decl *D)
7254 if (!D->hasOwningModule())
7256 if (Module *M = D->getOwningModule()->getTopLevelModule())
7257 m_TopLevelModules.insert(M);
7260 void VisitTemplateArgument(
const TemplateArgument &
TA)
7262 switch (
TA.getKind()) {
7263 case TemplateArgument::Null:
7264 case TemplateArgument::Integral:
7265 case TemplateArgument::Pack:
7266 case TemplateArgument::NullPtr:
7267 case TemplateArgument::StructuralValue:
7268 case TemplateArgument::Expression:
7269 case TemplateArgument::Template:
7270 case TemplateArgument::TemplateExpansion:
return;
7271 case TemplateArgument::Type:
7272 if (
const TagType *TagTy = dyn_cast<TagType>(
TA.getAsType()))
7273 return Visit(TagTy->getDecl());
7275 case TemplateArgument::Declaration:
return Visit(
TA.getAsDecl());
7277 llvm_unreachable(
"Invalid TemplateArgument::Kind!");
7280 void VisitClassTemplateSpecializationDecl(
const ClassTemplateSpecializationDecl *CTSD)
7282 if (CTSD->getOwningModule())
7285 VisitDecl(CTSD->getSpecializedTemplate());
7286 const TemplateArgumentList &ArgList = CTSD->getTemplateArgs();
7287 for (
const TemplateArgument *Arg = ArgList.data(), *ArgEnd = Arg + ArgList.size(); Arg != ArgEnd; ++Arg) {
7288 VisitTemplateArgument(*Arg);
7293 llvm::DenseSet<Module *> TopLevelModules;
7294 ModuleCollector
m(TopLevelModules);
7297 for (
auto M : TopLevelModules) {
7300 if (!M->LinkLibraries.size())
7303 if (M->Name ==
"Core" && skipCore)
7305 assert(M->LinkLibraries.size() == 1);
7308 result += M->LinkLibraries[0].Library;
7331 llvm::StringRef className = cls;
7337 if (className.contains(
"(lambda)"))
7341 cling::LookupHelper &LH =
fInterpreter->getLookupHelper();
7343 if (!libs.empty()) {
7349 if (!cls || !*cls) {
7354 TEnvRec* libs_record =
nullptr;
7357 const char* libs = libs_record->GetValue();
7358 return (*libs) ? libs :
nullptr;
7372 TEnvRec* libs_record =
nullptr;
7375 const char* libs = libs_record->GetValue();
7376 return (*libs) ? libs :
nullptr;
7390 cling::Interpreter *interp,
7391 bool skipLoadedLibs =
true)
7394 if (!llvm::sys::path::is_absolute(lib)) {
7396 Error(
"TCling__GetSharedLibImmediateDepsSlow",
"Cannot find library '%s'", lib.c_str());
7400 assert(llvm::sys::fs::exists(lib) &&
"Must exist!");
7401 lib = llvm::sys::path::filename(lib).str();
7404 auto ObjF = llvm::object::ObjectFile::createObjectFile(LibFullPath.Data());
7406 Warning(
"TCling__GetSharedLibImmediateDepsSlow",
"Failed to read object file %s", lib.c_str());
7410 llvm::object::ObjectFile *BinObjFile = ObjF.get().getBinary();
7412 std::set<string> DedupSet;
7413 std::string Result = lib +
' ';
7414 for (
const auto &S : BinObjFile->symbols()) {
7415 uint32_t Flags = llvm::cantFail(S.getFlags());
7417 if (!(Flags & llvm::object::SymbolRef::SF_Undefined))
7421 if (Flags & llvm::object::SymbolRef::SF_Weak)
7423 llvm::Expected<StringRef> SymNameErr = S.getName();
7425 Warning(
"GetSharedLibDepsForModule",
"Failed to read symbol");
7428 llvm::StringRef SymName = SymNameErr.get();
7429 if (SymName.empty())
7432 if (BinObjFile->isELF()) {
7436 if (SymName.contains(
"@GLIBCXX") || SymName.contains(
"@CXXABI") ||
7437 SymName.contains(
"@GLIBC") || SymName.contains(
"@GCC"))
7445 static constexpr llvm::StringRef RegisterClasses(
"_Jv_RegisterClasses");
7446 static constexpr llvm::StringRef RegisterCloneTable(
"_ITM_registerTMCloneTable");
7447 static constexpr llvm::StringRef DeregisterCloneTable(
"_ITM_deregisterTMCloneTable");
7448 if (SymName == RegisterClasses ||
7449 SymName == RegisterCloneTable ||
7450 SymName == DeregisterCloneTable)
7455 if (skipLoadedLibs) {
7457 if (llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(SymNameForDlsym))
7462 std::string found = interp->getDynamicLibraryManager()->searchLibrariesForSymbol(SymName,
false);
7468 if (!found.empty()) {
7469 std::string cand = llvm::sys::path::filename(found).str();
7470 if (!DedupSet.insert(cand).second)
7473 Result += cand +
' ';
7483 llvm::SmallString<256> rootmapName;
7484 if (!lib.starts_with(
"lib"))
7485 rootmapName.append(
"lib");
7487 rootmapName.append(llvm::sys::path::filename(lib));
7488 llvm::sys::path::replace_extension(rootmapName,
"rootmap");
7494 llvm::StringRef rootmapNameNoLib = rootmapName.str();
7495 if (rootmapNameNoLib.consume_front(
"lib"))
7519 if (llvm::sys::path::is_absolute(lib) && !llvm::sys::fs::exists(lib))
7523 llvm::SmallString<512> rootmapName(lib);
7524 llvm::sys::path::replace_extension(rootmapName,
"rootmap");
7525 if (llvm::sys::fs::exists(rootmapName)) {
7527 Info(
"Load",
"loading %s", rootmapName.c_str());
7534 Warning(
"TCling::GetSharedLibDeps",
"Precomputed dependencies available but scanning '%s'", lib);
7539 if (!libs.empty()) {
7545 if (!
fMapfile || !lib || !lib[0]) {
7549 Ssiz_t idx = libname.Last(
'.');
7551 libname.Remove(idx);
7555 size_t len = libname.Length();
7556 while ((rec = (
TEnvRec*) next())) {
7557 const char* libs = rec->GetValue();
7558 if (!strncmp(libs, libname.Data(),
len) && strlen(libs) >=
len
7559 && (!libs[
len] || libs[
len] ==
' ' || libs[
len] ==
'.')) {
7572#if defined(R__MUST_REVISIT)
7573#if R__MUST_REVISIT(6,2)
7574 Warning(
"IsErrorMessagesEnabled",
"Interface not available yet.");
7586#if defined(R__MUST_REVISIT)
7587#if R__MUST_REVISIT(6,2)
7588 Warning(
"SetErrorMessages",
"Interface not available yet.");
7604 llvm::SmallVector<std::string, 10> includePaths;
7606 fInterpreter->GetIncludePaths(includePaths,
false,
true);
7607 if (
const size_t nPaths = includePaths.size()) {
7608 assert(!(nPaths & 1) &&
"GetIncludePath, number of paths and options is not equal");
7610 for (
size_t i = 0; i < nPaths; i += 2) {
7615 if (includePaths[i] !=
"-I")
7649 assert(fout !=
nullptr &&
"DisplayIncludePath, 'fout' parameter is null");
7651 llvm::SmallVector<std::string, 10> includePaths;
7653 fInterpreter->GetIncludePaths(includePaths,
false,
true);
7654 if (
const size_t nPaths = includePaths.size()) {
7655 assert(!(nPaths & 1) &&
"DisplayIncludePath, number of paths and options is not equal");
7657 std::string allIncludes(
"include path:");
7658 for (
size_t i = 0; i < nPaths; i += 2) {
7660 allIncludes += includePaths[i];
7662 if (includePaths[i] !=
"-I")
7664 allIncludes += includePaths[i + 1];
7667 fprintf(fout,
"%s\n", allIncludes.c_str());
7687#if defined(R__MUST_REVISIT)
7688#if R__MUST_REVISIT(6,2)
7689 Warning(
"GenericError",
"Interface not available yet.");
7717#if defined(R__MUST_REVISIT)
7718#if R__MUST_REVISIT(6,2)
7719 Warning(
"GetSecurityError",
"Interface not available yet.");
7732 cling::Interpreter::CompilationResult compRes;
7734 return compRes == cling::Interpreter::kFailure;
7753 TTHREAD_TLS_DECL(std::string,buffer);
7755 return buffer.c_str();
7836#if defined(R__MUST_REVISIT)
7837#if R__MUST_REVISIT(6,2)
7838 Warning(
"SetErrmsgcallback",
"Interface not available yet.");
7847 &
fInterpreter->getDiagnostics().getDiagnosticOptions(),
7849 [] (clang::DiagnosticsEngine::Level Level,
const std::string &
Info) {
7850 if (Level == clang::DiagnosticsEngine::Warning) {
7851 ::Warning(
"cling",
"%s", Info.c_str());
7852 }
else if (Level == clang::DiagnosticsEngine::Error
7853 || Level == clang::DiagnosticsEngine::Fatal) {
7859 fInterpreter->replaceDiagnosticConsumer(consumer,
true);
7861 fInterpreter->replaceDiagnosticConsumer(
nullptr);
7880 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
7881 std::string canonical = DLM->lookupLibrary(path);
7882 if (canonical.empty()) {
7886 cling::Interpreter::CompilationResult compRes;
7888 return compRes == cling::Interpreter::kFailure;
7892 return std::unique_ptr<TInterpreterValue>(
new TClingValue);
7899 std::vector<std::string>& completions)
7910 auto V =
reinterpret_cast<cling::Value*
>(
value.GetValAddr());
7912 return compRes!=cling::Interpreter::kSuccess ? 0 : 1 ;
7919 using namespace cling;
7920 const Value* V =
reinterpret_cast<const Value*
>(
value.GetValAddr());
7933 if (
value.isValid() &&
value.needsManagedAllocation()) {
7954 auto iSpecObj = iSpecObjMap->second.find(Name);
7955 if (iSpecObj != iSpecObjMap->second.end()) {
7957 return iSpecObj->second;
7964 ASTContext& C = SemaR.getASTContext();
7965 Preprocessor &PP = SemaR.getPreprocessor();
7966 Parser& P =
const_cast<Parser&
>(
fInterpreter->getParser());
7967 Preprocessor::CleanupAndRestoreCacheRAII cleanupRAII(PP);
7968 Parser::ParserCurTokRestoreRAII savedCurToken(P);
7971 Token& Tok =
const_cast<Token&
>(P.getCurToken());
7972 Tok.setKind(tok::semi);
7978 Sema::ContextAndScopeRAII pushedDCAndS(SemaR, C.getTranslationUnitDecl(),
7981 TObject* specObj =
gROOT->FindSpecialObject(Name, LookupCtx);
7984 Error(
"GetObjectAddress",
"Got a special object without LookupCtx!");
7998 clang::CXXRecordDecl* klass)
const
8000 using namespace clang;
8001 ASTContext& Ctx = klass->getASTContext();
8002 FriendDecl::FriendUnion friendUnion(function);
8005 FriendDecl* friendDecl = FriendDecl::Create(Ctx, klass, sl, friendUnion, sl);
8006 klass->pushFriendDecl(friendDecl);
8020 if (func)
return ((
TClingCallFunc*)func)->GetDecl()->getCanonicalDecl();
8091 f->Exec(address, &val);
8099 f->ExecWithReturn(address, ret);
8105 const void* args[] ,
8110 f->ExecWithArgsAndReturn(address, args, nargs, ret);
8118 return f->ExecInt(address);
8126 return f->ExecInt64(address);
8134 return f->ExecDouble(address);
8157 return (MethodInfo_t*)
f->FactoryMethod();
8165 f->IgnoreExtraArgs(ignore);
8182 return f->IsValid();
8191 return f->IFacePtr();
8255 f->SetArgArray(paramArr, nparam);
8272 f->SetFunc(ci, method, params,
offset);
8281 f->SetFunc(ci, method, params, objectIsConst,
offset);
8309 f->SetFuncProto(ci, method, proto, objectIsConst,
offset,
mode);
8319 llvm::SmallVector<clang::QualType, 4> funcProto;
8320 for (std::vector<TypeInfo_t*>::const_iterator iter = proto.begin(), end = proto.end();
8321 iter != end; ++iter) {
8322 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
8324 f->SetFuncProto(ci, method, funcProto,
offset,
mode);
8334 llvm::SmallVector<clang::QualType, 4> funcProto;
8335 for (std::vector<TypeInfo_t*>::const_iterator iter = proto.begin(), end = proto.end();
8336 iter != end; ++iter) {
8337 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
8339 f->SetFuncProto(ci, method, funcProto, objectIsConst,
offset,
mode);
8345 std::string wrapper_name;
8346 std::string wrapper;
8347 f->get_wrapper_code(wrapper_name, wrapper);
8374 const clang::DeclContext *ctxt =
nullptr;
8376 ctxt = clang::Decl::castToDeclContext(((
TClingClassInfo*)info)->GetDecl());
8378 ctxt =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
8383 const clang::Decl *decl =
reinterpret_cast<const clang::Decl*
>(declid);
8387 const clang::DeclContext *declDC = decl->getDeclContext();
8390 if (declDC->isTransparentContext()) {
8391 declDC = declDC->getParent();
8394 if (
const auto *declRD = llvm::dyn_cast<clang::RecordDecl>(declDC)) {
8395 if (declRD->isAnonymousStructOrUnion()) {
8396 declDC = declRD->getParent();
8400 if (
const auto *declNS = llvm::dyn_cast<clang::NamespaceDecl>(declDC)) {
8401 if (declNS->isAnonymousNamespace() || declNS->isInlineNamespace()) {
8402 declDC = declNS->getParent();
8409 return declDC->Equals(ctxt);
8520 TClinginfo->
Init(tagnum);
8593 return TClinginfo->
Next();
8641 return TClinginfo->
Size();
8649 return TClinginfo->
Tagnum();
8665 TTHREAD_TLS_DECL(std::string,output);
8667 return output.c_str();
8675 return TClinginfo->
Name();
8683 return TClinginfo->
Title();
8720 ClassInfo_t* base)
const
8733 return TClinginfo->
Next();
8741 return TClinginfo->
Next(onlyDirect);
8749 return TClinginfo->
Offset(address, isDerivedObject);
8759 if (TClinginfo->GetDecl() == TClinginfoBase->GetDecl()) {
8762 return TClinginfo->
GetBaseOffset(TClinginfoBase, address, isDerivedObject);
8778 return (ClassInfo_t *)TClinginfo->
GetBase();
8786 return TClinginfo->
Tagnum();
8794 TTHREAD_TLS_DECL(std::string,output);
8796 return output.c_str();
8804 return TClinginfo->
Name();
8849 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
8850 const clang::ValueDecl* vd = llvm::dyn_cast_or_null<clang::ValueDecl>(decl);
8883 return TClinginfo->
Next();
8891 return TClinginfo->
Offset();
8939 return TClinginfo->
Name();
8947 return TClinginfo->
Title();
8954 TTHREAD_TLS_DECL(std::string,
result);
8957 result = TClinginfo->ValidArrayIndex().str();
8965 Decl* decl =
static_cast<Decl*
>(
const_cast<void*
>(declId));
8966 ASTContext &C = decl->getASTContext();
8967 decl->addAttr(AnnotateAttr::CreateImplicit(C, attribute,
nullptr, 0));
8978 cling::Interpreter &interp,
8981 const clang::TypeDecl* td = llvm::dyn_cast<clang::TypeDecl>(decl->getDeclContext());
8984 clang::QualType qualType = td->getASTContext().getTypeDeclType(td);
8986 unsigned int level = 0;
8989 else if (
name[
cursor] ==
'<' && level) --level;
8990 else if (level == 0 &&
name[
cursor] ==
':') {
9003 const auto *FD = llvm::dyn_cast<clang::FunctionDecl>(decl);
9004 if (
const auto *USD = llvm::dyn_cast<clang::UsingShadowDecl>(decl)) {
9005 FD = llvm::dyn_cast<clang::FunctionDecl>(USD->getTargetDecl());
9008 Error(
"GetFunctionName",
"NULL Decl!");
9015 if (llvm::isa<clang::CXXConstructorDecl>(FD))
9019 }
else if (llvm::isa<clang::CXXDestructorDecl>(decl))
9022 output.insert(output.begin(),
'~');
9024 llvm::raw_string_ostream stream(output);
9025 auto printPolicy = decl->getASTContext().getPrintingPolicy();
9027 printPolicy.AnonymousTagLocations =
false;
9028 FD->getNameForDiagnostic(stream, printPolicy,
false);
9058 return (FuncTempInfo_t*)
const_cast<void*
>(declid);
9069 return (FuncTempInfo_t*)ft_info;
9080 return t_info !=
nullptr;
9089 if (!ft_info)
return 0;
9090 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
9091 return ft->getTemplateParameters()->size();
9100 if (!ft_info)
return 0;
9101 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
9102 return ft->getTemplateParameters()->getMinRequiredArguments();
9110 if (!ft_info)
return 0;
9115 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
9117 switch (ft->getAccess()) {
9118 case clang::AS_public:
9121 case clang::AS_protected:
9124 case clang::AS_private:
9127 case clang::AS_none:
9128 if (ft->getDeclContext()->isNamespace())
9133 assert(
false &&
"Unexpected value for the access property value in Clang");
9137 const clang::FunctionDecl *fd = ft->getTemplatedDecl();
9139 if (fd && fd->getStorageClass() == clang::SC_Static)
9142 if (
const clang::CXXMethodDecl *md =
9143 llvm::dyn_cast<clang::CXXMethodDecl>(fd)) {
9144 if (md->getMethodQualifiers().hasConst()) {
9147 if (md->isVirtual()) {
9150 if (md->isPureVirtual()) {
9153 if (
const clang::CXXConstructorDecl *cd =
9154 llvm::dyn_cast<clang::CXXConstructorDecl>(md)) {
9155 if (cd->isExplicit()) {
9159 else if (
const clang::CXXConversionDecl *cd =
9160 llvm::dyn_cast<clang::CXXConversionDecl>(md)) {
9161 if (cd->isExplicit()) {
9175 if (!ft_info)
return 0;
9180 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
9181 const clang::FunctionDecl *fd = ft->getTemplatedDecl();
9183 if (fd->isOverloadedOperator())
9185 if (llvm::isa<clang::CXXConversionDecl>(fd))
9187 if (llvm::isa<clang::CXXConstructorDecl>(fd))
9189 if (llvm::isa<clang::CXXDestructorDecl>(fd))
9191 if (fd->isInlined())
9202 if (!ft_info)
return;
9203 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
9215 if (!ft_info)
return;
9216 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
9220 if (
const RedeclarableTemplateDecl *AnnotFD
9222 if (AnnotateAttr *A = AnnotFD->getAttr<AnnotateAttr>()) {
9223 output = A->getAnnotation().str();
9227 if (!ft->isFromASTFile()) {
9278 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
9312 return info->
NArg();
9328 return info->
Next();
9355 return (TypeInfo_t*)info->
Type();
9363 TTHREAD_TLS_DECL(
TString, mangled_name);
9365 mangled_name = info->GetMangledName();
9366 return mangled_name;
9384 return info->
Name();
9402 if (info && info->IsValid())
9414 return info->
Title();
9422 return MethodInfo_MethodCallReturnType(func->fInfo);
9424 return EReturnType::kOther;
9433 if (info && info->IsValid()) {
9435 clang::QualType QT( typeinfo->GetQualType().getCanonicalType() );
9436 if (QT->isEnumeralType()) {
9437 return EReturnType::kLong;
9438 }
else if (QT->isPointerType()) {
9440 QT = llvm::cast<clang::PointerType>(QT)->getPointeeType();
9441 if ( QT->isCharType() ) {
9442 return EReturnType::kString;
9444 return EReturnType::kOther;
9446 }
else if ( QT->isFloatingType() ) {
9447 int sz = typeinfo->Size();
9448 if (sz == 4 || sz == 8) {
9450 return EReturnType::kDouble;
9452 return EReturnType::kOther;
9454 }
else if ( QT->isIntegerType() ) {
9455 int sz = typeinfo->Size();
9464 return EReturnType::kLong;
9466 return EReturnType::kOther;
9469 return EReturnType::kOther;
9472 return EReturnType::kOther;
9508 return (MethodArgInfo_t*)
9525 return info->
Next();
9549 return info->
Name();
9573 return (TypeInfo_t*) info->
Type();
9633 return TClinginfo->
Name();
9657 return TClinginfo->
Size();
9715 const char*
name)
const
9735 return TClinginfo->
Next();
9751 return TClinginfo->
Size();
9767 return TClinginfo->
Name();
9775 return TClinginfo->
Title();
9782 clang::QualType QT1 = clang::QualType::getFromOpaquePtr(QualTypePtr1);
9783 clang::QualType QT2 = clang::QualType::getFromOpaquePtr(QualTypePtr2);
9784 return fInterpreter->getCI()->getASTContext().hasSameType(QT1, QT2);
9791 clang::QualType QT = clang::QualType::getFromOpaquePtr(QualTypePtr);
9792 return QT->hasIntegerRepresentation();
9799 clang::QualType QT = clang::QualType::getFromOpaquePtr(QualTypePtr);
9800 return QT->hasSignedIntegerRepresentation();
9807 clang::QualType QT = clang::QualType::getFromOpaquePtr(QualTypePtr);
9808 return QT->hasUnsignedIntegerRepresentation();
9815 clang::QualType QT = clang::QualType::getFromOpaquePtr(QualTypePtr);
9816 return QT->hasFloatingRepresentation();
9823 clang::QualType QT = clang::QualType::getFromOpaquePtr(QualTypePtr);
9824 return QT->hasPointerRepresentation();
9831 clang::QualType QT = clang::QualType::getFromOpaquePtr(QualTypePtr);
9832 return QT->isVoidPointerType();
9841 Error(
"SnapshotMutexState",
"fRecurseCount != 0 even though initial mutex state is unset!");
9857 Error(
"ForgetMutexState",
"mutex state's recurse count already 0!");
9873 std::unique_ptr<MutexStateAndRecurseCountDelta> uniqueP{typedDelta};
9887 Error(
"ApplyToInterpreterMutex",
9888 "After returning from user code that turned on thread safety support, we notice that fInitialMutex is already used ... "
9889 "so the rest of this function/stack execution might have race condition (with the other thread that thinks it has exclusive access to the interpreter state.");
9905 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)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
short Version_t
Class version identifier (short)
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
long long Long64_t
Portable signed long integer 8 bytes.
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
const char Option_t
Option string (const char)
TClass *(* DictFuncPtr_t)()
R__EXTERN TApplication * gApplication
R__EXTERN TClassTable * gClassTable
static bool IsFromRootCling()
static void indent(ostringstream &buf, int indent_level)
The file contains facilities to work with C++ module files extensions used to store rdict files.
void TCling__RestoreInterpreterMutex(void *delta)
Re-apply the lock count delta that TCling__ResetInterpreterMutex() caused.
void TCling__TransactionRollback(const cling::Transaction &T)
static void RegisterPreIncludedHeaders(cling::Interpreter &clingInterp)
static bool hasParsedRootmapForLibrary(llvm::StringRef lib)
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)
int TCling__LoadLibrary(const char *library)
Load a library.
void TCling__DEBUG__dump(clang::DeclContext *DC)
bool TClingLookupHelper__CheckInClassTable(const std::string &tname, std::string &result)
Check if the class name is present in TClassTable.
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)
const char * TCling__GetClassSharedLibs(const char *className, bool skipCore)
static GlobalModuleIndex * loadGlobalModuleIndex(cling::Interpreter &interp)
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.
void TCling__UnlockCompilationDuringUserCodeExecution(void *)
Unlock the interpreter.
static std::string AlternateTuple(const char *classname, const cling::LookupHelper &lh, Bool_t silent)
static bool R__InitStreamerInfoFactory()
Helper to initialize TVirtualStreamerInfo's factor early.
int TCling__AutoParseCallback(const char *className)
clang::RecordDecl * TCling__DEBUG__DCtoRecordDecl(clang::DeclContext *DC)
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)
static bool HaveFullGlobalModuleIndex
bool TCling__TEST_isInvalidDecl(clang::Decl *D)
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()
void TCling__RegisterRdictForLoadPCM(const std::string &pcmFileNameFullPath, llvm::StringRef *pcmContent)
static void TCling__UpdateClassInfo(const NamedDecl *TD)
Update TClingClassInfo for a class (e.g. upon seeing a definition).
clang::DeclContext * TCling__DEBUG__getDeclContext(clang::Decl *D)
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.
void TCling__DEBUG__decl_dump(void *D)
int TCling__AutoLoadCallback(const char *className)
static bool LoadModule(const std::string &ModuleName, cling::Interpreter &interp)
static void RegisterCxxModules(cling::Interpreter &clingInterp)
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....
void TCling__DEBUG__printName(clang::Decl *D)
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)
TInterpreter * CreateInterpreter(void *interpLibHandle, const char *argv[])
static std::string GetClassSharedLibsForModule(const char *cls, cling::LookupHelper &LH, bool skipCore)
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 bool requiresRootMap(const char *rootmapfile)
clang::NamespaceDecl * TCling__DEBUG__DCtoNamespace(clang::DeclContext *DC)
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)
void DestroyInterpreter(TInterpreter *interp)
static bool hasPrecomputedLibraryDeps(llvm::StringRef lib)
void TCling__SplitAclicMode(const char *fileName, string &mode, string &args, string &io, string &fname)
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Int_t gErrorIgnoreLevel
errors with level below this value will be ignored. Default is kUnset.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t property
Option_t Option_t TPoint TPoint const char text
R__EXTERN TVirtualMutex * gInterpreterMutex
#define R__LOCKGUARD_CLING(mutex)
R__EXTERN TInterpreter * gCling
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
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
static Longptr_t ExecuteFile(const char *file, Int_t *error=nullptr, 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.
void RemoveStreamerInfo(Int_t slot)
Remove and delete the StreamerInfo in the given slot.
EState fState
!Current 'state' of the class (Emulated,Interpreted,Loaded)
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 TListOfFunctionTemplates for 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)
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
ClassInfo_t * GetClassInfo() const
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:.
std::atomic< Bool_t > fCanLoadClassInfo
!Indicates whether the ClassInfo is supposed to be available.
std::atomic< Bool_t > fHasRootPcmInfo
!Whether info was loaded from a root pcm.
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
TClingClassInfo * GetBase() const
Emulation of the CINT CallFunc class.
void SetArgs(const char *args)
void SetFunc(const TClingClassInfo *info, const char *method, const char *arglist, Longptr_t *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 IsAutoLoadingForJITSymbols() const
bool IsAutoLoadingEnabled() const
void SetAutoParsingSuspended(bool val=true)
void SetAutoLoadingForJITSymbols(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
size_t GetAlignOf() const
Return the alignment of the class in bytes as reported by clang.
const char * TmpltName() 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
TClingMethodInfo GetMethodWithArgs(const char *fname, const char *arglist, Longptr_t *poffset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch, EInheritanceMode imode=kWithInheritance) 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 IsValidMethod(const char *method, const char *proto, Bool_t objectIsConst, Longptr_t *offset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
bool HasMethod(const char *name) const
void DeleteArray(void *arena, bool dtorOnly, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
void * New(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
TClingMethodInfo GetMethod(const char *fname) const
const clang::ValueDecl * GetDataMember(const char *name) const
int Size() const
Return the size of the class in bytes as reported by clang.
void Destruct(void *arena, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
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
const char * Name() const override
long TypeProperty() const
virtual const char * Name() const
virtual bool IsValid() const
Uses clang::TextDiagnosticPrinter to format diagnostics, which are then passed to a user-specified fu...
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.
const char * TypeName() const
const char * Name() const override
const char * GetPrototype()
long ExtraProperty() const
void * InterfaceMethod() 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
void * QualTypePtr() const
Return the QualType as a void pointer.
bool IsValid() const override
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.
static Int_t DeepAutoLoadImpl(const char *cls, std::unordered_set< std::string > &visited, bool nameIsNormalized)
const char * MethodArgInfo_DefaultValue(MethodArgInfo_t *marginfo) const final
bool ClassInfo_IsScopedEnum(ClassInfo_t *info) const final
const char * TypeInfo_Name(TypeInfo_t *) const final
void * MethodInfo_InterfaceMethod(MethodInfo_t *minfo) const final
void LoadEnums(TListOfEnums &cl) const final
Create list of pointers to enums for TClass cl.
void UpdateListOfGlobals() final
No op: see TClingCallbacks (used to update the list of globals)
bool TypedefInfo_IsValid(TypedefInfo_t *tinfo) const final
Int_t AutoLoad(const char *classname, Bool_t knowDictNotLoaded=kFALSE) final
Load library containing the specified class.
void CallFunc_Init(CallFunc_t *func) const final
void SetGetline(const char *(*getlineFunc)(const char *prompt), void(*histaddFunc)(const char *line)) final
Set a getline function to call when input is needed.
bool LibraryLoadingFailed(const std::string &, const std::string &, bool, bool)
void GenericError(const char *error) const final
Let the interpreter issue a generic error, and set its error state.
std::vector< void * > fRegisterModuleDyLibs
void CallFunc_ExecWithReturn(CallFunc_t *func, void *address, void *ret) const final
bool IsIntegerType(const void *QualTypePtr) const final
TypeInfo_t * MethodInfo_Type(MethodInfo_t *minfo) const final
std::vector< std::string > fAutoLoadLibStorage
void CallFunc_Delete(CallFunc_t *func) const final
int LoadFile(const char *path) const final
Load a source file or library called path into the interpreter.
void ResetAll() final
Reset the Cling state to its initial state.
void SetDeclAttr(DeclId_t, const char *) final
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...
Long_t MethodInfo_Property(MethodInfo_t *minfo) const final
void LoadFunctionTemplates(TClass *cl) const final
Create list of pointers to function templates for TClass cl.
bool ClassInfo_IsValidMethod(ClassInfo_t *info, const char *method, const char *proto, Longptr_t *offset, ROOT::EFunctionMatchMode=ROOT::kConversionMatch) const final
Long_t DataMemberInfo_Property(DataMemberInfo_t *dminfo) const final
int SetClassAutoparsing(int) final
Enable/Disable the Autoparsing of headers.
std::vector< const char * > fCurExecutingMacros
void CreateListOfDataMembers(TClass *cl) const final
Create list of pointers to data members for TClass cl.
void RewindDictionary() final
Rewind Cling dictionary to the point where it was before executing the current macro.
bool ClassInfo_IsValid(ClassInfo_t *info) const final
void UpdateListsOnCommitted(const cling::Transaction &T)
int TypeInfo_RefType(TypeInfo_t *) const final
void CreateListOfBaseClasses(TClass *cl) const final
Create list of pointers to base class(es) for TClass cl.
ClassInfo_t * ClassInfo_Factory(Bool_t all=kTRUE) const final
const char * MethodInfo_Name(MethodInfo_t *minfo) const final
BaseClassInfo_t * BaseClassInfo_Factory(ClassInfo_t *info) const final
Bool_t LoadText(const char *text) const final
Load the declarations from text into the interpreter.
const char * GetSharedLibDeps(const char *lib, bool tryDyld=false) final
Get the list a libraries on which the specified lib depends.
EReturnType MethodInfo_MethodCallReturnType(MethodInfo_t *minfo) const final
TObject * GetObjectAddress(const char *Name, void *&LookupCtx)
If the interpreter encounters Name, check whether that is an object ROOT could retrieve.
Longptr_t ProcessLineAsynch(const char *line, EErrorCode *error=nullptr)
Let cling process a command line asynch.
bool MethodInfo_IsValid(MethodInfo_t *minfo) const final
FuncTempInfo_t * FuncTempInfo_Factory(DeclId_t declid) const final
Construct a FuncTempInfo_t.
TypeInfo_t * TypeInfo_Factory() const final
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.
bool IsSameType(const void *QualTypePtr1, const void *QualTypePtr2) const final
int Evaluate(const char *, TInterpreterValue &) final
Get the interpreter value corresponding to the statement.
std::unique_ptr< TInterpreterValue > MakeInterpreterValue() const final
void UpdateListOfLoadedSharedLibraries()
const char * TypedefInfo_Title(TypedefInfo_t *tinfo) const final
~TCling() final
Destroy the interpreter interface.
void CallFunc_SetFuncProto(CallFunc_t *func, ClassInfo_t *info, const char *method, const char *proto, Longptr_t *Offset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const final
Interface to cling function.
void InitRootmapFile(const char *name)
Create a resource table and read the (possibly) three resource files, i.e.
Int_t AutoParse(const char *cls) final
Parse the headers relative to the class Returns 1 in case of success, 0 in case of failure.
void LoadPCM(std::string pcmFileNameFullPath)
Tries to load a rdict PCM, issues diagnostics if it fails.
void UpdateListOfMethods(TClass *cl) const final
Update the list of pointers to method for TClass cl This is now a nop.
void AddFriendToClass(clang::FunctionDecl *, clang::CXXRecordDecl *) const
Inject function as a friend into klass.
void PrintIntro() final
No-op; see TRint instead.
Bool_t fCxxModulesEnabled
int BaseClassInfo_Next(BaseClassInfo_t *bcinfo) const final
void RefreshClassInfo(TClass *cl, const clang::NamedDecl *def, bool alias)
Internal function. Actually do the update of the ClassInfo when seeing.
CallFunc_t * CallFunc_FactoryCopy(CallFunc_t *func) const final
Double_t CallFunc_ExecDouble(CallFunc_t *func, void *address) const final
std::set< std::string > fAutoLoadedLibraries
void CallFunc_ResetArg(CallFunc_t *func) const final
const char * GetCurrentMacroName() const final
Return the file name of the currently interpreted file, included or not.
Bool_t IsLoaded(const char *filename) const final
Return true if the file has already been loaded by cint.
void SaveGlobalsContext() final
Save the current Cling state of global objects.
void CallFunc_IgnoreExtraArgs(CallFunc_t *func, bool ignore) const final
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.
Int_t GenerateDictionary(const char *classes, const char *includes="", const char *options=nullptr) final
Generate the dictionary for the C++ classes listed in the first argument (in a semi-colon separated l...
Bool_t ClassInfo_Contains(ClassInfo_t *info, DeclId_t declid) const final
Return true if the entity pointed to by 'declid' is declared in the context described by 'info'.
Bool_t IsLibraryLoaded(const char *libname) const final
Long_t GetExecByteCode() const final
This routines used to return the address of the internal wrapper function (of the interpreter) that w...
int DataMemberInfo_ArrayDim(DataMemberInfo_t *dminfo) const final
DataMemberInfo_t * DataMemberInfo_FactoryCopy(DataMemberInfo_t *dminfo) const final
Bool_t HandleNewTransaction(const cling::Transaction &T)
Helper function to increase the internal Cling count of transactions that change the AST.
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...
std::map< SpecialObjectLookupCtx_t, SpecialObjectMap_t > fSpecialObjectMaps
int ClassInfo_Next(ClassInfo_t *info) const final
void SetErrmsgcallback(void *p) const final
Set a callback to receive error messages.
bool MethodArgInfo_IsValid(MethodArgInfo_t *marginfo) const final
int TypeInfo_Size(TypeInfo_t *tinfo) const final
Int_t DeleteGlobal(void *obj) final
Delete obj from Cling symbol table so it cannot be accessed anymore.
int GetSecurityError() const final
Interface to cling function.
void SetTempLevel(int val) const final
Create / close a scope for temporaries.
void Print(Option_t *option="") const final
Print information about the interpreter.
std::set< size_t > fPayloads
UInt_t FuncTempInfo_TemplateNargs(FuncTempInfo_t *) const final
Return the maximum number of template arguments of the function template described by ft_info.
DeclId_t GetFunctionWithPrototype(ClassInfo_t *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) final
Return pointer to cling interface function for a method of a class with a certain prototype,...
TypedefInfo_t * TypedefInfo_Factory() const final
TObjArray * fRootmapFiles
Longptr_t ProcessLine(const char *line, EErrorCode *error=nullptr) final
int ClassInfo_Size(ClassInfo_t *info) const final
const char * MethodArgInfo_TypeName(MethodArgInfo_t *marginfo) const final
cling::Interpreter * GetInterpreterImpl() const
Longptr_t ExecuteMacro(const char *filename, EErrorCode *error=nullptr) final
Execute a cling macro.
std::vector< std::pair< TClass *, DictFuncPtr_t > > fClassesToUpdate
int DataMemberInfo_Next(DataMemberInfo_t *dminfo) const final
const char * TypedefInfo_Name(TypedefInfo_t *tinfo) const final
void BaseClassInfo_Delete(BaseClassInfo_t *bcinfo) const final
Long_t MethodInfo_ExtraProperty(MethodInfo_t *minfo) const final
void LoadMacro(const char *filename, EErrorCode *error=nullptr) final
Load a macro file in cling's memory.
FuncTempInfo_t * FuncTempInfo_FactoryCopy(FuncTempInfo_t *) const final
Construct a FuncTempInfo_t.
int DataMemberInfo_MaxIndex(DataMemberInfo_t *dminfo, Int_t dim) const final
Bool_t FuncTempInfo_IsValid(FuncTempInfo_t *) const final
Check validity of a FuncTempInfo_t.
void AddIncludePath(const char *path) final
Add a directory to the list of directories in which the interpreter looks for include files.
bool ClassInfo_IsBase(ClassInfo_t *info, const char *name) const final
void RecursiveRemove(TObject *obj) final
Delete object from cling symbol table so it can not be used anymore.
const char * DataMemberInfo_TypeName(DataMemberInfo_t *dminfo) const final
DeclId_t GetDataMemberAtAddr(const void *addr) const final
Return pointer to cling DeclId for a data member with a given name.
void CallFunc_SetArgArray(CallFunc_t *func, Longptr_t *paramArr, Int_t nparam) const final
std::string CallFunc_GetWrapperCode(CallFunc_t *func) const final
void * RewindInterpreterMutex()
Reset the interpreter lock to the state it had before interpreter-related calls happened.
const char * MethodArgInfo_Name(MethodArgInfo_t *marginfo) const final
Bool_t HasPCMForLibrary(const char *libname) const final
Return true if ROOT has cxxmodules pcm for a given library name.
void TypedefInfo_Init(TypedefInfo_t *tinfo, const char *name) const final
const char * DataMemberInfo_Title(DataMemberInfo_t *dminfo) const final
Longptr_t CallFunc_ExecInt(CallFunc_t *func, void *address) const final
void ClearStack() final
Delete existing temporary values.
void SetAlloclockfunc(void(*)()) const final
[Place holder for Mutex Lock] Provide the interpreter with a way to acquire a lock used to protect cr...
Bool_t SetErrorMessages(Bool_t enable=kTRUE) final
If error messages are disabled, the interpreter should suppress its failures and warning messages fro...
MethodInfo_t * CallFunc_FactoryMethod(CallFunc_t *func) const final
void RegisterAutoLoadedLibrary(const char *libname) final
Register that a library was autoloaded either to provide a 'missing' symbol or to provide a class (se...
TypedefInfo_t * TypedefInfo_FactoryCopy(TypedefInfo_t *tinfo) const final
void GetFunctionOverloads(ClassInfo_t *cl, const char *funcname, std::vector< DeclId_t > &res) const final
Insert overloads of name in cl to res.
void UnRegisterTClassUpdate(const TClass *oldcl) final
If the dictionary is loaded, we can remove the class from the list (otherwise the class might be load...
std::string MethodArgInfo_TypeNormalizedName(MethodArgInfo_t *marginfo) const final
DeclId_t GetEnum(TClass *cl, const char *name) const final
Return pointer to cling Decl of global/static variable that is located at the address given by addr.
Long_t MethodArgInfo_Property(MethodArgInfo_t *marginfo) const final
int TypedefInfo_Size(TypedefInfo_t *tinfo) const final
void CallFunc_ExecWithArgsAndReturn(CallFunc_t *func, void *address, const void *args[]=nullptr, int nargs=0, void *ret=nullptr) const final
void GetInterpreterTypeName(const char *name, std::string &output, Bool_t full=kFALSE) final
The 'name' is known to the interpreter, this function returns the internal version of this name (usua...
std::map< std::string, llvm::StringRef > fPendingRdicts
static void UpdateClassInfoWork(const char *name)
Int_t Load(const char *filenam, Bool_t system=kFALSE) final
Load a library file in cling's memory.
int TypedefInfo_Next(TypedefInfo_t *tinfo) const final
void * GetInterfaceMethod(TClass *cl, const char *method, const char *params, Bool_t objectIsConst=kFALSE) final
Return pointer to cling interface function for a method of a class with parameters params (params is ...
void TypeInfo_Init(TypeInfo_t *tinfo, const char *funcname) const final
Bool_t SetSuspendAutoParsing(Bool_t value) final
Suspend the Autoparsing of headers.
int DataMemberInfo_TypeSize(DataMemberInfo_t *dminfo) const final
static void * fgSetOfSpecials
const char * ClassInfo_Title(ClassInfo_t *info) const final
const char * DataMemberInfo_Name(DataMemberInfo_t *dminfo) const final
const char * TypeName(const char *typeDesc) final
Return the absolute type of typeDesc.
ROOT::TMetaUtils::TNormalizedCtxt * fNormalizedCtxt
void ForgetMutexState() final
int MethodInfo_Next(MethodInfo_t *minfo) const final
Long_t ClassInfo_ClassProperty(ClassInfo_t *info) const final
void MethodInfo_Delete(MethodInfo_t *minfo) const final
Interface to cling function.
void MethodArgInfo_Delete(MethodArgInfo_t *marginfo) const final
bool IsSignedIntegerType(const void *QualTypePtr) const final
DataMemberInfo_t * DataMemberInfo_Factory(ClassInfo_t *clinfo, TDictionary::EMemberSelection selection) const final
void ClassInfo_Destruct(ClassInfo_t *info, void *arena) const final
TClass * GetClass(const std::type_info &typeinfo, Bool_t load) const final
Demangle the name (from the typeinfo) and then request the class via the usual name based interface (...
Int_t UnloadAllSharedLibraryMaps() final
Unload the library map entries coming from all the loaded shared libraries.
void ClassInfo_Init(ClassInfo_t *info, const char *funcname) const final
std::set< TClass * > & GetModTClasses()
ClassInfo_t * BaseClassInfo_ClassInfo(BaseClassInfo_t *) const final
ECheckClassInfo CheckClassInfo(const char *name, Bool_t autoload, Bool_t isClassOrNamespaceOnly=kFALSE, ClassInfo_t **classInfo=nullptr) final
Checks if an entity with the specified name is defined in Cling.
TClingCallbacks * fClingCallbacks
Long64_t CallFunc_ExecInt64(CallFunc_t *func, void *address) const final
Long_t ClassInfo_Property(ClassInfo_t *info) const final
Longptr_t ClassInfo_GetBaseOffset(ClassInfo_t *fromDerived, ClassInfo_t *toBase, void *address, bool isDerivedObject) const final
void UpdateEnumConstants(TEnum *enumObj, TClass *cl) const final
void ExecuteWithArgsAndReturn(TMethod *method, void *address, const void *args[]=nullptr, int nargs=0, void *ret=nullptr) const final
Bool_t IsErrorMessagesEnabled() const final
If error messages are disabled, the interpreter should suppress its failures and warning messages fro...
int DisplayIncludePath(FILE *fout) const final
Interface to cling function.
void TransactionRollback(const cling::Transaction &T)
Long_t FuncTempInfo_Property(FuncTempInfo_t *) const final
Return the property of the function template.
TEnum * CreateEnum(void *VD, TClass *cl) const final
const char * TypeInfo_TrueName(TypeInfo_t *tinfo) const final
Int_t UnloadLibraryMap(const char *library) final
Unload library map entries coming from the specified library.
void RegisterTemporary(const TInterpreterValue &value)
MutexStateAndRecurseCount fInitialMutex
const char * GetSharedLibs() final
Return the list of shared libraries loaded into the process.
int MethodArgInfo_Next(MethodArgInfo_t *marginfo) const final
void SnapshotMutexState(ROOT::TVirtualRWMutex *mtx) final
Long_t TypeInfo_Property(TypeInfo_t *tinfo) const final
const char * MethodInfo_GetPrototype(MethodInfo_t *minfo) const final
UInt_t FuncTempInfo_TemplateMinReqArgs(FuncTempInfo_t *) const final
Return the number of required template arguments of the function template described by ft_info.
std::vector< cling::Value > * fTemporaries
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) final
Inject the module named "modulename" into cling; load all headers.
static Int_t ShallowAutoLoadImpl(const char *cls)
void MethodInfo_CreateSignature(MethodInfo_t *minfo, TString &signature) const final
Bool_t CheckClassTemplate(const char *name) final
Return true if there is a class template by the given name ...
void LibraryLoaded(const void *dyLibHandle, const char *canonicalName)
void RegisterTClassUpdate(TClass *oldcl, DictFuncPtr_t dict) final
Register classes that already existed prior to their dictionary loading and that already had a ClassI...
bool IsVoidPointerType(const void *QualTypePtr) const final
TObjArray * GetRootMapFiles() const final
bool DataMemberInfo_IsValid(DataMemberInfo_t *dminfo) const final
bool ClassInfo_IsEnum(const char *name) const final
int MethodInfo_NDefaultArg(MethodInfo_t *minfo) const final
bool IsFloatingType(const void *QualTypePtr) const final
void CreateListOfMethods(TClass *cl) const final
Create list of pointers to methods for TClass cl.
Int_t RescanLibraryMap() final
Scan again along the dynamic path for library maps.
std::map< const cling::Transaction *, size_t > fTransactionHeadersMap
void ReportDiagnosticsToErrorHandler(bool enable=true) final
Report diagnostics to the ROOT error handler (see TError.h).
const char * MethodInfo_GetMangledName(MethodInfo_t *minfo) const final
TypeInfo_t * MethodArgInfo_TypeInfo(MethodArgInfo_t *marginfo) const final
Bool_t fHeaderParsingOnDemand
std::hash< std::string > fStringHashFunction
static void RemoveAndInvalidateObject(List &L, Object *O)
void * GetInterfaceMethodWithPrototype(TClass *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) final
Return pointer to cling interface function for a method of a class with a certain prototype,...
void * ClassInfo_New(ClassInfo_t *info) const final
int DisplayClass(FILE *fout, const char *name, int base, int start) const final
void GetFunctionName(const clang::Decl *decl, std::string &name) const
void CreateListOfMethodArgs(TFunction *m) const final
Create list of pointers to method arguments for TMethod m.
const char * GetSTLIncludePath() const final
Return the directory containing CINT's stl cintdlls.
MethodArgInfo_t * MethodArgInfo_FactoryCopy(MethodArgInfo_t *marginfo) const final
Longptr_t BaseClassInfo_Offset(BaseClassInfo_t *toBaseClassInfo, void *address, bool isDerivedObject) const final
void * FindSym(const char *entry) const final
Interface to cling function.
void RegisterLoadedSharedLibrary(const char *name)
Register a new shared library name with the interpreter; add it to fSharedLibs.
void TypeInfo_Delete(TypeInfo_t *tinfo) const final
int MethodInfo_NArg(MethodInfo_t *minfo) const final
DeclId_t GetDataMemberWithValue(const void *ptrvalue) const final
NOT IMPLEMENTED.
std::unordered_set< const clang::NamespaceDecl * > fNSFromRootmaps
EReturnType MethodCallReturnType(TFunction *func) const final
void ProcessClassesToUpdate()
DeclId_t GetFunctionWithValues(ClassInfo_t *cl, const char *method, const char *params, Bool_t objectIsConst=kFALSE) final
Return pointer to cling DeclId for a method of a class with a certain prototype, i....
TString GetMangledName(TClass *cl, const char *method, const char *params, Bool_t objectIsConst=kFALSE) final
Return the cling mangled name for a method of a class with parameters params (params is a string of a...
const char * MethodInfo_Title(MethodInfo_t *minfo) const final
void SetClassInfo(TClass *cl, Bool_t reload=kFALSE, Bool_t silent=kFALSE, ClassInfo_t *classInfo=nullptr) final
Set pointer to the TClingClassInfo in TClass.
const char * BaseClassInfo_TmpltName(BaseClassInfo_t *bcinfo) const final
Bool_t Declare(const char *code) final
Declare code to the interpreter, without any of the interpreter actions that could trigger a re-inter...
const char * BaseClassInfo_FullName(BaseClassInfo_t *bcinfo) const final
void CallFunc_SetArgs(CallFunc_t *func, const char *param) const final
int UnloadFile(const char *path) const final
void CallFunc_Exec(CallFunc_t *func, void *address) const final
Long_t FuncTempInfo_ExtraProperty(FuncTempInfo_t *) const final
Return the property not already defined in Property See TDictionary's EFunctionProperty.
bool CallFunc_IsValid(CallFunc_t *func) const final
const char * BaseClassInfo_Name(BaseClassInfo_t *bcinfo) const final
ROOT::TMetaUtils::TClingLookupHelper * fLookupHelper
const char * DataMemberInfo_ValidArrayIndex(DataMemberInfo_t *dminfo) const final
Int_t GetMore() const final
Return whether we are waiting for more input either because the collected input contains unbalanced b...
Bool_t fIsAutoParsingSuspended
std::string ToString(const char *type, void *obj) final
DeclId_t GetDeclId(const llvm::GlobalValue *gv) const
Return pointer to cling DeclId for a global value.
void Execute(const char *function, const char *params, int *error=nullptr) final
Execute a global function with arguments params.
bool ClassInfo_IsLoaded(ClassInfo_t *info) const final
Longptr_t ClassInfo_Tagnum(ClassInfo_t *info) const final
Long_t BaseClassInfo_Property(BaseClassInfo_t *bcinfo) const final
void CallFunc_SetFunc(CallFunc_t *func, ClassInfo_t *info, const char *method, const char *params, Longptr_t *Offset) const final
std::vector< std::string > GetUsingNamespaces(ClassInfo_t *cl) const final
Get the scopes representing using declarations of namespace.
const char * ClassInfo_FileName(ClassInfo_t *info) const final
void FuncTempInfo_Title(FuncTempInfo_t *, TString &name) const final
Return the comments associates with this function template.
const char * ClassInfo_TmpltName(ClassInfo_t *info) const final
void SaveContext() final
Save the current Cling state.
void LoadPCMImpl(TFile &pcmFile)
Tries to load a PCM from TFile; returns true on success.
Bool_t IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *nsDecl)
void ResetGlobals() final
Reset in Cling the list of global variables to the state saved by the last call to TCling::SaveGlobal...
void CodeComplete(const std::string &, size_t &, std::vector< std::string > &) final
The call to Cling's tab complition.
void ResetGlobalVar(void *obj) final
Reset the Cling 'user' global objects/variables state to the state saved by the last call to TCling::...
const char * MapCppName(const char *) const final
Interface to cling function.
Longptr_t Calc(const char *line, EErrorCode *error=nullptr) final
Directly execute an executable statement (e.g.
Int_t ReloadAllSharedLibraryMaps() final
Reload the library map entries coming from all the loaded shared libraries, after first unloading the...
void UpdateListOfGlobalFunctions() final
No op: see TClingCallbacks (used to update the list of global functions)
void DataMemberInfo_Delete(DataMemberInfo_t *dminfo) const final
const char * GetTopLevelMacroName() const final
Return the file name of the current un-included interpreted file.
void * fPrevLoadedDynLibInfo
void UpdateListOfDataMembers(TClass *cl) const
Update the list of pointers to data members for TClass cl This is now a nop.
void InspectMembers(TMemberInspector &, const void *obj, const TClass *cl, Bool_t isTransient) final
Visit all members over members, recursing over base classes.
Int_t SetClassSharedLibs(const char *cls, const char *libs) final
Register the AutoLoading information for a class.
MethodInfo_t * MethodInfo_FactoryCopy(MethodInfo_t *minfo) const final
std::set< const char * > fParsedPayloadsAddresses
CallFuncIFacePtr_t CallFunc_IFacePtr(CallFunc_t *func) const final
MethodArgInfo_t * MethodArgInfo_Factory() const final
static void UpdateClassInfo(char *name, Long_t tagnum)
No op: see TClingCallbacks.
DeclId_t GetFunction(ClassInfo_t *cl, const char *funcname) final
Return pointer to cling interface function for a method of a class with a certain name.
void ClassInfo_Delete(ClassInfo_t *info) const final
std::unique_ptr< cling::Interpreter > fInterpreter
EDataType ClassInfo_GetUnderlyingType(ClassInfo_t *info) const final
void FuncTempInfo_Delete(FuncTempInfo_t *) const final
Delete the FuncTempInfo_t.
bool IsUnsignedIntegerType(const void *QualTypePtr) const final
DeclId_t GetFunctionTemplate(ClassInfo_t *cl, const char *funcname) final
Return pointer to cling interface function for a method of a class with a certain name.
Int_t DeleteVariable(const char *name) final
Undeclare obj called name.
const char * GetClassSharedLibs(const char *cls, bool skipCore=true) final
Get the list of shared libraries containing the code for class cls.
Longptr_t DataMemberInfo_Offset(DataMemberInfo_t *dminfo) const final
CallFunc_t * CallFunc_Factory() const final
MethodInfo_t * MethodInfo_Factory() const final
Long_t DataMemberInfo_TypeProperty(DataMemberInfo_t *dminfo) const final
void ClearFileBusy() final
Reset the interpreter internal state in case a previous action was not correctly terminated.
cling::MetaProcessor * GetMetaProcessorImpl() const
bool DiagnoseIfInterpreterException(const std::exception &e) const final
void SetAllocunlockfunc(void(*)()) const final
[Place holder for Mutex Unlock] Provide the interpreter with a way to release a lock used to protect ...
std::set< size_t > fLookedUpClasses
bool IsValid() const final
Check if constructor exited correctly, ie the instance is in a valid state.
void AddAvailableIndentifiers(TSeqCollection &Idents) final
void TypedefInfo_Delete(TypedefInfo_t *tinfo) const final
void Reset() final
Pressing Ctrl+C should forward here.
const char * TypedefInfo_TrueName(TypedefInfo_t *tinfo) const final
int SetClassAutoLoading(int) const final
Enable/Disable the AutoLoading of libraries.
const char * ClassInfo_FullName(ClassInfo_t *info) const final
UInt_t AutoParseImplRecurse(const char *cls, bool topLevel)
Helper routine for TCling::AutoParse implementing the actual call to the parser and looping over temp...
const char * MethodInfo_TypeName(MethodInfo_t *minfo) const final
void CallFunc_SetArg(CallFunc_t *func, Long_t param) const final
const char * GetIncludePath() final
Refresh the list of include paths known to the interpreter and return it with -I prepended.
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.
void Initialize() final
Initialize the interpreter, once TROOT::fInterpreter is set.
int ClassInfo_GetMethodNArg(ClassInfo_t *info, const char *method, const char *proto, Bool_t objectIsConst=false, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const final
DeclId_t GetDataMember(ClassInfo_t *cl, const char *name) const final
Return pointer to cling Decl of global/static variable that is located at the address given by addr.
void FuncTempInfo_Name(FuncTempInfo_t *, TString &name) const final
Return the name of this function template.
std::unique_ptr< cling::MetaProcessor > fMetaProcessor
bool TypeInfo_IsValid(TypeInfo_t *tinfo) const final
bool RegisterPrebuiltModulePath(const std::string &FullPath, const std::string &ModuleMapName="module.modulemap") const final
std::string MethodInfo_TypeNormalizedName(MethodInfo_t *minfo) const final
const char * ClassInfo_Name(ClassInfo_t *info) const final
TClass * GenerateTClass(const char *classname, Bool_t emulation, Bool_t silent=kFALSE) final
Generate a TClass for the given class.
ULong64_t fTransactionCount
std::set< std::string > fAutoParseClasses
bool ClassInfo_HasDefaultConstructor(ClassInfo_t *info, Bool_t testio=kFALSE) const final
void EndOfLineAction() final
It calls a "fantom" method to synchronize user keyboard input and ROOT prompt line.
TypeInfo_t * TypeInfo_FactoryCopy(TypeInfo_t *) const final
size_t ClassInfo_AlignOf(ClassInfo_t *info) const final
bool ClassInfo_HasMethod(ClassInfo_t *info, const char *name) const final
void ClassInfo_DeleteArray(ClassInfo_t *info, void *arena, bool dtorOnly) const final
std::map< size_t, std::vector< const char * > > fClassesHeadersMap
const char * DataMemberInfo_TypeTrueName(DataMemberInfo_t *dminfo) const final
void UpdateListOfTypes() final
No op: see TClingCallbacks (used to update the list of types)
void * TypeInfo_QualTypePtr(TypeInfo_t *tinfo) const final
Long_t TypedefInfo_Property(TypedefInfo_t *tinfo) const final
void RegisterRdictForLoadPCM(const std::string &pcmFileNameFullPath, llvm::StringRef *pcmContent)
Register Rdict data for future loading by LoadPCM;.
Longptr_t ProcessLineSynch(const char *line, EErrorCode *error=nullptr) final
Let cling process a command line synchronously, i.e we are waiting it will be finished.
TString GetMangledNameWithPrototype(TClass *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) final
Return the cling mangled name for a method of a class with a certain prototype, i....
static void UpdateAllCanvases()
Update all canvases at end the terminal input command.
Int_t LoadLibraryMap(const char *rootmapfile=nullptr) final
Load map between class and library.
Longptr_t BaseClassInfo_Tagnum(BaseClassInfo_t *bcinfo) const final
void LibraryUnloaded(const void *dyLibHandle, const char *canonicalName)
bool IsPointerType(const void *QualTypePtr) const final
Collection abstract base class.
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.
Basic data type descriptor (datatype information is obtained from CINT).
EMemberSelection
Kinds of members to include in lists.
TDirectory::TContext keeps track and restore the current directory.
The TEnumConstant class implements the constants of the enum type.
The TEnum class implements the enum type.
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
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 void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
Set the value of a resource or create a new resource.
virtual TEnvRec * Lookup(const char *n) const
Loop over all resource records and return the one with name.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
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) override
Remove object from the list.
THashTable implements a hash table to store TObject's.
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 void RegisterAutoLoadedLibrary(const char *libname)=0
virtual Bool_t Declare(const char *code)=0
virtual const char * GetClassSharedLibs(const char *cls, bool skipCore=true)=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...
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...
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TObject * At(Int_t idx) const override
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.
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.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
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 override
Return the number of objects in array (i.e.
TObject * Remove(TObject *obj) override
Remove object from array.
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
void Add(TObject *obj) override
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.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
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.
virtual TClass * IsA() const
@ 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.
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 & GetSharedLibDir()
Get the shared libraries directory in the installation.
Sequenceable collection abstract base class.
Describes a persistent version of a class.
void Clear()
Clear string without changing its capacity.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
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
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual void FreeDirectory(void *dirp)
Free a directory.
virtual void * OpenDirectory(const char *name)
Open a directory.
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 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
const std::string & GetPathSeparator()
const char & GetEnvPathSeparator()
bool ConvertEnvValueToBool(const std::string &value)
R__EXTERN TVirtualRWMutex * gCoreMutex
@ kWarning
Warnings about likely unexpected behavior.
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)
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 *)
RAII used to store Parser, Sema, Preprocessor state for recursive parsing.
std::unique_ptr< ROOT::TVirtualRWMutex::State > fState
State of gCoreMutex when the first interpreter-related function was invoked.
Int_t fRecurseCount
Interpreter-related functions will push the "entry" lock state to *this.
A read-only memory range which we do not control.