63#include "RConfigure.h"
64#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"
144#include <unordered_map>
145#include <unordered_set>
153#define R__DLLEXPORT __attribute__ ((visibility ("default")))
161#include <mach-o/dyld.h>
162#include <mach-o/loader.h>
169#if defined(R__LINUX) || defined(R__FBSD)
176#if defined(__CYGWIN__)
177#include <sys/cygwin.h>
178#define HMODULE void *
180 __declspec(dllimport)
void * __stdcall GetCurrentProcess();
181 __declspec(dllimport)
bool __stdcall EnumProcessModules(
void *,
void **,
unsigned long,
unsigned long *);
182 __declspec(dllimport)
unsigned long __stdcall GetModuleFileNameExW(
void *,
void *,
wchar_t *,
unsigned long);
189# define STDIN_FILENO 0
192# define STDOUT_FILENO 1
195# define STDERR_FILENO 2
205#undef GetModuleFileName
206#define RTLD_DEFAULT ((void *)::GetModuleHandle(NULL))
207#define dlsym(library, function_name) ::GetProcAddress((HMODULE)library, function_name)
208#define dlopen(library_name, flags) ::LoadLibraryA(library_name)
209#define dlclose(library) ::FreeLibrary((HMODULE)library)
210#define R__DLLEXPORT __declspec(dllexport)
218 return D->getDeclContext();
221 return llvm::dyn_cast<clang::NamespaceDecl>(DC);
224 return llvm::dyn_cast<clang::RecordDecl>(DC);
227 return DC->dumpDeclContext();
236 return ((clang::Decl*)D)->dump();
239 if (clang::NamedDecl* ND = llvm::dyn_cast<clang::NamedDecl>(D)) {
242 llvm::raw_string_ostream OS(
name);
243 ND->getNameForDiagnostic(OS, D->getASTContext().getPrintingPolicy(),
246 printf(
"%s\n",
name.c_str());
254 return D->isInvalidDecl();
258 assert(info && info->
IsValid());
259 return info->
GetDecl()->isInvalidDecl();
262using std::string, std::vector;
263using namespace clang;
267 static const std::string gInterpreterClassDef = R
"ICF(
269#define ClassDef(name, id) \
270_ClassDefInterp_(name,id,virtual,) \
271static int DeclFileLine() { return __LINE__; }
273#define ClassDefNV(name, id) \
274_ClassDefInterp_(name,id,,) \
275static int DeclFileLine() { return __LINE__; }
276#undef ClassDefOverride
277#define ClassDefOverride(name, id) \
278_ClassDefInterp_(name,id,,override) \
279static int DeclFileLine() { return __LINE__; }
282 static const std::string gNonInterpreterClassDef = R
"ICF(
283#define __ROOTCLING__ 1
285#define ClassDef(name,id) \
286_ClassDefOutline_(name,id,virtual,) \
287static int DeclFileLine() { return __LINE__; }
289#define ClassDefNV(name, id)\
290_ClassDefOutline_(name,id,,)\
291static int DeclFileLine() { return __LINE__; }
292#undef ClassDefOverride
293#define ClassDefOverride(name, id)\
294_ClassDefOutline_(name,id,,override)\
295static int DeclFileLine() { return __LINE__; }
299 static const std::string gClassDefInterpMacro = R
"ICF(
302#define _ClassDefInterp_(name,id,virtual_keyword, overrd) \
305 static TClass *Class() { static TClass* sIsA = 0; if (!sIsA) sIsA = TClass::GetClass(#name); return sIsA; } \
306 static const char *Class_Name() { return #name; } \
307 virtual_keyword Bool_t CheckTObjectHashConsistency() const overrd { \
308 static std::atomic<UChar_t> recurseBlocker(0); \
309 if (R__likely(recurseBlocker >= 2)) { \
310 return ::ROOT::Internal::THashConsistencyHolder<decltype(*this)>::fgHashConsistency; \
311 } else if (recurseBlocker == 1) { \
313 } else if (recurseBlocker++ == 0) { \
314 ::ROOT::Internal::THashConsistencyHolder<decltype(*this)>::fgHashConsistency = \
315 ::ROOT::Internal::HasConsistentHashMember(_QUOTE_(name)) || \
316 ::ROOT::Internal::HasConsistentHashMember(*IsA()); \
318 return ::ROOT::Internal::THashConsistencyHolder<decltype(*this)>::fgHashConsistency; \
320 return false; /* unreachable */ \
322 static Version_t Class_Version() { return id; } \
323 static TClass *Dictionary() { return 0; } \
324 virtual_keyword TClass *IsA() const overrd { return name::Class(); } \
325 virtual_keyword void ShowMembers(TMemberInspector&insp) const overrd { ::ROOT::Class_ShowMembers(name::Class(), this, insp); } \
326 virtual_keyword void Streamer(TBuffer&) overrd { ::Error("Streamer", "Cannot stream interpreted class."); } \
327 void StreamerNVirtual(TBuffer&ClassDef_StreamerNVirtual_b) { name::Streamer(ClassDef_StreamerNVirtual_b); } \
328 static const char *DeclFileName() { return __FILE__; } \
329 static int ImplFileLine() { return 0; } \
330 static const char *ImplFileName() { return __FILE__; }
351 gCling->RegisterAutoLoadedLibrary(library);
352 return gSystem->Load(library,
"",
false);
370 return ((
TCling*)
gCling)->LibraryLoadingFailed(errmessage, libStem, permanent, resolved);
409 static vector<const NamedDecl*> updateList;
412 if (entered) topLevel =
kFALSE;
427 updateList.push_back(TD);
430 while (!updateList.empty()) {
432 updateList.pop_back();
439 const clang::Decl* D =
static_cast<const clang::Decl*
>(enumObj->
GetDeclId());
440 if(
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(D)) {
442 for (EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(),
443 EDE = ED->enumerator_end(); EDI != EDE; ++EDI) {
445 std::string constbuf;
446 if (
const NamedDecl* END = llvm::dyn_cast<NamedDecl>(*EDI)) {
447 PrintingPolicy Policy((*EDI)->getASTContext().getPrintingPolicy());
448 llvm::raw_string_ostream stream(constbuf);
450 Policy.AnonymousTagLocations =
false;
451 (END)->getNameForDiagnostic(stream, Policy,
false);
453 const char* constantName = constbuf.c_str();
457 const llvm::APSInt valAPSInt = (*EDI)->getInitVal();
458 if (valAPSInt.isSigned()) {
459 value = valAPSInt.getSExtValue();
461 value = valAPSInt.getZExtValue();
468 DataMemberInfo_t* dmInfo = (DataMemberInfo_t*) tcDmInfo;
472 enumConstant =
new TEnumConstant(dmInfo, constantName, value, enumObj);
479 globals->
Add(enumConstant);
491 TEnum* enumType =
nullptr;
492 const clang::Decl* D =
static_cast<const clang::Decl*
>(VD);
494 if (
const EnumDecl* ED = llvm::dyn_cast<EnumDecl>(D)) {
496 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
497 llvm::raw_string_ostream stream(buf);
499 Policy.AnonymousTagLocations =
false;
500 ED->getNameForDiagnostic(stream, Policy,
false);
506 const char*
name = buf.c_str();
517 const clang::Decl* D =
static_cast<const clang::Decl*
>(DV);
519 if (!D->isCanonicalDecl() && !isa<clang::NamespaceDecl>(D)
520 && !dyn_cast<clang::RecordDecl>(D))
return;
522 if (isa<clang::FunctionDecl>(D->getDeclContext())
523 || isa<clang::TagDecl>(D->getDeclContext()))
527 if (
const clang::CXXRecordDecl* RD = dyn_cast<clang::CXXRecordDecl>(D)) {
528 if (RD->getDescribedClassTemplate())
530 }
else if (
const clang::FunctionDecl* FD = dyn_cast<clang::FunctionDecl>(D)) {
531 if (FD->getDescribedFunctionTemplate())
535 if (
const RecordDecl *TD = dyn_cast<RecordDecl>(D)) {
536 if (TD->isCanonicalDecl() || TD->isThisDeclarationADefinition())
539 else if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
541 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
545 }
else if (
const NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(D)) {
550 if (!isa<TranslationUnitDecl>(ND->getDeclContext()))
554 if (isa<EnumDecl>(ND))
559 if (!(isa<VarDecl>(ND)))
563 if (
gROOT->GetListOfGlobals()->FindObject(ND->getNameAsString().c_str()))
567 gROOT->GetListOfGlobals()->Add(
new TGlobal((DataMemberInfo_t *)
569 cast<ValueDecl>(ND),
nullptr)));
601 const char* canonicalName) {
602 ((
TCling*)
gCling)->LibraryLoaded(dyLibHandle, canonicalName);
607 ((
TCling *)
gCling)->RegisterRdictForLoadPCM(pcmFileNameFullPath, pcmContent);
611 const char* canonicalName) {
612 ((
TCling*)
gCling)->LibraryUnloaded(dyLibHandle, canonicalName);
618 return ((
TCling*)
gCling)->GetObjectAddress(Name, LookupCtx);
628 auto tcling =
new TCling(
"C++",
"cling C++ Interpreter", argv, interpLibHandle);
652 return ((
TCling*)
gCling)->GetClassSharedLibs(className, skipCore);
658 return ((
TCling*)
gCling)->IsAutoLoadNamespaceCandidate(nsDecl);
663 string file(fileName);
665 return gSystem->CompileMacro(file.c_str(), opt.c_str());
669 string &args,
string &io,
string &fname)
671 string file(fileName);
672 TString f, amode, arguments, aclicio;
673 f =
gSystem->SplitAclicMode(file.c_str(), amode, arguments, aclicio);
674 mode = amode.
Data(); args = arguments.
Data();
675 io = aclicio.
Data(); fname =
f.Data();
685 char *__unDName(
char *demangled,
const char *mangled,
int out_len,
686 void * (* pAlloc )(
size_t),
void (* pFree )(
void *),
687 unsigned short int flags);
699 using namespace clang;
700 if (NamespaceDecl* nsd = llvm::dyn_cast<NamespaceDecl>(decl)){
704 if (ClassTemplateDecl* ctd = llvm::dyn_cast<ClassTemplateDecl>(decl)){
717 const std::vector<std::string> &headers,
718 const std::vector<std::string> &fwdDecls,
719 const std::vector<std::string> &unknown)
725 if (classes.empty()) {
729 const std::string& className = classes[0];
731 TString fileName =
"AutoDict_";
732 std::string::const_iterator sIt;
733 for (sIt = className.begin(); sIt != className.end(); ++sIt) {
734 if (*sIt ==
'<' || *sIt ==
'>' ||
735 *sIt ==
' ' || *sIt ==
'*' ||
736 *sIt ==
',' || *sIt ==
'&' ||
744 if (classes.size() > 1) {
746 std::vector<std::string>::const_iterator it = classes.begin();
747 while ((++it) != classes.end()) {
748 for (
UInt_t cursor = 0; cursor != it->length(); ++cursor) {
749 chk = chk * 3 + it->at(cursor);
755 if (
gSystem->AccessPathName(fileName) != 0) {
762 static const std::set<std::string> sSTLTypes {
763 "vector",
"list",
"forward_list",
"deque",
"map",
"unordered_map",
"multimap",
764 "unordered_multimap",
"set",
"unordered_set",
"multiset",
"unordered_multiset",
765 "queue",
"priority_queue",
"stack",
"iterator"};
766 std::vector<std::string>::const_iterator it;
767 std::string fileContent(
"");
768 for (it = headers.begin(); it != headers.end(); ++it) {
769 fileContent +=
"#include \"" + *it +
"\"\n";
771 for (it = unknown.begin(); it != unknown.end(); ++it) {
777 while (dirbase.
Length() && dirbase !=
"."
778 && dirbase !=
"include" && dirbase !=
"inc"
779 && dirbase !=
"prec_stl") {
780 gSystem->PrependPathName(dirbase, header);
781 dir =
gSystem->GetDirName(dir);
783 fileContent +=
TString(
"#include \"") + header +
"\"\n";
786 for (it = fwdDecls.begin(); it != fwdDecls.end(); ++it) {
787 fileContent +=
"class " + *it +
";\n";
789 fileContent +=
"#ifdef __CLING__ \n";
790 fileContent +=
"#pragma link C++ nestedclasses;\n";
791 fileContent +=
"#pragma link C++ nestedtypedefs;\n";
792 for (it = classes.begin(); it != classes.end(); ++it) {
794 size_t posTemplate =
n.find(
'<');
795 std::set<std::string>::const_iterator iSTLType = sSTLTypes.end();
796 if (posTemplate != std::string::npos) {
797 n.erase(posTemplate, std::string::npos);
798 if (
n.compare(0, 5,
"std::") == 0) {
801 iSTLType = sSTLTypes.find(
n);
803 fileContent +=
"#pragma link C++ class ";
804 fileContent += *it +
"+;\n" ;
805 if (iSTLType == sSTLTypes.end()) {
808 fileContent +=
"#pragma link C++ class " + *it +
"::*+;\n" ;
811 fileContent +=
"#endif\n";
815 filePointer = fopen(fileName,
"w");
816 if (filePointer ==
nullptr) {
822 fprintf(filePointer,
"%s", fileContent.c_str());
838 const std::vector<std::string> &headers,
839 const std::vector<std::string> &fwdDecls,
840 const std::vector<std::string> &unknown)
846 std::vector<std::string> classes;
847 classes.push_back(className);
875 void exceptionErrorHandler(
void * ,
878 throw std::runtime_error(std::string(
">>> Interpreter compilation error:\n") + reason);
892 class clangDiagSuppr {
894 clangDiagSuppr(clang::DiagnosticsEngine& diag): fDiagEngine(diag){
895 fOldDiagValue = fDiagEngine.getIgnoreAllWarnings();
896 fDiagEngine.setIgnoreAllWarnings(
true);
900 fDiagEngine.setIgnoreAllWarnings(fOldDiagValue);
903 clang::DiagnosticsEngine& fDiagEngine;
913 return gCling->AutoParse(cname);
925 unsigned long offset = 0;
926 if (strncmp(tname.c_str(),
"const ", 6) == 0) {
929 unsigned long end = tname.length();
930 while( end && (tname[end-1]==
'&' || tname[end-1]==
'*' || tname[end-1]==
']') ) {
931 if ( tname[end-1]==
']' ) {
933 while ( end && tname[end-1]!=
'[' ) --end;
937 std::string innerbuf;
939 if (end != tname.length()) {
940 innerbuf = tname.substr(offset,end-offset);
941 inner = innerbuf.c_str();
943 inner = tname.c_str()+offset;
947 if (
gROOT->GetListOfClasses()->FindObject(inner)
957 const char *newname =
type->GetFullTypeName();
959 newname =
"Long64_t";
961 newname =
"ULong64_t";
963 if (strcmp(inner,newname) == 0) {
966 if (offset) result =
"const ";
968 if ( end != tname.length() ) {
969 result += tname.substr(end,tname.length()-end);
971 if (result == tname) result.clear();
977 if (lastPos != inner)
980 const auto enName = lastPos;
981 const auto scopeNameSize = (lastPos - inner) /
sizeof(
decltype(*lastPos)) - 2;
982 std::string scopeName{inner, scopeNameSize};
984 if (
auto scope =
static_cast<TClass *
>(
gROOT->GetListOfClasses()->FindObject(scopeName.c_str()))) {
985 auto enumTable =
dynamic_cast<const THashList *
>(scope->GetListOfEnums(
false));
986 if (enumTable && enumTable->THashList::FindObject(enName))
991 auto listOfEnums = scope->GetListOfEnums();
993 auto enumTable =
dynamic_cast<const THashList *
>(listOfEnums);
994 if (enumTable && enumTable->THashList::FindObject(enName))
1001 auto enumTable =
dynamic_cast<const THashList *
>(
gROOT->GetListOfEnums());
1002 if (enumTable && enumTable->THashList::FindObject(inner))
return true;
1005 if (
gCling->GetClassSharedLibs(inner))
1065static bool LoadModule(
const std::string &ModuleName, cling::Interpreter &interp)
1074 std::string currentDir =
gSystem->WorkingDirectory();
1075 assert(!currentDir.empty());
1076 gCling->RegisterPrebuiltModulePath(currentDir);
1078 ::Info(
"TCling::__LoadModule",
"Preloading module %s. \n",
1079 ModuleName.c_str());
1081 return interp.loadModule(ModuleName,
true);
1087static void LoadModules(
const std::vector<std::string> &modules, cling::Interpreter &interp)
1089 for (
const auto &modName : modules)
1095 const static bool foundSymbol = dlsym(RTLD_DEFAULT,
"usedToIdentifyRootClingByDlSym");
1100static bool HasASTFileOnDisk(clang::Module *M,
const clang::Preprocessor &PP, std::string *FullFileName =
nullptr)
1102 const HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
1104 std::string ModuleFileName;
1105 if (!HSOpts.PrebuiltModulePaths.empty())
1107 ModuleFileName = PP.getHeaderSearchInfo().getPrebuiltModuleFileName(M->Name);
1109 *FullFileName = ModuleFileName;
1111 return !ModuleFileName.empty();
1117 CompilerInstance &CI = *interp.getCI();
1118 Preprocessor &PP = CI.getPreprocessor();
1119 auto ModuleManager = CI.getASTReader();
1120 assert(ModuleManager);
1125 if (ModuleIndexPath.empty())
1128 ModuleManager->resetForReload();
1129 ModuleManager->loadGlobalIndex();
1130 GlobalModuleIndex *GlobalIndex = ModuleManager->getGlobalIndex();
1135 ModuleMap &MMap = PP.getHeaderSearchInfo().getModuleMap();
1136 bool RecreateIndex =
false;
1137 for (ModuleMap::module_iterator
I = MMap.module_begin(), E = MMap.module_end();
I != E; ++
I) {
1138 Module *TheModule =
I->second;
1143 RecreateIndex =
true;
1145 if (RecreateIndex) {
1146 cling::Interpreter::PushTransactionRAII deserRAII(&interp);
1147 clang::GlobalModuleIndex::UserDefinedInterestingIDs IDs;
1149 struct DefinitionFinder :
public RecursiveASTVisitor<DefinitionFinder> {
1150 DefinitionFinder(clang::GlobalModuleIndex::UserDefinedInterestingIDs& IDs,
1151 clang::TranslationUnitDecl* TU) : DefinitionIDs(IDs) {
1154 bool VisitNamedDecl(NamedDecl *ND) {
1155 if (!ND->isFromASTFile())
1157 if (!ND->getIdentifier())
1160 if (ND->getAccess() == AS_protected || ND->getAccess() == AS_private)
1163 if (TagDecl *TD = llvm::dyn_cast<TagDecl>(ND)) {
1164 if (TD->isCompleteDefinition())
1166 }
else if (NamespaceDecl *NSD = llvm::dyn_cast<NamespaceDecl>(ND)) {
1167 Register(NSD,
false);
1169 else if (TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(ND))
1175 clang::GlobalModuleIndex::UserDefinedInterestingIDs &DefinitionIDs;
1176 void Register(
const NamedDecl* ND,
bool AddSingleEntry =
true) {
1177 assert(ND->isFromASTFile());
1180 if (!ND->hasOwningModule()) {
1182 SourceManager &SM = ND->getASTContext().getSourceManager();
1183 SourceLocation Loc = ND->getLocation();
1184 OptionalFileEntryRef FE = SM.getFileEntryRefForID(SM.getFileID(Loc));
1186 assert(FE->getName().contains(
"input_line_"));
1191 Module *OwningModule = ND->getOwningModule()->getTopLevelModule();
1192 assert(OwningModule);
1193 assert(!ND->getName().empty() &&
"Empty name");
1194 if (AddSingleEntry && DefinitionIDs.count(ND->getName()))
1200 DefinitionIDs[ND->getName()].push_back(OwningModule->getASTFile());
1203 DefinitionFinder defFinder(IDs, CI.getASTContext().getTranslationUnitDecl());
1205 llvm::cantFail(GlobalModuleIndex::writeIndex(CI.getFileManager(),
1206 CI.getPCHContainerReader(),
1209 ModuleManager->resetForReload();
1210 ModuleManager->loadGlobalIndex();
1211 GlobalIndex = ModuleManager->getGlobalIndex();
1220 if (!clingInterp.getCI()->getLangOpts().Modules)
1224 cling::Interpreter::PushTransactionRAII deserRAII(&clingInterp);
1242 LoadModule(
"_Builtin_intrinsics", clingInterp);
1246 std::vector<std::string> CoreModules = {
"ROOT_Foundation_C",
1249 "ROOT_Foundation_Stage1_NoRTTI",
1258 std::vector<std::string> CommonModules = {
"MathCore"};
1264 std::vector<std::string> FIXMEModules = {
"Hist"};
1265 clang::CompilerInstance &CI = *clingInterp.getCI();
1266 clang::Preprocessor &PP = CI.getPreprocessor();
1267 ModuleMap &MMap = PP.getHeaderSearchInfo().getModuleMap();
1268 if (MMap.findModule(
"RInterface"))
1269 FIXMEModules.push_back(
"RInterface");
1273 GlobalModuleIndex *GlobalIndex =
nullptr;
1277 GlobalIndex = CI.getASTReader()->getGlobalIndex();
1279 llvm::StringSet<> KnownModuleFileNames;
1281 GlobalIndex->getKnownModuleFileNames(KnownModuleFileNames);
1283 std::vector<std::string> PendingModules;
1284 PendingModules.reserve(256);
1285 for (
auto I = MMap.module_begin(), E = MMap.module_end();
I != E; ++
I) {
1286 clang::Module *M =
I->second;
1290 std::string FullASTFilePath;
1294 if (GlobalIndex && KnownModuleFileNames.count(FullASTFilePath))
1297 if (M->IsUnimportable)
1305 if (std::find(CoreModules.begin(), CoreModules.end(), M->Name) != CoreModules.end())
1313 PendingModules.push_back(M->Name);
1320 assert(clingInterp.getMacro(
"gROOT") &&
"Couldn't load gROOT macro?");
1324 clingInterp.declare(R
"CODE(
1336 std::string PreIncludes;
1337 bool hasCxxModules = clingInterp.getCI()->getLangOpts().Modules;
1343 PreIncludes +=
"#include \"RtypesCore.h\"\n";
1346 PreIncludes +=
"#include \"Rtypes.h\"\n";
1348 PreIncludes += gClassDefInterpMacro +
"\n"
1349 + gInterpreterClassDef +
"\n"
1351 "#define ClassImp(X);\n";
1354 PreIncludes +=
"#include <string>\n";
1359 PreIncludes +=
"#include <cassert>\n";
1361 PreIncludes +=
"using namespace std;\n";
1362 clingInterp.declare(PreIncludes);
1373TCling::TCling(
const char *
name,
const char *title,
const char*
const argv[],
void *interpLibHandle)
1383#ifdef R__USE_CXXMODULES
1387 llvm::install_fatal_error_handler(&exceptionErrorHandler);
1391 std::vector<std::string> clingArgsStorage;
1392 clingArgsStorage.push_back(
"cling4root");
1393 for (
const char*
const* arg = argv; *arg; ++arg)
1394 clingArgsStorage.push_back(*arg);
1397 if (!fromRootCling) {
1402 clingArgsStorage.push_back(
"-I" + interpInclude);
1405 clingArgsStorage.push_back(
"-I" + interpInclude +
"/cling");
1408 clingArgsStorage.push_back(
"-I" + interpInclude +
"/cling/plugins/include");
1419 std::string pchFilename = interpInclude +
"/allDict.cxx.pch";
1420 if (
gSystem->Getenv(
"ROOT_PCH")) {
1421 pchFilename =
gSystem->Getenv(
"ROOT_PCH");
1424 clingArgsStorage.push_back(
"-include-pch");
1425 clingArgsStorage.push_back(pchFilename);
1428 clingArgsStorage.push_back(
"-Wno-undefined-inline");
1429 clingArgsStorage.push_back(
"-fsigned-char");
1430 clingArgsStorage.push_back(
"-fsized-deallocation");
1435 clingArgsStorage.push_back(
"-O1");
1438 clingArgsStorage.push_back(
"-mllvm");
1439 clingArgsStorage.push_back(
"-optimize-regalloc=0");
1442#ifdef CLING_WITH_ADAPTIVECPP
1445 clingArgsStorage.push_back(
"-isystem");
1446 clingArgsStorage.push_back(acppInclude);
1447 clingArgsStorage.push_back(
"-mllvm");
1448 clingArgsStorage.push_back(
"-acpp-sscp");
1453 std::optional<std::string> EnvOpt = llvm::sys::Process::GetEnv(
"EXTRA_CLING_ARGS");
1454 if (EnvOpt.has_value()) {
1455 StringRef Env(*EnvOpt);
1456 while (!Env.empty()) {
1458 std::tie(Arg, Env) = Env.split(
' ');
1459 clingArgsStorage.push_back(Arg.str());
1463 auto GetEnvVarPath = [](
const std::string &EnvVar, std::vector<std::string> &Paths) {
1464 std::optional<std::string> EnvOpt = llvm::sys::Process::GetEnv(EnvVar);
1465 if (EnvOpt.has_value()) {
1466 StringRef Env(*EnvOpt);
1467 while (!Env.empty()) {
1470 if (std::find(Paths.begin(), Paths.end(), Arg.str()) == Paths.end())
1471 Paths.push_back(Arg.str());
1477 std::vector<std::string> Paths;
1482 GetEnvVarPath(
"CLING_PREBUILT_MODULE_PATH", Paths);
1483 std::string EnvVarPath;
1484 for (
const std::string& P : Paths)
1487 gSystem->Setenv(
"CLING_PREBUILT_MODULE_PATH", EnvVarPath.c_str());
1491 EnvOpt = llvm::sys::Process::GetEnv(
"ROOT_CLING_TIMING");
1492 if (EnvOpt.has_value())
1493 clingArgsStorage.push_back(
"-ftime-report");
1500 std::vector<std::string> ModuleMaps;
1503 GetEnvVarPath(
"CLING_MODULEMAP_FILES", ModuleMaps);
1505 std::string cwd =
gSystem->WorkingDirectory();
1507 if (llvm::sys::fs::exists(cwd + ModuleMapSuffix))
1508 ModuleMaps.push_back(cwd + ModuleMapSuffix);
1510 for (
const std::string& M : ModuleMaps)
1511 clingArgsStorage.push_back(
"-fmodule-map-file=" + M);
1513 std::string ModulesCachePath;
1514 EnvOpt = llvm::sys::Process::GetEnv(
"CLING_MODULES_CACHE_PATH");
1515 if (EnvOpt.has_value()){
1516 StringRef Env(*EnvOpt);
1517 assert(llvm::sys::fs::exists(Env) &&
"Path does not exist!");
1518 ModulesCachePath = Env.str();
1523 clingArgsStorage.push_back(
"-fmodules-cache-path=" + ModulesCachePath);
1526 std::vector<const char*> interpArgs;
1527 for (std::vector<std::string>::const_iterator iArg = clingArgsStorage.begin(),
1528 eArg = clingArgsStorage.end(); iArg != eArg; ++iArg)
1529 interpArgs.push_back(iArg->c_str());
1536 if (!fromRootCling) {
1538 interpArgs.push_back(
"-fmodules");
1539 interpArgs.push_back(
"-fno-implicit-module-maps");
1543 interpArgs.push_back(
"-Rmodule-build");
1549 interpArgs.push_back(
"-fno-autolink");
1554 interpArgs.push_back(
"-ffast-math");
1560 extraArgs && *extraArgs; ++extraArgs) {
1561 if (!strcmp(*extraArgs,
"-resource-dir")) {
1563 llvmResourceDir = *(++extraArgs);
1565 interpArgs.push_back(*extraArgs);
1569 std::vector<std::string> _empty;
1571 for (
const auto &arg: args)
1572 interpArgs.emplace_back(arg.c_str());
1575 cling::Interpreter::ModuleFileExtensions extensions;
1576 EnvOpt = llvm::sys::Process::GetEnv(
"ROOTDEBUG_RDICT");
1577 if (!EnvOpt.has_value())
1578 extensions.push_back(std::make_shared<TClingRdictModuleFileExtension>());
1580 fInterpreter = std::make_unique<cling::Interpreter>(interpArgs.size(),
1582 llvmResourceDir, extensions,
1591 Cpp::UseExternalInterpreter((Cpp::TInterp_t*)
fInterpreter.get());
1594 fInterpreter->getCI()->getPreprocessorOpts().DisablePCHOrModuleValidation =
1595 DisableValidationForModuleKind::All;
1599 fInterpreter->getCI()->getLangOpts().SpellChecking =
false;
1602 auto isModulesArg = [](
const char* arg) {
return !strcmp(arg,
"-fmodules"); };
1603 bool hasModulesArg = std::find_if(interpArgs.begin(), interpArgs.end(), isModulesArg) != interpArgs.end();
1604 fInterpreter->getCI()->getLangOpts().Modules = hasModulesArg;
1609 static llvm::raw_fd_ostream fMPOuts (STDOUT_FILENO,
false);
1628 if (!fromRootCling) {
1633 fInterpreter->getRuntimeOptions().AllowRedefinition = 1;
1634 auto &Policy =
const_cast<clang::PrintingPolicy &
>(
fInterpreter->getCI()->getASTContext().getPrintingPolicy());
1638 Policy.SplitTemplateClosers =
true;
1640 Policy.SuppressDefaultTemplateArgs =
false;
1646 std::unique_ptr<TClingCallbacks>
1652 if (!fromRootCling) {
1653 cling::DynamicLibraryManager& DLM = *
fInterpreter->getDynamicLibraryManager();
1658 auto ShouldPermanentlyIgnore = [](llvm::StringRef FileName) ->
bool{
1659 llvm::StringRef stem = llvm::sys::path::stem(FileName);
1660 return stem.starts_with(
"libNew") || stem.starts_with(
"libcppyy_backend");
1663 DLM.initializeDyld(ShouldPermanentlyIgnore);
1722 auto setFactory = []() {
1726 static bool doneFactory = setFactory();
1738 if (llvm::sys::fs::exists(pcmFileNameFullPath)) {
1739 ::Error(
"TCling::RegisterRdictForLoadPCM",
"Rdict '%s' is both in Module extension and in File system.", pcmFileNameFullPath.c_str());
1757 if (listOfKeys && ((listOfKeys->GetSize() == 0) ||
1758 ((listOfKeys->GetSize() == 1) &&
1759 !strcmp(((
TKey *)listOfKeys->At(0))->GetName(),
"EMPTY")
1764 TObjArray *protoClasses;
1766 ::Info(
"TCling::LoadPCMImpl",
"reading protoclasses for %s \n", pcmFile.
GetName());
1772 auto listOfGlobals =
gROOT->GetListOfGlobals();
1773 auto listOfEnums =
dynamic_cast<THashList *
>(
gROOT->GetListOfEnums());
1775 for (
auto selEnum : *enums) {
1776 const char *enumScope = selEnum->GetTitle();
1777 const char *enumName = selEnum->GetName();
1778 if (strcmp(enumScope,
"") == 0) {
1781 if (!listOfEnums->THashList::FindObject(enumName)) {
1782 ((TEnum *)selEnum)->SetClass(
nullptr);
1783 listOfEnums->Add(selEnum);
1785 for (
auto enumConstant : *
static_cast<TEnum *
>(selEnum)->GetConstants()) {
1786 if (!listOfGlobals->FindObject(enumConstant)) {
1787 listOfGlobals->Add(enumConstant);
1794 if (!nsTClassEntry) {
1797 auto listOfEnums = nsTClassEntry->
fEnums.load();
1802 listOfEnums = nsTClassEntry->
fEnums =
new TListOfEnums(nsTClassEntry);
1805 listOfEnums = nsTClassEntry->
fEnums =
new TListOfEnumsWithLock(nsTClassEntry);
1808 if (listOfEnums && !listOfEnums->THashList::FindObject(enumName)) {
1809 ((TEnum *)selEnum)->SetClass(nsTClassEntry);
1810 listOfEnums->Add(selEnum);
1818 pcmFile.
GetObject(
"__ProtoClasses", protoClasses);
1821 for (
auto obj : *protoClasses) {
1822 TProtoClass *
proto = (TProtoClass *)obj;
1831 for (
auto proto : *protoClasses) {
1832 if (TClass *existingCl = (TClass *)
gROOT->GetListOfClasses()->FindObject(
proto->GetName())) {
1839 ::Error(
"TCling::LoadPCM",
"Inconsistent TClassTable for %s",
proto->GetName());
1842 TClass *ncl = (*dict)();
1850 protoClasses->Clear();
1851 delete protoClasses;
1854 TObjArray *dataTypes;
1855 pcmFile.
GetObject(
"__Typedefs", dataTypes);
1857 for (
auto typedf : *dataTypes)
1858 gROOT->GetListOfTypes()->Add(typedf);
1872 assert(!pcmFileNameFullPath.empty());
1873 assert(llvm::sys::path::is_absolute(pcmFileNameFullPath));
1876 TString pcmFileName = pcmFileNameFullPath;
1884 llvm::SaveAndRestore<Int_t> SaveGDebug(
gDebug);
1887 ::Info(
"TCling::LoadPCM",
"Loading ROOT PCM %s", pcmFileName.
Data());
1892 if (llvm::sys::fs::is_symlink_file(pcmFileNameFullPath))
1897 llvm::StringRef pcmContent = pendingRdict->second;
1898 TMemFile::ZeroCopyView_t range{pcmContent.data(), pcmContent.size()};
1899 std::string RDictFileOpts = pcmFileNameFullPath +
"?filetype=pcm";
1900 TMemFile pcmMemFile(RDictFileOpts.c_str(), range);
1915 if (!llvm::sys::fs::exists(pcmFileNameFullPath)) {
1916 ::Error(
"TCling::LoadPCM",
"ROOT PCM %s file does not exist",
1917 pcmFileNameFullPath.data());
1920 ::Info(
"TCling::LoadPCM",
"In-memory ROOT PCM candidate %s\n",
1921 rdict.first.c_str());
1925 if (!
gROOT->IsRootFile(pcmFileName)) {
1926 Fatal(
"LoadPCM",
"The file %s is not a ROOT as was expected\n", pcmFileName.
Data());
1929 TFile pcmFile(pcmFileName +
"?filetype=pcm",
"READ");
1936 using namespace clang;
1938 class ExtLexicalStorageAdder:
public RecursiveASTVisitor<ExtLexicalStorageAdder>{
1943 bool VisitRecordDecl(clang::RecordDecl* rcd){
1945 Info(
"ExtLexicalStorageAdder",
1946 "Adding external lexical storage to class %s",
1947 rcd->getNameAsString().c_str());
1948 auto reDeclPtr = rcd->getMostRecentDecl();
1950 reDeclPtr->setHasExternalLexicalStorage();
1951 }
while ((reDeclPtr = reDeclPtr->getPreviousDecl()));
1964 const std::string &ModuleMapName )
const
1966 assert(llvm::sys::path::is_absolute(FullPath));
1967 Preprocessor &PP =
fInterpreter->getCI()->getPreprocessor();
1968 FileManager &FM = PP.getFileManager();
1971 if (
auto DE = FM.getOptionalDirectoryRef(FullPath)) {
1972 HeaderSearch &HS = PP.getHeaderSearchInfo();
1973 HeaderSearchOptions &HSOpts = HS.getHeaderSearchOpts();
1974 const auto &ModPaths = HSOpts.PrebuiltModulePaths;
1975 bool pathExists = std::find(ModPaths.begin(), ModPaths.end(), FullPath) != ModPaths.end();
1977 HSOpts.AddPrebuiltModulePath(FullPath);
1982 llvm::SmallString<256> ModuleMapFileName(DE->getName());
1983 llvm::sys::path::append(ModuleMapFileName, ModuleMapName);
1984 if (
auto FE = FM.getOptionalFileRef(ModuleMapFileName,
false,
1986 if (!HS.loadModuleMapFile(*FE,
false))
1988 Error(
"RegisterPrebuiltModulePath",
"Could not load modulemap in %s", ModuleMapFileName.c_str());
2005 "libforward_listDict",
2013 "libunordered_setDict",
2014 "libunordered_multisetDict",
2015 "libunordered_mapDict",
2016 "libunordered_multimapDict",
2021static void PrintDlError(
const char *dyLibName,
const char *modulename)
2024 char dyLibError[1000];
2025 FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
2026 dyLibError,
sizeof(dyLibError), NULL);
2028 const char *dyLibError = dlerror();
2030 ::Error(
"TCling::RegisterModule",
"Cannot open shared library %s for dictionary %s:\n %s", dyLibName, modulename,
2031 (dyLibError) ? dyLibError :
"");
2069 const char** headers,
2070 const char** includePaths,
2071 const char* payloadCode,
2072 const char* fwdDeclsCode,
2073 void (*triggerFunc)(),
2075 const char** classesHeaders,
2076 Bool_t lateRegistration ,
2083 if (fromRootCling)
return;
2092 bool isACLiC = strstr(modulename,
"_ACLiC_dict") !=
nullptr;
2093 if (hasHeaderParsingOnDemand && isACLiC) {
2095 Info(
"TCling::RegisterModule",
2096 "Header parsing on demand is active but this is an Aclic library. Disabling it for this library.");
2097 hasHeaderParsingOnDemand =
false;
2111 for (
const char** inclPath = includePaths; *inclPath; ++inclPath) {
2114 cling::Transaction* T =
nullptr;
2116 for (
auto& fwdDeclArgToSkipPair : fwdDeclsArgToSkip){
2117 const std::string& fwdDecl = fwdDeclArgToSkipPair.first;
2118 const int nArgsToSkip = fwdDeclArgToSkipPair.second;
2119 auto compRes =
fInterpreter->declare(fwdDecl.c_str(), &T);
2120 assert(cling::Interpreter::kSuccess == compRes &&
2121 "A fwd declaration could not be compiled");
2122 if (compRes!=cling::Interpreter::kSuccess){
2123 Warning(
"TCling::RegisterModule",
2124 "Problems in declaring string '%s' were encountered.",
2131 fNormalizedCtxt->AddTemplAndNargsToKeep(TD->getCanonicalDecl(), nArgsToSkip);
2139 TString code = gNonInterpreterClassDef;
2141 code += payloadCode;
2143 std::string dyLibName = cling::DynamicLibraryManager::getSymbolLocation(triggerFunc);
2144 assert(!llvm::sys::fs::is_symlink_file(dyLibName));
2146 if (dyLibName.empty()) {
2147 ::Error(
"TCling::RegisterModule",
"Dictionary trigger function for %s not found", modulename);
2152 bool isSharedLib = cling::DynamicLibraryManager::isSharedLibrary(dyLibName);
2154 bool wasDlopened =
false;
2159 if (!lateRegistration) {
2166 void* dyLibHandle = dlopen(dyLibName.c_str(), RTLD_LAZY | RTLD_GLOBAL);
2176 if (hasHeaderParsingOnDemand && fwdDeclsCode){
2179 std::string fwdDeclsCodeLessEnums;
2183 std::string fwdDeclsLine;
2184 std::istringstream fwdDeclsCodeStr(fwdDeclsCode);
2185 std::vector<std::string> scopes;
2186 while (std::getline(fwdDeclsCodeStr, fwdDeclsLine)) {
2187 const auto enumPos = fwdDeclsLine.find(
"enum __attribute__((annotate(\"");
2189 if (enumPos != std::string::npos) {
2196 auto nsPos = fwdDeclsLine.find(
"namespace");
2197 R__ASSERT(nsPos < enumPos &&
"Inconsistent enum and enclosing scope parsing!");
2198 while (nsPos < enumPos && nsPos != std::string::npos) {
2200 const auto nsNameStart = nsPos + 10;
2201 const auto nsNameEnd = fwdDeclsLine.find(
'{', nsNameStart);
2202 const auto nsName = fwdDeclsLine.substr(nsNameStart, nsNameEnd - nsNameStart);
2203 scopes.push_back(nsName);
2204 nsPos = fwdDeclsLine.find(
"namespace", nsNameEnd);
2207 clang::DeclContext* DC =
nullptr;
2208 for (
auto &&aScope: scopes) {
2209 DC = cling::utils::Lookup::Namespace(&
fInterpreter->getSema(), aScope.c_str(), DC);
2215 if (scopes.empty() || DC) {
2219 size_t posEnumName = fwdDeclsLine.rfind(
"\"))) ");
2220 R__ASSERT(posEnumName != std::string::npos &&
"Inconsistent enum fwd decl!");
2222 while (isspace(fwdDeclsLine[posEnumName]))
2224 size_t posEnumNameEnd = fwdDeclsLine.find(
" : ", posEnumName);
2225 R__ASSERT(posEnumNameEnd != std::string::npos &&
"Inconsistent enum fwd decl (end)!");
2226 while (isspace(fwdDeclsLine[posEnumNameEnd]))
2230 std::string enumName = fwdDeclsLine.substr(posEnumName,
2231 posEnumNameEnd - posEnumName + 1);
2233 if (clang::NamedDecl* enumDecl
2234 = cling::utils::Lookup::Named(&
fInterpreter->getSema(),
2235 enumName.c_str(), DC)) {
2238 R__ASSERT(llvm::dyn_cast<clang::EnumDecl>(enumDecl) &&
"not an enum decl!");
2245 fwdDeclsCodeLessEnums += fwdDeclsLine +
"\n";
2249 if (!fwdDeclsCodeLessEnums.empty()){
2250 auto compRes =
fInterpreter->declare(fwdDeclsCodeLessEnums, &T);
2251 assert(cling::Interpreter::kSuccess == compRes &&
2252 "The forward declarations could not be compiled");
2253 if (compRes!=cling::Interpreter::kSuccess){
2254 Warning(
"TCling::RegisterModule",
2255 "Problems in compiling forward declarations for module %s: '%s'",
2256 modulename, fwdDeclsCodeLessEnums.c_str()) ;
2264 ExtLexicalStorageAdder elsa;
2265 for (
auto dciIt = T->decls_begin();dciIt!=T->decls_end();dciIt++){
2266 cling::Transaction::DelayCallInfo& dci = *dciIt;
2267 for(
auto dit = dci.m_DGR.begin(); dit != dci.m_DGR.end(); ++dit) {
2268 clang::Decl* declPtr = *dit;
2269 elsa.TraverseDecl(declPtr);
2283 for (
const char** classesHeader = classesHeaders; *classesHeader; ++classesHeader) {
2284 temp=*classesHeader;
2286 size_t theTemplateHash = 0;
2287 bool addTemplate =
false;
2288 size_t posTemplate =
temp.find(
'<');
2289 if (posTemplate != std::string::npos) {
2291 std::string templateName =
temp.substr(0, posTemplate);
2297 for (
const char** classesHeader_inner = classesHeader; 0!=strcmp(*classesHeader_inner,
"@"); ++classesHeader_inner,++classesHeader){
2299 if (payloadCode == *classesHeader_inner ){
2301 if (addTemplate)
fPayloads.insert(theTemplateHash);
2304 Info(
"TCling::RegisterModule",
2305 "Adding a header for %s",
temp.c_str());
2311 addTemplate =
false;
2319 bool ModuleWasSuccessfullyLoaded =
false;
2321 std::string ModuleName = modulename;
2322 if (llvm::StringRef(modulename).starts_with(
"lib"))
2323 ModuleName = llvm::StringRef(modulename).substr(3).str();
2328 clang::Preprocessor &PP = TheSema.getPreprocessor();
2329 std::string ModuleMapName;
2331 ModuleMapName = ModuleName +
".modulemap";
2333 ModuleMapName =
"module.modulemap";
2341 if (!ModuleWasSuccessfullyLoaded) {
2343 clang::HeaderSearch &headerSearch = PP.getHeaderSearchInfo();
2344 clang::ModuleMap &moduleMap = headerSearch.getModuleMap();
2345 if (moduleMap.findModule(ModuleName))
2346 Info(
"TCling::RegisterModule",
"Module %s in modulemap failed to load.", ModuleName.c_str());
2351 llvm::SmallString<256> pcmFileNameFullPath(dyLibName);
2354 llvm::sys::fs::make_absolute(pcmFileNameFullPath);
2355 llvm::sys::path::remove_filename(pcmFileNameFullPath);
2356 llvm::sys::path::append(pcmFileNameFullPath,
2358 LoadPCM(pcmFileNameFullPath.str().str());
2365 clangDiagSuppr diagSuppr(TheSema.getDiagnostics());
2367#if defined(R__MUST_REVISIT)
2368#if R__MUST_REVISIT(6,2)
2369 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
2373 if (!ModuleWasSuccessfullyLoaded && !hasHeaderParsingOnDemand){
2376 const cling::Transaction* watermark =
fInterpreter->getLastTransaction();
2377 cling::Interpreter::CompilationResult compRes =
fInterpreter->parseForModule(code.
Data());
2383 assert(cling::Interpreter::kSuccess == compRes &&
2384 "Payload code of a dictionary could not be parsed correctly.");
2385 if (compRes!=cling::Interpreter::kSuccess) {
2386 Warning(
"TCling::RegisterModule",
2387 "Problems declaring payload for module %s.", modulename) ;
2400 if (!ModuleWasSuccessfullyLoaded && !hasHeaderParsingOnDemand) {
2403 "#undef __ROOTCLING__\n"
2404 + gInterpreterClassDef +
2409 assert(isSharedLib);
2412 dlclose(dyLibHandle);
2418 ASTContext &
C = CI.getASTContext();
2426 if (IdentifierInfoLookup *External =
C.Idents.getExternalIdentifierLookup()) {
2427 std::unique_ptr<IdentifierIterator> Iter(
External->getIdentifiers());
2428 for (llvm::StringRef Ident = Iter->Next(); !Ident.empty(); Ident = Iter->Next()) {
2429 std::string
I = Ident.str();
2431 Idents.
Add(
new TObjString(
I.c_str()));
2453 typedef std::vector<std::pair<TClass*,DictFuncPtr_t> >::iterator iterator;
2459 if ( i->first == oldcl ) {
2482 const char* input_line,
2483 cling::Interpreter::CompilationResult& compRes,
2484 cling::Value* result)
2487 return metaProcessor->process(input_line, compRes, result);
2489 catch (cling::InterpreterException&
ex)
2491 Error(
"HandleInterpreterException",
"%s\n%s",
ex.what(),
"Execution of your code was aborted.");
2493 compRes = cling::Interpreter::kFailure;
2502 if (
auto ie =
dynamic_cast<const cling::InterpreterException*
>(&
e)) {
2518 TString sLine(
line);
2528 gROOT->SetLineIsProcessing();
2532 gROOT->SetLineHasBeenProcessed();
2545 gROOT->SetLineIsProcessing();
2547 struct InterpreterFlagsRAII {
2548 cling::Interpreter* fInterpreter;
2549 bool fWasDynamicLookupEnabled;
2551 InterpreterFlagsRAII(cling::Interpreter* interp):
2552 fInterpreter(interp),
2553 fWasDynamicLookupEnabled(interp->isDynamicLookupEnabled())
2555 fInterpreter->enableDynamicLookup(
true);
2557 ~InterpreterFlagsRAII() {
2558 fInterpreter->enableDynamicLookup(fWasDynamicLookupEnabled);
2559 gROOT->SetLineHasBeenProcessed();
2567 cling::Value result;
2568 cling::Interpreter::CompilationResult compRes = cling::Interpreter::kSuccess;
2569 if (!strncmp(sLine.
Data(),
".L", 2) || !strncmp(sLine.
Data(),
".x", 2) ||
2570 !strncmp(sLine.
Data(),
".X", 2)) {
2573 TString mod_line(sLine);
2577 TString fname =
gSystem->SplitAclicMode(sLine.
Data() + 3,
2578 aclicMode, arguments, io);
2579 if (aclicMode.
Length()) {
2581 R__ASSERT(aclicMode[0]==
'+' &&
"ACLiC mode must start with a +");
2583 if (aclicMode[1]==
'+') {
2587 if (!
gSystem->CompileMacro(fname,aclicMode)) {
2589 compRes = cling::Interpreter::kFailure;
2591 if (strncmp(sLine.
Data(),
".L", 2) != 0) {
2594 if (arguments.
Length() == 0) {
2603 mod_line =
function + arguments + io;
2607 }
else if (cling::DynamicLibraryManager::isSharedLibrary(fname.
Data()) &&
2608 strncmp(sLine.
Data(),
".L", 2) != 0) {
2609 if (
gSystem->Load(fname) < 0) {
2611 compRes = cling::Interpreter::kFailure;
2613 if (arguments.
Length() == 0) {
2627 ext = fname.
Last(
'_');
2633 mod_line =
function + arguments + io;
2638 size_t unnamedMacroOpenCurly;
2641 std::string codeline;
2644 std::ifstream in(fname, std::ifstream::binary);
2646 std::getline(in, codeline);
2647 code += codeline +
"\n";
2649 unnamedMacroOpenCurly
2650 = cling::utils::isUnnamedMacro(code,
fInterpreter->getCI()->getLangOpts());
2654 if (unnamedMacroOpenCurly != std::string::npos) {
2656 unnamedMacroOpenCurly);
2666 if (0!=strncmp(sLine.
Data(),
".autodict ",10) && sLine !=
".autodict") {
2671 bool isInclusionDirective = sLine.
Contains(
"\n#include") || sLine.
BeginsWith(
"#include");
2672 if (isInclusionDirective) {
2680 if (result.isValid())
2689 case cling::Interpreter::kSuccess: *error =
kNoError;
break;
2690 case cling::Interpreter::kFailure: *error =
kRecoverable;
break;
2691 case cling::Interpreter::kMoreInputExpected: *error =
kProcessing;
break;
2694 if (compRes == cling::Interpreter::kSuccess
2696 && !result.isVoid())
2719 if (!strcmp(
option,
"autoparsed")) {
2720 std::cout <<
"Auto parsed classes:" << std::endl;
2722 std::cout <<
" " << cls << std::endl;
2724 }
else if (!strcmp(
option,
"autoloaded")) {
2725 std::cout <<
"Auto loaded libraries:" << std::endl;
2727 std::cout <<
" " << lib << std::endl;
2733 ::Info(
"TCling::Print",
"No options specified");
2753 if (path[0] ==
'-' && path[1] ==
'I')
2756 gSystem->ExpandPathName(sPath);
2760 snprintf(drive, 3,
"%c:", _getdrive() +
'A' - 1);
2785 static const TClassRef clRefString(
"std::string");
2786 if (clRefString == cl) {
2796 const char* cobj = (
const char*) obj;
2803 auto inspInspect = [&] (ptrdiff_t offset){
2804 insp.
Inspect(
const_cast<TClass*
>(cl), insp.
GetParent(),
"_real", cobj, isTransient);
2805 insp.
Inspect(
const_cast<TClass*
>(cl), insp.
GetParent(),
"_imag", cobj + offset, isTransient);
2809 switch(complexType) {
2816 inspInspect(
sizeof(
float));
2821 inspInspect(
sizeof(
double));
2826 inspInspect(
sizeof(
int));
2831 inspInspect(
sizeof(
long));
2836 static clang::PrintingPolicy
2838 if (printPol.Indentation) {
2840 printPol.Indentation = 0;
2841 printPol.SuppressInitializers =
true;
2844 const char* clname = cl->
GetName();
2847 const clang::ASTContext& astContext =
fInterpreter->getCI()->getASTContext();
2848 const clang::Decl *scopeDecl =
nullptr;
2849 const clang::Type *recordType =
nullptr;
2852 TClingClassInfo * clingCI = (TClingClassInfo *)cl->
GetClassInfo();
2853 scopeDecl = clingCI->
GetDecl();
2854 recordType = clingCI->
GetType();
2856 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
2858 scopeDecl = lh.findScope(clname, cling::LookupHelper::NoDiagnostics,
2862 Error(
"InspectMembers",
"Cannot find Decl for class %s", clname);
2865 const clang::CXXRecordDecl* recordDecl
2866 = llvm::dyn_cast<const clang::CXXRecordDecl>(scopeDecl);
2868 Error(
"InspectMembers",
"Cannot find Decl for class %s is not a CXXRecordDecl.", clname);
2877 astContext.getASTRecordLayout(recordDecl);
2879 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2880 eField = recordDecl->field_end(); iField != eField; ++iField) {}
2883 const clang::ASTRecordLayout& recLayout
2884 = astContext.getASTRecordLayout(recordDecl);
2891 if (cl->
Size() != recLayout.getSize().getQuantity()) {
2892 Error(
"InspectMembers",
"TClass and cling disagree on the size of the class %s, respectively %d %lld\n",
2896 unsigned iNField = 0;
2899 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2900 eField = recordDecl->field_end(); iField != eField;
2901 ++iField, ++iNField) {
2904 clang::QualType memberQT = iField->getType();
2909 memberQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, memberQT,
fNormalizedCtxt->GetConfig(),
false );
2910 if (memberQT.isNull()) {
2911 std::string memberName;
2912 llvm::raw_string_ostream stream(memberName);
2914 printPol.AnonymousTagLocations =
false;
2915 iField->getNameForDiagnostic(stream, printPol,
true );
2917 Error(
"InspectMembers",
2918 "Cannot retrieve QualType for member %s while inspecting class %s",
2919 memberName.c_str(), clname);
2922 const clang::Type* memType = memberQT.getTypePtr();
2924 std::string memberName;
2925 llvm::raw_string_ostream stream(memberName);
2927 printPol.AnonymousTagLocations =
false;
2928 iField->getNameForDiagnostic(stream, printPol,
true );
2930 Error(
"InspectMembers",
2931 "Cannot retrieve Type for member %s while inspecting class %s",
2932 memberName.c_str(), clname);
2936 const clang::Type* memNonPtrType = memType;
2937 Bool_t ispointer =
false;
2938 if (memNonPtrType->isPointerType()) {
2940 clang::QualType ptrQT
2941 = memNonPtrType->getAs<clang::PointerType>()->getPointeeType();
2946 ptrQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, ptrQT,
fNormalizedCtxt->GetConfig(),
false );
2947 if (ptrQT.isNull()) {
2948 std::string memberName;
2949 llvm::raw_string_ostream stream(memberName);
2951 printPol.AnonymousTagLocations =
false;
2952 iField->getNameForDiagnostic(stream, printPol,
true );
2954 Error(
"InspectMembers",
2955 "Cannot retrieve pointee Type for member %s while inspecting class %s",
2956 memberName.c_str(), clname);
2959 memNonPtrType = ptrQT.getTypePtr();
2963 llvm::SmallString<8> arraySize;
2964 const clang::ArrayType* arrType = memNonPtrType->getAsArrayTypeUnsafe();
2965 unsigned arrLevel = 0;
2966 bool haveErrorDueToArray =
false;
2970 const clang::ConstantArrayType* constArrType =
2971 clang::dyn_cast<clang::ConstantArrayType>(arrType);
2973 constArrType->getSize().toStringUnsigned(arraySize);
2976 clang::QualType subArrQT = arrType->getElementType();
2977 if (subArrQT.isNull()) {
2978 std::string memberName;
2979 llvm::raw_string_ostream stream(memberName);
2981 printPol.AnonymousTagLocations =
false;
2982 iField->getNameForDiagnostic(stream, printPol,
true );
2984 Error(
"InspectMembers",
2985 "Cannot retrieve QualType for array level %d (i.e. element type of %s) for member %s while inspecting class %s",
2986 arrLevel, subArrQT.getAsString(printPol).c_str(),
2987 memberName.c_str(), clname);
2988 haveErrorDueToArray =
true;
2991 arrType = subArrQT.getTypePtr()->getAsArrayTypeUnsafe();
2993 if (haveErrorDueToArray) {
2998 std::string fieldName;
2999 if (memType->isPointerType()) {
3004 std::string ioname(iField->getName());
3006 fieldName += ioname;
3007 fieldName += arraySize;
3012 clang::CharUnits offset(astContext.toCharUnitsFromBits(recLayout.getFieldOffset(iNField)));
3013 ptrdiff_t fieldOffset = offset.getQuantity();
3023 auto iFiledQtype = iField->getType();
3024 if (
auto tagDecl = iFiledQtype->getAsTagDecl()){
3025 auto declAccess = tagDecl->getAccess();
3026 if (declAccess == AS_private || declAccess == AS_protected) {
3032 insp.
Inspect(
const_cast<TClass*
>(cl), insp.
GetParent(), fieldName.c_str(), cobj + fieldOffset, isTransient);
3035 const clang::CXXRecordDecl* fieldRecDecl = memNonPtrType->getAsCXXRecordDecl();
3036 if (fieldRecDecl && !fieldRecDecl->isAnonymousStructOrUnion()) {
3039 std::string sFieldRecName;
3042 clang::QualType(memNonPtrType,0),
3053 insp.
InspectMember(sFieldRecName.c_str(), cobj + fieldOffset,
3054 (fieldName +
'.').c_str(), transient);
3064 unsigned iNBase = 0;
3065 for (clang::CXXRecordDecl::base_class_const_iterator iBase
3066 = recordDecl->bases_begin(), eBase = recordDecl->bases_end();
3067 iBase != eBase; ++iBase, ++iNBase) {
3068 clang::QualType baseQT = iBase->getType();
3069 if (baseQT.isNull()) {
3070 Error(
"InspectMembers",
3071 "Cannot find QualType for base number %d while inspecting class %s",
3075 const clang::CXXRecordDecl* baseDecl
3076 = baseQT->getAsCXXRecordDecl();
3078 Error(
"InspectMembers",
3079 "Cannot find CXXRecordDecl for base number %d while inspecting class %s",
3083 TClass* baseCl=
nullptr;
3084 std::string sBaseName;
3086 std::vector<TClass*> foundClasses;
3088 if (foundClasses.size()==1){
3089 baseCl=foundClasses[0];
3102 std::string qualNameForDiag;
3104 Error(
"InspectMembers",
3105 "Cannot find TClass for base class %s", qualNameForDiag.c_str() );
3110 if (iBase->isVirtual()) {
3113 Error(
"InspectMembers",
3114 "Base %s of class %s is virtual but no object provided",
3115 sBaseName.c_str(), clname);
3120 TClingClassInfo* ci = (TClingClassInfo*)cl->
GetClassInfo();
3121 TClingClassInfo* baseCi = (TClingClassInfo*)baseCl->
GetClassInfo();
3123 baseOffset = ci->
GetBaseOffset(baseCi,
const_cast<void*
>(obj),
3125 if (baseOffset == -1) {
3126 Error(
"InspectMembers",
3127 "Error calculating offset of virtual base %s of class %s",
3128 sBaseName.c_str(), clname);
3131 Error(
"InspectMembers",
3132 "Cannot calculate offset of virtual base %s of class %s",
3133 sBaseName.c_str(), clname);
3138 baseOffset = recLayout.getBaseClassOffset(baseDecl).getQuantity();
3193 bool oldDynLookup =
fInterpreter->isDynamicLookupEnabled();
3222 return fInterpreter->getDynamicLibraryManager()->isLibraryLoaded(tLibName.Data());
3237 llvm::StringRef ModuleName(libname);
3238 ModuleName = llvm::sys::path::stem(ModuleName);
3239 ModuleName.consume_front(
"lib");
3247 clang::ModuleMap &moduleMap =
fInterpreter->getCI()->getPreprocessor().getHeaderSearchInfo().getModuleMap();
3248 clang::Module *M = moduleMap.findModule(ModuleName);
3249 return M && !M->IsUnimportable && M->getASTFile();
3267 std::string file_name = filename;
3268 size_t at = std::string::npos;
3269 while ((at = file_name.find(
"/./")) != std::string::npos)
3270 file_name.replace(at, 3,
"/");
3272 std::string filesStr =
"";
3273 llvm::raw_string_ostream filesOS(filesStr);
3274 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
3275 cling::ClangInternalState::printIncludedFiles(filesOS, SM);
3278 llvm::SmallVector<llvm::StringRef, 100> files;
3279 llvm::StringRef(filesStr).split(files,
"\n");
3281 std::set<std::string> fileMap;
3282 llvm::StringRef file_name_ref(file_name);
3284 for (llvm::SmallVector<llvm::StringRef, 100>::const_iterator
3285 iF = files.begin(), iE = files.end(); iF != iE; ++iF) {
3286 if ((*iF) == file_name_ref)
return kTRUE;
3287 fileMap.insert(iF->str());
3290 if (fileMap.empty())
return kFALSE;
3293 TString sFilename(file_name.c_str());
3295 && fileMap.count(sFilename.
Data())) {
3303 while (incPath.
Index(
" :") != -1) {
3307 sFilename = file_name.c_str();
3309 && fileMap.count(sFilename.
Data())) {
3318 clang::ConstSearchDirIterator *CurDir =
nullptr;
3319 clang::Preprocessor &PP =
fInterpreter->getCI()->getPreprocessor();
3320 clang::HeaderSearch &HS = PP.getHeaderSearchInfo();
3321 auto FE = HS.LookupFile(file_name.c_str(),
3322 clang::SourceLocation(),
3325 clang::ArrayRef<std::pair<clang::OptionalFileEntryRef,
3326 clang::DirectoryEntryRef>>(),
3339 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
3341 clang::FileID FID = SM.translateFile(*FE);
3342 if (!FID.isInvalid() && FID.getHashValue() == 0)
3345 clang::SrcMgr::SLocEntry SLocE = SM.getSLocEntry(FID);
3346 if (SLocE.isFile() && !SLocE.getFile().getContentCache().getBufferIfLoaded())
3348 if (!FID.isInvalid())
3352 sFilename = FE->getName().str();
3354 && fileMap.count(sFilename.
Data())) {
3362#if defined(R__MACOSX)
3370static bool R__UpdateLibFileForLinking(
TString &lib)
3372 const char *mapfile =
nullptr;
3374 mapfile =
"/System/Library/dyld/dyld_shared_cache_x86_64.map";
3376 mapfile =
"/System/Library/dyld/dyld_shared_cache_arm64e.map";
3378 #error unsupported architecture
3380 if (std::ifstream cacheMap{mapfile}) {
3382 while (getline(cacheMap,
line)) {
3383 if (
line.find(lib) != std::string::npos) {
3395#if defined (R__LINUX) || defined (R__FBSD)
3401static int callback_for_dl_iterate_phdr(
struct dl_phdr_info *info,
size_t size,
void *data)
3404 static std::unordered_set<
decltype(info->dlpi_addr)> sKnownLoadedLibBaseAddrs;
3406 auto newLibs =
static_cast<std::vector<std::string>*
>(data);
3407 if (!sKnownLoadedLibBaseAddrs.count(info->dlpi_addr)) {
3409 if (info->dlpi_name && info->dlpi_name[0]
3414 && strncmp(info->dlpi_name,
"[vdso]", 6)
3418 && strncmp(info->dlpi_name,
"/libexec/ld-elf.so.1", 20)
3420 && strncmp(info->dlpi_name,
"linux-vdso.so", 13)
3421 && strncmp(info->dlpi_name,
"linux-vdso32.so", 15)
3422 && strncmp(info->dlpi_name,
"linux-vdso64.so", 15)
3423 && strncmp(info->dlpi_name,
"linux-gate.so", 13))
3424 newLibs->emplace_back(info->dlpi_name);
3425 sKnownLoadedLibBaseAddrs.insert(info->dlpi_addr);
3438#if defined(R__WIN32) || defined(__CYGWIN__)
3439 HMODULE hModules[1024];
3441 unsigned long cbModules;
3443 hProcess = (
void *)::GetCurrentProcess();
3444 ::EnumProcessModules(hProcess, hModules,
sizeof(hModules), &cbModules);
3446 for (i = 1; i < (cbModules /
sizeof(
void *)); i++) {
3447 static const int bufsize = 260;
3448 wchar_t winname[bufsize];
3449 char posixname[bufsize];
3450 ::GetModuleFileNameExW(hProcess, hModules[i], winname, bufsize);
3451#if defined(__CYGWIN__)
3452 cygwin_conv_path(CCP_WIN_W_TO_POSIX, winname, posixname, bufsize);
3454 std::wstring wpath = winname;
3455 std::replace(wpath.begin(), wpath.end(),
'\\',
'/');
3456 string path(wpath.begin(), wpath.end());
3457 strncpy(posixname, path.c_str(), bufsize);
3463#elif defined(R__MACOSX)
3467 while (
const mach_header* mh = _dyld_get_image_header(imageIndex)) {
3469 if (mh->filetype == MH_DYLIB) {
3470 if (
const char* imageName = _dyld_get_image_name(imageIndex)) {
3478#elif defined(R__LINUX) || defined(R__FBSD)
3482 std::vector<std::string> newLibs;
3483 dl_iterate_phdr(callback_for_dl_iterate_phdr, &newLibs);
3484 for (
auto &&lib: newLibs)
3487 Error(
"TCling::UpdateListOfLoadedSharedLibraries",
3488 "Platform not supported!");
3494static bool StartsWithStrLit(
const char *haystack,
const char (&needle)[
N]) {
3495 return !strncmp(haystack, needle,
N - 1);
3514 if (!filename)
return;
3518 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
3519 if (!DLM->isLibraryLoaded(filename)) {
3520 DLM->loadLibrary(filename,
true ,
true );
3523#if defined(R__MACOSX)
3525 auto lenFilename = strlen(filename);
3526 auto isInMacOSSystemDir = [](
const char *fn) {
3527 return StartsWithStrLit(fn,
"/usr/lib/") || StartsWithStrLit(fn,
"/System/Library/");
3529 if (!strcmp(filename,
"cl_kernels")
3532 || StartsWithStrLit(filename,
"/usr/lib/system/")
3533 || StartsWithStrLit(filename,
"/usr/lib/libc++")
3534 || StartsWithStrLit(filename,
"/System/Library/Frameworks/")
3535 || StartsWithStrLit(filename,
"/System/Library/PrivateFrameworks/")
3536 || StartsWithStrLit(filename,
"/System/Library/CoreServices/")
3537 || StartsWithStrLit(filename,
"/usr/lib/libSystem")
3538 || StartsWithStrLit(filename,
"/usr/lib/libstdc++")
3539 || StartsWithStrLit(filename,
"/usr/lib/libicucore")
3540 || StartsWithStrLit(filename,
"/usr/lib/libbsm")
3541 || StartsWithStrLit(filename,
"/usr/lib/libobjc")
3542 || StartsWithStrLit(filename,
"/usr/lib/libresolv")
3543 || StartsWithStrLit(filename,
"/usr/lib/libauto")
3544 || StartsWithStrLit(filename,
"/usr/lib/libcups")
3545 || StartsWithStrLit(filename,
"/usr/lib/libDiagnosticMessagesClient")
3546 || StartsWithStrLit(filename,
"/usr/lib/liblangid")
3547 || StartsWithStrLit(filename,
"/usr/lib/libCRFSuite")
3548 || StartsWithStrLit(filename,
"/usr/lib/libpam")
3549 || StartsWithStrLit(filename,
"/usr/lib/libOpenScriptingUtil")
3550 || StartsWithStrLit(filename,
"/usr/lib/libextension")
3551 || StartsWithStrLit(filename,
"/usr/lib/libAudioToolboxUtility")
3552 || StartsWithStrLit(filename,
"/usr/lib/liboah")
3553 || StartsWithStrLit(filename,
"/usr/lib/libRosetta")
3554 || StartsWithStrLit(filename,
"/usr/lib/libCoreEntitlements")
3555 || StartsWithStrLit(filename,
"/usr/lib/libssl.")
3556 || StartsWithStrLit(filename,
"/usr/lib/libcrypto.")
3559 || (isInMacOSSystemDir(filename) &&
gSystem->AccessPathName(filename))
3562 || StartsWithStrLit(filename,
"/usr/lib/system/libsystem_kernel")
3563 || StartsWithStrLit(filename,
"/usr/lib/system/libsystem_platform")
3564 || StartsWithStrLit(filename,
"/usr/lib/system/libsystem_pthread")
3569 || (lenFilename > 4 && !strcmp(filename + lenFilename - 4,
".tbd")))
3571 TString sFileName(filename);
3572 R__UpdateLibFileForLinking(sFileName);
3573 filename = sFileName.Data();
3574#elif defined(__CYGWIN__)
3576 static const int bufsize = 260;
3577 char posixwindir[bufsize];
3578 char *windir = std::getenv(
"WINDIR");
3580 cygwin_conv_path(CCP_WIN_A_TO_POSIX, windir, posixwindir, bufsize);
3582 snprintf(posixwindir,
sizeof(posixwindir),
"/Windows/");
3583 if (strstr(filename, posixwindir) ||
3584 strstr(filename,
"/usr/bin/cyg"))
3586#elif defined(R__WIN32)
3587 if (strstr(filename,
"/Windows/"))
3589#elif defined (R__LINUX)
3590 if (strstr(filename,
"/ld-linux")
3591 || strstr(filename,
"linux-gnu/")
3592 || strstr(filename,
"/libstdc++.")
3593 || strstr(filename,
"/libgcc")
3594 || strstr(filename,
"/libc.")
3595 || strstr(filename,
"/libdl.")
3596 || strstr(filename,
"/libm."))
3613 assert(!
IsFromRootCling() &&
"Trying to load library from rootcling!");
3617 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
3618 std::string canonLib = DLM->lookupLibrary(filename);
3619 cling::DynamicLibraryManager::LoadLibResult res
3620 = cling::DynamicLibraryManager::kLoadLibNotFound;
3621 if (!canonLib.empty()) {
3623 res = DLM->loadLibrary(filename, system,
true);
3627 cling::Interpreter::CompilationResult compRes;
3629 if (compRes == cling::Interpreter::kSuccess)
3630 res = cling::DynamicLibraryManager::kLoadLibSuccess;
3634 if (res == cling::DynamicLibraryManager::kLoadLibSuccess) {
3638 case cling::DynamicLibraryManager::kLoadLibSuccess:
return 0;
3639 case cling::DynamicLibraryManager::kLoadLibAlreadyLoaded:
return 1;
3689 Warning(
"Calc",
"waiting for cling thread to free");
3692 gROOT->SetLineIsProcessing();
3699 cling::Value valRef;
3700 cling::Interpreter::CompilationResult cr = cling::Interpreter::kFailure;
3704 catch (cling::InterpreterException&
ex)
3706 Error(
"Calc",
"%s.\n%s",
ex.what(),
"Evaluation of your expression was aborted.");
3708 cr = cling::Interpreter::kFailure;
3711 if (cr != cling::Interpreter::kSuccess) {
3719 if (!valRef.isValid()) {
3728 if (valRef.isVoid()) {
3735 gROOT->SetLineHasBeenProcessed();
3745 void (*histaddFunc)(
const char*
line))
3750#if defined(R__MUST_REVISIT)
3751#if R__MUST_REVISIT(6,2)
3752 Warning(
"SetGetline",
"Cling should support the equivalent of SetGetlineFunc(getlineFunc, histaddFunc)");
3765 if ((std::distance(T.decls_begin(), T.decls_end()) != 1)
3766 || T.deserialized_decls_begin() != T.deserialized_decls_end()
3767 || T.macros_begin() != T.macros_end()
3768 || ((!T.getFirstDecl().isNull()) && ((*T.getFirstDecl().begin()) != T.getWrapperFD()))) {
3791 std::set<TObject*>::iterator iSpecial = ((std::set<TObject*>*)
fgSetOfSpecials)->find(obj);
3809#if defined(R__MUST_REVISIT)
3810#if R__MUST_REVISIT(6,2)
3812 Warning(
"Reset",
"Cling should support the equivalent of scratch_upto(&fDictPos)");
3822#if defined(R__MUST_REVISIT)
3823#if R__MUST_REVISIT(6,2)
3825 Warning(
"ResetAll",
"Cling should support the equivalent of complete reset (unload everything but the startup decls.");
3852#if defined(R__MUST_REVISIT)
3853#if R__MUST_REVISIT(6,2)
3855 Warning(
"ResetGlobalVar",
"Cling should support the equivalent of resetglobalvar(obj)");
3867#if defined(R__MUST_REVISIT)
3868#if R__MUST_REVISIT(6,2)
3870 Warning(
"RewindDictionary",
"Cling should provide a way to revert transaction similar to rewinddictionary()");
3881#if defined(R__MUST_REVISIT)
3882#if R__MUST_REVISIT(6,2)
3884 Warning(
"DeleteGlobal",
"Cling should provide the equivalent of deleteglobal(obj), see also DeleteVariable.");
3896#if defined(R__MUST_REVISIT)
3897#if R__MUST_REVISIT(6,2)
3898 Warning(
"DeleteVariable",
"should do more that just reseting the value to zero");
3903 llvm::StringRef srName(
name);
3904 const char* unscopedName =
name;
3905 llvm::StringRef::size_type posScope = srName.rfind(
"::");
3906 const clang::DeclContext* declCtx =
nullptr;
3907 if (posScope != llvm::StringRef::npos) {
3908 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
3909 const clang::Decl* scopeDecl
3910 = lh.findScope(srName.substr(0, posScope),
3911 cling::LookupHelper::WithDiagnostics);
3913 Error(
"DeleteVariable",
"Cannot find enclosing scope for variable %s",
3917 declCtx = llvm::dyn_cast<clang::DeclContext>(scopeDecl);
3919 Error(
"DeleteVariable",
3920 "Enclosing scope for variable %s is not a declaration context",
3924 unscopedName += posScope + 2;
3928 clang::NamedDecl* nVarDecl
3929 = cling::utils::Lookup::Named(&
fInterpreter->getSema(), unscopedName, declCtx);
3931 Error(
"DeleteVariable",
"Unknown variable %s",
name);
3934 clang::VarDecl* varDecl = llvm::dyn_cast<clang::VarDecl>(nVarDecl);
3936 Error(
"DeleteVariable",
"Entity %s is not a variable",
name);
3940 clang::QualType qType = varDecl->getType();
3941 const clang::Type*
type = qType->getUnqualifiedDesugaredType();
3944 if (
type->isPointerType()) {
3945 int** ppInt = (
int**)
fInterpreter->getAddressOfGlobal(GlobalDecl(varDecl));
3947 if (ppInt) *ppInt =
nullptr;
3957#if defined(R__MUST_REVISIT)
3958#if R__MUST_REVISIT(6,2)
3960 Warning(
"SaveContext",
"Cling should provide a way to record a state watermark similar to store_dictposition(&fDictPos)");
3970#if defined(R__MUST_REVISIT)
3971#if R__MUST_REVISIT(6,2)
3973 Warning(
"SaveGlobalsContext",
"Cling should provide a way to record a watermark for the list of global variable similar to store_dictposition(&fDictPosGlobals)");
4021 std::tuple<int,double> value;
4025 size_t offset0 = ((
char*)&(std::get<0>(value))) - ((
char*)&value);
4026 size_t offset1 = ((
char*)&(std::get<1>(value))) - ((
char*)&value);
4028 size_t ascOffset0 = ((
char*)&(asc.
_0)) - ((
char*)&asc);
4029 size_t ascOffset1 = ((
char*)&(asc.
_1)) - ((
char*)&asc);
4031 size_t desOffset0 = ((
char*)&(des.
_0)) - ((
char*)&des);
4032 size_t desOffset1 = ((
char*)&(des.
_1)) - ((
char*)&des);
4034 if (offset0 == ascOffset0 && offset1 == ascOffset1) {
4036 }
else if (offset0 == desOffset0 && offset1 == desOffset1) {
4043static std::string
AlternateTuple(
const char *classname,
const cling::LookupHelper& lh,
Bool_t silent)
4046 std::string alternateName =
"TEmulatedTuple";
4047 alternateName.append( classname + 5 );
4049 std::string fullname =
"ROOT::Internal::" + alternateName;
4050 if (lh.findScope(fullname, cling::LookupHelper::NoDiagnostics,
4056 auto iter = tupleContent.fElements.begin() + 1;
4057 auto theEnd = tupleContent.fElements.end() - 1;
4058 auto deleter = [](TypeInfo_t *
type) {
4061 std::unique_ptr<TypeInfo_t,
decltype(deleter)>
type{
gInterpreter->TypeInfo_Factory(), deleter };
4062 while (iter != theEnd) {
4066 Error(
"Load",
"Could not declare alternate type for %s since %s (or one of its context) is private or protected",
4067 classname, iter->c_str());
4074 std::string guard_name;
4076 std::ostringstream guard;
4077 guard <<
"ROOT_INTERNAL_TEmulated_";
4078 guard << guard_name;
4080 std::ostringstream alternateTuple;
4081 std::ostringstream initializers;
4083 alternateTuple <<
"#ifndef " << guard.str() <<
"\n";
4084 alternateTuple <<
"#define " << guard.str() <<
"\n";
4085 alternateTuple <<
"namespace ROOT { namespace Internal {\n";
4086 alternateTuple <<
"template <class... Types> struct TEmulatedTuple;\n";
4087 alternateTuple <<
"template <> struct " << alternateName <<
" {\n";
4092 unsigned int nMember = 0;
4093 auto iter = tupleContent.fElements.begin() + 1;
4094 auto theEnd = tupleContent.fElements.end() - 1;
4096 while (iter != theEnd) {
4097 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
4098 initializers <<
" " <<
sep <<
" _" << nMember <<
"(std::get<" << nMember <<
">(std::forward<Tuple>(t)))\n";
4106 unsigned int nMember = tupleContent.fElements.size() - 3;
4107 auto iter = tupleContent.fElements.rbegin() + 1;
4108 auto theEnd = tupleContent.fElements.rend() - 1;
4110 while (iter != theEnd) {
4111 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
4112 initializers <<
" " <<
sep <<
" _" << nMember <<
"(std::get<" << nMember <<
">(std::forward<Tuple>(t)))\n";
4120 Fatal(
"TCling::SetClassInfo::AlternateTuple",
4121 "Layout of std::tuple on this platform is unexpected.");
4127 alternateTuple <<
" TEmulatedTuple() = default;\n";
4130 alternateTuple <<
" template <typename Tuple>\n";
4131 alternateTuple <<
" TEmulatedTuple(Tuple&& t)\n";
4132 alternateTuple << initializers.str();
4133 alternateTuple <<
" {}\n";
4135 alternateTuple <<
"};\n";
4136 alternateTuple <<
"}}\n";
4137 alternateTuple <<
"#endif\n";
4138 if (!
gCling->Declare(alternateTuple.str().c_str()))
4142 Error(
"Load",
"Could not declare %s",alternateName.c_str());
4145 alternateName =
"ROOT::Internal::" + alternateName;
4146 return alternateName;
4178 TClingClassInfo* TClinginfo = (TClingClassInfo*) cl->
fClassInfo;
4186 auto SetWithoutClassInfoState = [](TClass *cl)
4199 if (strncmp(cl->
GetName(),
"tuple<",std::char_traits<char>::length(
"tuple<"))==0) {
4202 if (reload ||
name.empty()) {
4204 SetWithoutClassInfoState(cl);
4216 SetWithoutClassInfoState(cl);
4233 zombieCandidate =
kTRUE;
4240 zombieCandidate =
kTRUE;
4293 static const char *anonEnum =
"anonymous enum ";
4294 static const int cmplen = strlen(anonEnum);
4321 const char *classname =
name;
4324 class MaybeSuspendAutoLoadParse {
4325 int fStoreAutoLoad = 0;
4326 int fStoreAutoParse = 0;
4327 bool fSuspendedAutoParse =
false;
4329 MaybeSuspendAutoLoadParse(
int autoload) {
4330 fStoreAutoLoad = ((
TCling*)
gCling)->SetClassAutoLoading(autoload);
4334 fSuspendedAutoParse =
true;
4335 fStoreAutoParse = ((
TCling*)
gCling)->SetSuspendAutoParsing(
true);
4338 ~MaybeSuspendAutoLoadParse() {
4339 if (fSuspendedAutoParse)
4340 ((
TCling*)
gCling)->SetSuspendAutoParsing(fStoreAutoParse);
4341 ((
TCling*)
gCling)->SetClassAutoLoading(fStoreAutoLoad);
4345 MaybeSuspendAutoLoadParse autoLoadParseRAII( autoload );
4347 autoLoadParseRAII.SuspendAutoParsing();
4356 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
4357 const clang::Type *
type =
nullptr;
4358 const clang::Decl *decl
4359 = lh.findScope(classname,
4360 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4361 : cling::LookupHelper::NoDiagnostics,
4365 decl = lh.findScope(buf,
4366 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4367 : cling::LookupHelper::NoDiagnostics,
4384 clang::ClassTemplateSpecializationDecl *tmpltDecl =
4385 llvm::dyn_cast_or_null<clang::ClassTemplateSpecializationDecl>
4386 (
type->getAsCXXRecordDecl());
4387 if (tmpltDecl && !tmpltDecl->getPointOfInstantiation().isValid()) {
4404 if (tci.
Property() & propertiesMask) {
4405 bool hasClassDefInline =
false;
4406 if (isClassOrNamespaceOnly) {
4412 if (hasDictionary.IsValid() && implLineFunc.IsValid()) {
4414 bool success =
false;
4415 std::tie(success, lineNumber) =
4417 hasClassDefInline = success && (lineNumber == -1);
4425 if (hasClassDefInline)
4464 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
4467 const clang::Decl *decl
4468 = lh.findClassTemplate(
name,
4469 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4470 : cling::LookupHelper::NoDiagnostics);
4472 std::string strname =
"std::";
4474 decl = lh.findClassTemplate(strname,
4475 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4476 : cling::LookupHelper::NoDiagnostics);
4478 return nullptr != decl;
4492 cl->
fBase =
new TList();
4495 TClingClassInfo *tci = (TClingClassInfo *)cl->
GetClassInfo();
4498 TList *listOfBase =
new TList;
4501 if (t.IsValid() && t.Name()) {
4502 TClingBaseClassInfo *
a =
new TClingBaseClassInfo(t);
4503 listOfBase->
Add(
new TBaseClass((BaseClassInfo_t *)
a, cl));
4507 cl->
fBase = listOfBase;
4523 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
4526 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
4529 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
4530 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
4531 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(), declEnd = allDeclContexts.end();
4532 declIter != declEnd; ++declIter) {
4534 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
4535 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
4536 if (
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(*DI)) {
4539 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
4540 llvm::raw_string_ostream stream(buf);
4542 Policy.AnonymousTagLocations =
false;
4543 ED->getNameForDiagnostic(stream, Policy,
false);
4547 const char*
name = buf.c_str();
4565 TListOfFunctionTemplates* funcTempList;
4571 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
4572 funcTempList = (TListOfFunctionTemplates*)
gROOT->GetListOfFunctionTemplates();
4575 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
4578 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
4579 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
4580 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(),
4581 declEnd = allDeclContexts.end(); declIter != declEnd; ++declIter) {
4583 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
4584 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
4585 if (
const clang::FunctionTemplateDecl* FTD = dyn_cast<clang::FunctionTemplateDecl>(*DI)) {
4586 funcTempList->
Get(FTD);
4598 TClingClassInfo *ci = (TClingClassInfo*)cl;
4644 if (
m->fMethodArgs) {
4647 TList *arglist =
new TList;
4651 TClingMethodArgInfo*
a =
new TClingMethodArgInfo(t);
4652 arglist->
Add(
new TMethodArg((MethodArgInfo_t*)
a,
m));
4655 m->fMethodArgs = arglist;
4689 TClass *cl =
new TClass(classname, version, silent);
4699 TClingClassInfo* cli = (TClingClassInfo*)cl->
GetClassInfo();
4700 if (llvm::isa<clang::NamespaceDecl>(cli->
GetDecl())) {
4704 TClingMethodInfo mi = cli->
GetMethod(
"Class_Version",
"",
nullptr ,
4709 Error(
"GenerateTClass",
4710 "Cannot find %s::Class_Version()! Class version might be wrong.",
4717 if (newvers == -1) {
4724 callfunc.SetFunc(&mi);
4725 newvers = callfunc.ExecInt(
nullptr);
4727 Error(
"GenerateTClass",
4728 "Cannot invoke %s::Class_Version()! Class version might be wrong.",
4732 if (newvers != oldvers) {
4749static void GenerateTClass_GatherInnerIncludes(cling::Interpreter *interp,
TString &includes,
TClingClassInfo *info)
4753 const clang::ClassTemplateSpecializationDecl *templateCl
4754 = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(info->
GetDecl());
4756 for(
unsigned int i=0; i < templateCl->getTemplateArgs().
size(); ++i) {
4757 const clang::TemplateArgument &arg( templateCl->getTemplateArgs().get(i) );
4758 if (arg.getKind() == clang::TemplateArgument::Type) {
4761 if (!uType->isFundamentalType() && !uType->isEnumeralType()) {
4763 const clang::CXXRecordDecl *argdecl = uType->getAsCXXRecordDecl();
4766 TClingClassInfo subinfo(interp,*(argdecl->getASTContext().getRecordType(argdecl).getTypePtr()));
4767 GenerateTClass_GatherInnerIncludes(interp, includes, &subinfo);
4770 llvm::raw_string_ostream OS(Result);
4771 arg.print(argdecl->getASTContext().getPrintingPolicy(),OS);
4772 Warning(
"TCling::GenerateTClass",
"Missing header file for %s",OS.str().c_str());
4786 TClingClassInfo *info = (TClingClassInfo*)classinfo;
4787 if (!info || !info->
IsValid()) {
4788 Fatal(
"GenerateTClass",
"Requires a valid ClassInfo object");
4792 TClass *cl =
nullptr;
4793 std::string classname;
4797 Info(
"GenerateTClass",
"Will (try to) generate the compiled TClass for %s.",classname.c_str());
4801 GenerateTClass_GatherInnerIncludes(
fInterpreter,includes,info);
4807 Error(
"GenerateTClass",
"Even though the dictionary generation for %s seemed successful we can't find the TClass bootstrap!",classname.c_str());
4811 if (cl ==
nullptr) {
4813 cl =
new TClass(classinfo, version,
nullptr,
nullptr, -1, -1, silent);
4818 cl =
new TClass(classinfo, 1,
nullptr,
nullptr, -1, -1, silent);
4843 if (classes ==
nullptr || classes[0] == 0) {
4844 Error(
"TCling::GenerateDictionary",
"Cannot generate dictionary without passing classes.");
4848 std::vector<std::string> listClasses;
4850 const char* current = classes, *prev = classes;
4854 if (*current ==
';') {
4855 listClasses.push_back(std::string(prev, current - prev));
4858 else if (*(current + 1) == 0) {
4859 listClasses.push_back(std::string(prev, current + 1 - prev));
4863 std::vector<std::string> listIncludes;
4867 const char* current = includes, *prev = includes;
4871 if (*current ==
';') {
4872 listIncludes.push_back(std::string(prev, current - prev));
4875 else if (*(current + 1) == 0) {
4876 listIncludes.push_back(std::string(prev, current + 1 - prev));
4882 std::vector<std::string>(), std::vector<std::string>());
4906 if (
const ValueDecl* decl = (
const ValueDecl*)
d){
4909 if (hasIoName && ioName !=
name)
return nullptr;
4921 using namespace clang;
4923 DeclarationName DName = &SemaR.Context.Idents.get(
name);
4925 LookupResult
R(SemaR, DName, SourceLocation(), Sema::LookupOrdinaryName,
4926 RedeclarationKind::ForExternalRedeclaration);
4928 cling::utils::Lookup::Named(&SemaR,
R);
4930 LookupResult::Filter
F =
R.makeFilter();
4932 while (
F.hasNext()) {
4933 NamedDecl *D =
F.next();
4934 if (isa<VarDecl>(D) || isa<FieldDecl>(D) || isa<EnumConstantDecl>(D) ||
4935 isa<IndirectFieldDecl>(D))
4941 if (
R.isSingleResult())
4942 return R.getFoundDecl();
4954 const clang::Decl* possibleEnum =
nullptr;
4959 const clang::DeclContext* dc =
nullptr;
4960 if (
const clang::Decl* D = cci->
GetDecl()) {
4961 if (!(dc = dyn_cast<clang::NamespaceDecl>(D))) {
4962 dc = dyn_cast<clang::RecordDecl>(D);
4969 possibleEnum = cling::utils::Lookup::Tag(&
fInterpreter->getSema(),
name, dc);
4971 Error(
"TCling::GetEnum",
"DeclContext not found for %s .\n",
name);
4980 if (possibleEnum && (possibleEnum != (clang::Decl*)-1)
4981 && isa<clang::EnumDecl>(possibleEnum)) {
4982 return possibleEnum;
4992 if (!gv)
return nullptr;
4994 llvm::StringRef mangled_name = gv->getName();
5009 std::string scopename(demangled_name_c);
5010 free(demangled_name_c);
5016 std::string dataname;
5018 if (!strncmp(scopename.c_str(),
"typeinfo for ",
sizeof(
"typeinfo for ")-1)) {
5019 scopename.erase(0,
sizeof(
"typeinfo for ")-1);
5020 }
else if (!strncmp(scopename.c_str(),
"vtable for ",
sizeof(
"vtable for ")-1)) {
5021 scopename.erase(0,
sizeof(
"vtable for ")-1);
5024 std::string::size_type
pos = scopename.rfind(
'(');
5025 if (
pos != std::string::npos) {
5029 pos = scopename.rfind(
':');
5030 if (
pos != std::string::npos) {
5031 if ((
pos != 0) && (scopename[
pos-1] ==
':')) {
5032 dataname = scopename.substr(
pos+1);
5033 scopename.erase(
pos-1);
5037 dataname = scopename;
5045 if (scopename.size()) {
5051 d = gcl.GetDataMember(dataname.c_str());
5061 Error(
"GetDataMemberWithValue()",
"not implemented");
5071 Error(
"GetDataMemberAtAddr()",
"not implemented");
5081 const char* params,
Bool_t objectIsConst )
5093 func.
SetFunc(&gcl, method, params, &offset);
5095 TClingMethodInfo* mi = (TClingMethodInfo*) func.
FactoryMethod();
5099 return mangled_name;
5114 GetMethod(method,
proto, objectIsConst,
nullptr , mode).GetMangledName();
5117 return gcl.GetMethod(method,
proto, objectIsConst,
nullptr , mode).GetMangledName();
5126 const char* params,
Bool_t objectIsConst )
5138 func.
SetFunc(&gcl, method, params, &offset);
5157 f = gcl.GetMethod(method).GetDeclId();
5167 std::vector<DeclId_t>& res)
const
5170 clang::ASTContext& Ctx = S.Context;
5171 const clang::Decl* CtxDecl
5173 Ctx.getTranslationUnitDecl();
5174 auto RecDecl = llvm::dyn_cast<const clang::RecordDecl>(CtxDecl);
5175 const clang::DeclContext* DeclCtx = RecDecl;
5178 DeclCtx = dyn_cast<clang::NamespaceDecl>(CtxDecl);
5179 if (!DeclCtx)
return;
5181 clang::DeclarationName DName;
5186 if (RecDecl->getNameAsString() == funcname) {
5187 clang::QualType QT = Ctx.getTypeDeclType(RecDecl);
5188 DName = Ctx.DeclarationNames.getCXXConstructorName(Ctx.getCanonicalType(QT));
5189 }
else if (funcname[0] ==
'~' && RecDecl->getNameAsString() == funcname + 1) {
5190 clang::QualType QT = Ctx.getTypeDeclType(RecDecl);
5191 DName = Ctx.DeclarationNames.getCXXDestructorName(Ctx.getCanonicalType(QT));
5193 DName = &Ctx.Idents.get(funcname);
5196 DName = &Ctx.Idents.get(funcname);
5200 clang::LookupResult
R(S, DName, clang::SourceLocation(), Sema::LookupOrdinaryName,
5201 RedeclarationKind::NotForRedeclaration);
5202 R.suppressDiagnostics();
5203 S.LookupQualifiedName(
R,
const_cast<DeclContext*
>(DeclCtx));
5204 if (
R.empty())
return;
5206 res.reserve(res.size() + (
R.end() -
R.begin()));
5207 for (clang::LookupResult::iterator IR =
R.begin(), ER =
R.end();
5209 if (
const clang::FunctionDecl* FD
5210 = llvm::dyn_cast<const clang::FunctionDecl>(*IR)) {
5211 if (!FD->getDescribedFunctionTemplate()) {
5214 }
else if (
const auto *USD = llvm::dyn_cast<const clang::UsingShadowDecl>(*IR)) {
5216 if (llvm::isa<clang::FunctionDecl>(USD->getTargetDecl())) {
5237 GetMethod(method,
proto, objectIsConst,
nullptr , mode).InterfaceMethod();
5241 f = gcl.GetMethod(method,
proto, objectIsConst,
nullptr , mode).InterfaceMethod();
5263 f = gcl.GetMethod(method, params, objectIsConst,
nullptr ).GetDeclId();
5286 f = gcl.GetMethod(method,
proto, objectIsConst,
nullptr , mode).GetDeclId();
5305 f = gcl.GetFunctionTemplate(
name);
5351void TCling::Execute(
const char* function,
const char* params,
int* error)
5360 func.
SetFunc(&cl, function, params, &offset);
5376 const char* params,
Bool_t objectIsConst,
int* error)
5389 void* address = (
void*)((
Longptr_t)addr + offset);
5396 const char* params,
int* error)
5398 Execute(obj,cl,method,params,
false,error);
5413 Error(
"Execute",
"No method was defined");
5422 if (argc > nparms) {
5423 Error(
"Execute",
"Too many parameters to call %s, got %d but expected at most %d.",method->
GetName(),argc,nparms);
5426 if (nparms != argc) {
5436 Int_t firstDefault = -1;
5437 for (
Int_t i = 0; i < nparms; i ++) {
5444 if (firstDefault >= 0) {
5445 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);
5447 Error(
"Execute",
"Too few arguments to call %s, got only %d but expected %d.",method->
GetName(),argc,nparms);
5453 const char* listpar =
"";
5458 for (
Int_t i = 0; i < argc; i ++) {
5474 complete += nxtpar->
String();
5477 listpar = complete.
Data();
5497 void* address = (
void*)((
Longptr_t)addr + offset);
5504 const void* args[] ,
5509 Error(
"ExecuteWithArgsAndReturn",
"No method was defined");
5513 TClingMethodInfo* minfo = (TClingMethodInfo*) method->
fInfo;
5536 Warning(
"GetTopLevelMacroName",
"Must change return type!");
5583#if defined(R__MUST_REVISIT)
5584#if R__MUST_REVISIT(6,0)
5585 Warning(
"GetCurrentMacroName",
"Must change return type!");
5598 TTHREAD_TLS_DECL(std::string,t);
5600 if (!strstr(typeDesc,
"(*)(")) {
5601 const char *s = strchr(typeDesc,
' ');
5602 const char *template_start = strchr(typeDesc,
'<');
5603 if (!strcmp(typeDesc,
"long long")) {
5606 else if (!strncmp(typeDesc,
"unsigned ", s + 1 - typeDesc)) {
5613 else if (s && (template_start ==
nullptr || (s < template_start))) {
5623 auto l = t.length();
5624 while (
l > 0 && (t[
l - 1] ==
'*' || t[
l - 1] ==
'&'))
5632 assert(rootmapfile && *rootmapfile);
5634 llvm::StringRef libName = llvm::sys::path::filename(rootmapfile);
5635 libName.consume_back(
".rootmap");
5637 return !
gInterpreter->HasPCMForLibrary(libName.str().c_str());
5648 if (!(rootmapfile && *rootmapfile))
5655 const std::map<char, unsigned int> keyLenMap = {{
'c',6},{
'n',10},{
't',8},{
'h',7},{
'e',5},{
'v',4}};
5657 std::string rootmapfileNoBackslash(rootmapfile);
5659 std::replace(rootmapfileNoBackslash.begin(), rootmapfileNoBackslash.end(),
'\\',
'/');
5662 if (
fRootmapFiles->FindObject(rootmapfileNoBackslash.c_str()))
5666 std::string lineDirective = std::string(
"\n#line 2 \"Forward declarations from ") + rootmapfileNoBackslash +
"\"\n";
5668 std::ifstream file(rootmapfileNoBackslash);
5671 std::string lib_name;
5673 bool newFormat =
false;
5674 while (getline(file,
line,
'\n')) {
5675 if (!newFormat && (
line.compare(0, 8,
"Library.") == 0 ||
line.compare(0, 8,
"Declare.") == 0)) {
5681 if (
line.compare(0, 9,
"{ decls }") == 0) {
5684 while (getline(file,
line,
'\n')) {
5687 if (!uniqueString) {
5688 Error(
"ReadRootmapFile",
"Cannot handle \"{ decls }\" sections in custom rootmap file %s",
5689 rootmapfileNoBackslash.c_str());
5692 if (!lineDirective.empty())
5693 uniqueString->
Append(lineDirective);
5697 const char firstChar =
line[0];
5698 if (firstChar ==
'[') {
5700 auto brpos =
line.find(
']');
5701 if (brpos == string::npos)
5703 lib_name =
line.substr(1, brpos - 1);
5705 lib_name.erase(lib_name.find_last_not_of(
' ') + 1);
5706 lib_name.erase(0, lib_name.find_first_not_of(
' '));
5708 TString lib_nameTstr(lib_name.c_str());
5710 const char *lib = ((
TObjString *)tokens->
At(0))->GetName();
5711 const char *wlib =
gSystem->DynamicPathName(lib,
kTRUE);
5713 Info(
"ReadRootmapFile",
"%s: New section for %s", rootmapfile, lib_nameTstr.
Data());
5715 Info(
"ReadRootmapFile",
"%s: Section for %s (library does not exist)", rootmapfile, lib_nameTstr.
Data());
5721 auto keyLenIt = keyLenMap.find(firstChar);
5722 if (keyLenIt == keyLenMap.end())
5724 unsigned int keyLen = keyLenIt->second;
5726 const char *keyname =
line.c_str() + keyLen;
5728 Info(
"ReadRootmapFile",
"%s: class %s in %s", rootmapfile, keyname, lib_name.c_str());
5731 if (lib_name != isThere->
GetValue()) {
5732 if (firstChar ==
'n') {
5734 Info(
"ReadRootmapFile",
5735 "While processing %s, namespace %s was found to be associated to %s although it is already "
5737 rootmapfile, keyname, lib_name.c_str(), isThere->
GetValue());
5738 }
else if (firstChar ==
'h') {
5741 fMapfile->SetValue(keyname, lib_name.c_str());
5744 "While processing %s, %s %s was found to be associated to %s although it is already "
5746 rootmapfile,
line.substr(0, keyLen - 1).c_str(), keyname, lib_name.c_str(),
5751 Info(
"ReadRootmapFile",
"While processing %s, key %s was found to be already defined for %s",
5752 rootmapfile, keyname, lib_name.c_str());
5755 fMapfile->SetValue(keyname, lib_name.c_str());
5792 if (!
gSystem->Getenv(
"ROOTENV_NO_HOME")) {
5794 const char *s2 =
gSystem->PrependPathName(
gSystem->HomeDirectory(), temp_name);
5798 if (strcmp(
gSystem->HomeDirectory(),
gSystem->WorkingDirectory())) {
5808 fMapfile->IgnoreDuplicates(ignore);
5813 using namespace clang;
5815 class ExtVisibleStorageAdder:
public RecursiveASTVisitor<ExtVisibleStorageAdder>{
5821 ExtVisibleStorageAdder(std::unordered_set<const NamespaceDecl*>& nsSet): fNSSet(nsSet) {};
5822 bool VisitNamespaceDecl(NamespaceDecl* nsDecl) {
5827 nsDecl->setHasExternalVisibleStorage();
5828 fNSSet.insert(nsDecl);
5831 bool VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl* specDecl) {
5834 if (specDecl->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
5836 specDecl->setHasExternalLexicalStorage();
5848 std::unordered_set<const NamespaceDecl*>& fNSSet;
5895 for (
Int_t j = 0; j < i; j++) {
5903 void* dirp =
gSystem->OpenDirectory(
d);
5906 Info(
"LoadLibraryMap",
"%s",
d.Data());
5909 while ((
f1 =
gSystem->GetDirEntry(dirp))) {
5911 if (
f.EndsWith(
".rootmap")) {
5917 Info(
"LoadLibraryMap",
" rootmap file: %s", p.
Data());
5935 if (
f.BeginsWith(
"rootmap")) {
5940 Warning(
"LoadLibraryMap",
"please rename %s to end with \".rootmap\"", p.
Data());
5953 if (rootmapfile && *rootmapfile) {
5960 else if (res == -3) {
5965 fMapfile->IgnoreDuplicates(ignore);
5970 while ((rec = (
TEnvRec*) next())) {
5972 if (!strncmp(cls.
Data(),
"Library.", 8) && cls.
Length() > 8) {
5980 const char* lib = ((
TObjString*)tokens->
At(0))->GetName();
5989 const char* wlib =
gSystem->DynamicPathName(lib,
kTRUE);
5991 Info(
"LoadLibraryMap",
"class %s in %s", cls.
Data(), wlib);
5994 Info(
"LoadLibraryMap",
"class %s in %s (library does not exist)", cls.
Data(), lib);
6000 else if (!strncmp(cls.
Data(),
"Declare.", 8) && cls.
Length() > 8) {
6010 cling::Transaction* T =
nullptr;
6012 assert(cling::Interpreter::kSuccess == compRes &&
"A declaration in a rootmap could not be compiled");
6014 if (compRes!=cling::Interpreter::kSuccess){
6016 "Problems in %s declaring '%s' were encountered.", rootmapfile, uniqueString.
Data()) ;
6021 for (
auto declIt = T->decls_begin(); declIt < T->decls_end(); ++declIt) {
6022 if (declIt->m_DGR.isSingleDecl()) {
6023 if (Decl* D = declIt->m_DGR.getSingleDecl()) {
6024 if (clang::isa<TagDecl>(D) || clang::isa<NamespaceDecl>(D)) {
6025 evsAdder.TraverseDecl(D);
6060 for (
Int_t ilib = 0; ilib < nrSharedLibs; ilib++) {
6062 const TString sharedLibBaseStr =
gSystem->BaseName(sharedLibStr);
6067 TString rootMapBaseStr = sharedLibBaseStr;
6068 if (sharedLibBaseStr.
EndsWith(
".dll")) {
6071 else if (sharedLibBaseStr.
EndsWith(
".DLL")) {
6074 else if (sharedLibBaseStr.
EndsWith(
".so")) {
6077 else if (sharedLibBaseStr.
EndsWith(
".sl")) {
6080 else if (sharedLibBaseStr.
EndsWith(
".dl")) {
6083 else if (sharedLibBaseStr.
EndsWith(
".a")) {
6087 Error(
"ReloadAllSharedLibraryMaps",
"Unknown library type %s", sharedLibBaseStr.
Data());
6091 rootMapBaseStr +=
".rootmap";
6092 const char* rootMap =
gSystem->Which(
gSystem->GetDynamicPath(), rootMapBaseStr);
6094 Error(
"ReloadAllSharedLibraryMaps",
"Could not find rootmap %s in path", rootMapBaseStr.
Data());
6101 Error(
"ReloadAllSharedLibraryMaps",
"Error loading map %s", rootMap);
6122 const TString sharedLibBaseStr =
gSystem->BaseName(sharedLibStr);
6136 if (!
fMapfile || !library || !*library) {
6139 TString libname(library);
6140 Ssiz_t idx = libname.Last(
'.');
6142 libname.Remove(idx);
6144 size_t len = libname.Length();
6149 while ((rec = (TEnvRec *) next())) {
6158 TObjArray* tokens = libs.
Tokenize(delim);
6159 const char* lib = ((TObjString *)tokens->
At(0))->GetName();
6160 if (!strncmp(cls.
Data(),
"Library.", 8) && cls.
Length() > 8) {
6169 if (!strncmp(lib, libname.Data(), len)) {
6170 if (
fMapfile->GetTable()->Remove(rec) ==
nullptr) {
6171 Error(
"UnloadLibraryMap",
"entry for <%s, %s> not found in library map table", cls.
Data(), lib);
6179 TString library_rootmap(library);
6180 if (!library_rootmap.EndsWith(
".rootmap"))
6181 library_rootmap.Append(
".rootmap");
6232 if (
err)
return nullptr;
6234 free(demangled_name);
6252 std::string demangled_name(demangled_name_c);
6253 free(demangled_name_c);
6266 result =
AutoLoad(demangled_name.c_str(), knowDictNotLoaded);
6279 TString deplibs =
gCling->GetClassSharedLibs(cls);
6282 TObjArray* tokens = deplibs.
Tokenize(delim);
6284 const char* deplib = ((TObjString*)tokens->
At(i))->GetName();
6285 if (
gROOT->LoadClass(cls, deplib) == 0) {
6287 gCling->Info(
"TCling::AutoLoad",
6288 "loaded dependent library %s for %s", deplib, cls);
6292 gCling->Error(
"TCling::AutoLoad",
6293 "failure loading dependent library %s for %s",
6297 const char* lib = ((TObjString*)tokens->
At(0))->GetName();
6298 if (lib && lib[0]) {
6299 if (
gROOT->LoadClass(cls, lib) == 0) {
6301 gCling->Info(
"TCling::AutoLoad",
6302 "loaded library %s for %s", lib, cls);
6307 gCling->Error(
"TCling::AutoLoad",
6308 "failure loading library %s for %s", lib, cls);
6323 bool nameIsNormalized)
6329 if (!visited.insert(std::string(cls)).second)
6339 for (
auto element :
proto->GetData()) {
6340 if (element->IsBasic())
6342 const char *subtypename = element->GetTypeName();
6358 if (classinfo &&
gInterpreter->ClassInfo_IsValid(classinfo)
6362 while (
gInterpreter->DataMemberInfo_Next(memberinfo)) {
6395 Info(
"TCling::AutoLoad",
"Explicitly disabled (the class name is %s)", cls);
6404 if (!knowDictNotLoaded &&
gClassTable->GetDictNorm(cls)) {
6415 Info(
"TCling::AutoLoad",
6416 "Trying to autoload for %s", cls);
6421 Info(
"TCling::AutoLoad",
6422 "Disabled due to gROOT or gInterpreter being invalid/not ready (the class name is %s)", cls);
6443 std::unordered_set<std::string> visited;
6452 cling::Interpreter *interpreter)
6454 std::string code = gNonInterpreterClassDef ;
6461 code += (
"#include \"");
6465 code += (
"#ifdef __ROOTCLING__\n"
6466 "#undef __ROOTCLING__\n"
6467 + gInterpreterClassDef +
6470 cling::Interpreter::CompilationResult cr;
6476 Sema &SemaR = interpreter->getSema();
6478 clangDiagSuppr diagSuppr(SemaR.getDiagnostics());
6480 #if defined(R__MUST_REVISIT)
6481 #if R__MUST_REVISIT(6,2)
6482 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
6486 cr = interpreter->parseForModule(code);
6504 Int_t nHheadersParsed = 0;
6505 unsigned long offset = 0;
6506 if (strncmp(cls,
"const ", 6) == 0) {
6511 bool skipFirstEntry =
false;
6512 std::vector<std::string> autoparseKeys;
6513 if (strchr(cls,
'<')) {
6519 if (!autoparseKeys.empty() && !autoparseKeys[0].empty()) {
6524 TString templateName(autoparseKeys[0]);
6525 auto tokens = templateName.
Tokenize(
"::");
6526 clang::NamedDecl* previousScopeAsNamedDecl =
nullptr;
6527 clang::DeclContext* previousScopeAsContext =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
6529 previousScopeAsContext =
fInterpreter->getSema().getStdNamespace();
6531 for (
Int_t tk = 0; tk < nTokens; ++tk) {
6533 auto scopeName = ((
TObjString*) scopeObj)->String().Data();
6534 previousScopeAsNamedDecl = cling::utils::Lookup::Named(&
fInterpreter->getSema(), scopeName, previousScopeAsContext);
6536 if ((clang::NamedDecl*)-1 == previousScopeAsNamedDecl)
break;
6537 previousScopeAsContext = llvm::dyn_cast_or_null<clang::DeclContext>(previousScopeAsNamedDecl);
6538 if (!previousScopeAsContext)
break;
6542 if ((clang::NamedDecl*)-1 != previousScopeAsNamedDecl) {
6543 if (
auto templateDecl = llvm::dyn_cast_or_null<clang::ClassTemplateDecl>(previousScopeAsNamedDecl)) {
6544 if (
auto templatedDecl = templateDecl->getTemplatedDecl()) {
6545 skipFirstEntry = templatedDecl->hasDefinition();
6552 if (topLevel) autoparseKeys.emplace_back(cls);
6554 for (
const auto & apKeyStr : autoparseKeys) {
6555 if (skipFirstEntry) {
6556 skipFirstEntry=
false;
6559 if (apKeyStr.empty())
continue;
6560 const char *apKey = apKeyStr.c_str();
6564 Info(
"TCling::AutoParse",
6565 "Starting autoparse for %s\n", apKey);
6570 const cling::Transaction *T =
fInterpreter->getCurrentTransaction();
6572 auto const &hNamesPtrs = iter->second;
6574 Info(
"TCling::AutoParse",
6575 "We can proceed for %s. We have %s headers.", apKey, std::to_string(hNamesPtrs.size()).c_str());
6577 for (
auto & hName : hNamesPtrs) {
6579 if (0 !=
fPayloads.count(normNameHash)) {
6580 float initRSSval=0.f, initVSIZEval=0.f;
6582 (void) initVSIZEval;
6585 "Parsing full payload for %s", apKey);
6592 if (cRes != cling::Interpreter::kSuccess) {
6593 if (hName[0] ==
'\n')
6594 Error(
"AutoParse",
"Error parsing payload code for class %s with content:\n%s", apKey, hName);
6603 Info(
"Autoparse",
">>> RSS key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initRSSval, endRSSval, endRSSval-initRSSval);
6604 Info(
"Autoparse",
">>> VSIZE key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initVSIZEval, endVSIZEval, endVSIZEval-initVSIZEval);
6610 "Parsing single header %s", hName);
6613 if (cRes != cling::Interpreter::kSuccess) {
6614 Error(
"AutoParse",
"Error parsing headerfile %s for class %s.", hName, apKey);
6626 if (strchr(apKey,
'<')) {
6633 if (nHheadersParsed) {
6637 Info(
"AutoParse",
"Parsed %d headers for %s", nHheadersParsed, cls);
6639 return nHheadersParsed;
6649 if (llvm::StringRef(cls).
contains(
"(lambda)"))
6663 Info(
"TCling::AutoParse",
6664 "Trying to autoparse for %s", cls);
6671 ROOT::Internal::ParsingStateRAII parsingStateRAII(
fInterpreter->getParser(),
6686 return nHheadersParsed > 0 ? 1 : 0;
6694 StringRef errMsg(errmessage);
6695 if (errMsg.contains(
"undefined symbol: ")) {
6697 std::string mangled_name = std::string(errMsg.split(
"undefined symbol: ").second);
6698 void* res = ((
TCling*)
gCling)->LazyFunctionCreatorAutoload(mangled_name);
6699 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
6700 if (res && DLM && (DLM->loadLibrary(libStem, permanent, resolved) == cling::DynamicLibraryManager::kLoadLibSuccess))
6719 if (
void* Addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(dlsym_mangled_name))
6722 const cling::DynamicLibraryManager &DLM = *
GetInterpreterImpl()->getDynamicLibraryManager();
6725 auto LibLoader = [](
const std::string& LibName) ->
bool {
6726 if (
gSystem->Load(LibName.c_str(),
"",
false) < 0) {
6727 ::Error(
"TCling__LazyFunctionCreatorAutoloadForModule",
6728 "Failed to load library %s", LibName.c_str());
6734 std::string libName = DLM.searchLibrariesForSymbol(mangled_name,
6737 assert(!llvm::StringRef(libName).starts_with(
"libNew") &&
"We must not resolve symbols from libNew!");
6739 if (libName.empty())
6742 if (!LibLoader(libName))
6746 return llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(dlsym_mangled_name);
6766 const NamedDecl *oldDef = llvm::dyn_cast_or_null<NamedDecl>(cci->
GetDecl());
6767 if (!oldDef || (def && def != oldDef)) {
6776 Error(
"RefreshClassInfo",
"Should not need to update the classInfo a non type decl: %s", oldDef->getNameAsString().c_str());
6782 if (strncmp(cl->
GetName(),
"tuple<",strlen(
"tuple<"))==0) {
6797 if (!alias && def !=
nullptr)
6801 if (((TClingClassInfo *)cl->
fClassInfo)->IsValid()) {
6819 const TagDecl *td = dyn_cast<TagDecl>(ND);
6820 const NamespaceDecl *ns = dyn_cast<NamespaceDecl>(ND);
6821 const NamedDecl *canon =
nullptr;
6824 TagDecl* tdDef =
nullptr;
6826 canon = tdDef = td->getDefinition();
6830 if (!tdDef->isCompleteDefinition() || llvm::isa<clang::FunctionDecl>(tdDef->getDeclContext())) {
6836 auto declName = tdDef->getNameAsString();
6847 clang::QualType
type(tdDef->getTypeForDecl(), 0);
6850 canon = ns->getCanonicalDecl();
6851 name = ND->getQualifiedNameAsString();
6853 name = ND->getQualifiedNameAsString();
6902 std::set<TClass*> modifiedTClasses;
6907 bool isTUTransaction =
false;
6908 if (!
T.empty() &&
T.decls_begin() + 1 ==
T.decls_end() && !
T.hasNestedTransactions()) {
6909 clang::Decl* FirstDecl = *(
T.decls_begin()->m_DGR.begin());
6910 if (llvm::isa<clang::TranslationUnitDecl>(FirstDecl)) {
6913 isTUTransaction =
true;
6917 std::set<const void*> TransactionDeclSet;
6918 if (!isTUTransaction &&
T.decls_end() -
T.decls_begin()) {
6919 const clang::Decl* WrapperFD =
T.getWrapperFD();
6920 for (cling::Transaction::const_iterator
I =
T.decls_begin(), E =
T.decls_end();
6922 if (
I->m_Call != cling::Transaction::kCCIHandleTopLevelDecl
6923 &&
I->m_Call != cling::Transaction::kCCIHandleTagDeclDefinition)
6926 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
6927 DE =
I->m_DGR.end(); DI != DE; ++DI) {
6928 if (*DI == WrapperFD)
6930 TransactionDeclSet.insert(*DI);
6931 ((
TCling*)
gCling)->HandleNewDecl(*DI,
false, modifiedTClasses);
6938 for (cling::Transaction::const_iterator
I =
T.deserialized_decls_begin(),
6939 E =
T.deserialized_decls_end();
I != E; ++
I) {
6940 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
6941 DE =
I->m_DGR.end(); DI != DE; ++DI)
6942 if (TransactionDeclSet.find(*DI) == TransactionDeclSet.end()) {
6958 std::vector<TClass*> modifiedTClassesDiff(modifiedTClasses.size());
6959 std::vector<TClass*>::iterator it;
6960 it = set_difference(modifiedTClasses.begin(), modifiedTClasses.end(),
6963 modifiedTClassesDiff.begin());
6964 modifiedTClassesDiff.resize(it - modifiedTClassesDiff.begin());
6967 ((
TCling*)
gCling)->GetModTClasses().insert(modifiedTClassesDiff.begin(),
6968 modifiedTClassesDiff.end());
6969 for (std::vector<TClass*>::const_iterator
I = modifiedTClassesDiff.begin(),
6970 E = modifiedTClassesDiff.end();
I != E; ++
I) {
6972 if (!
gROOT->GetListOfClasses()->FindObject(*
I)) {
6989 auto Lists = std::make_tuple((TListOfDataMembers *)
gROOT->GetListOfGlobals(),
6990 (TListOfFunctions *)
gROOT->GetListOfGlobalFunctions(),
6991 (TListOfFunctionTemplates *)
gROOT->GetListOfFunctionTemplates(),
6992 (TListOfEnums *)
gROOT->GetListOfEnums());
6994 cling::Transaction::const_nested_iterator iNested =
T.nested_begin();
6995 for (cling::Transaction::const_iterator
I =
T.decls_begin(), E =
T.decls_end();
6997 if (
I->m_Call == cling::Transaction::kCCIHandleVTable)
6999 if (
I->m_Call == cling::Transaction::kCCINone) {
7005 for (
auto &D :
I->m_DGR)
7013 auto Lists = std::make_tuple((TListOfDataMembers *)
gROOT->GetListOfGlobals(),
7014 (TListOfFunctions *)
gROOT->GetListOfGlobalFunctions(),
7015 (TListOfFunctionTemplates *)
gROOT->GetListOfFunctionTemplates(),
7016 (TListOfEnums *)
gROOT->GetListOfEnums());
7031 if (D->isFromASTFile())
7039 if (isa<VarDecl>(D) || isa<FieldDecl>(D) || isa<EnumConstantDecl>(D)) {
7045 }
else if (isa<FunctionDecl>(D)) {
7047 }
else if (isa<FunctionTemplateDecl>(D)) {
7049 }
else if (isa<EnumDecl>(D)) {
7060 }
else if (isa<RecordDecl>(D) || isa<NamespaceDecl>(D)) {
7061 if (isa<RecordDecl>(D) && !cast<RecordDecl>(D)->isCompleteDefinition())
7064 std::vector<TClass *> Classes;
7067 for (
auto &C : Classes) {
7072 for (
auto &
I : cast<DeclContext>(D)->decls())
7076 if (D->getKind() != Decl::Namespace || cast<NamespaceDecl>(D)->isFirstDecl())
7077 C->ResetClassInfo();
7089 std::size_t normNameHash = triter->second;
7095 auto const &hNamesPtrs = iter->second;
7096 for (
auto &hName : hNamesPtrs) {
7098 Info(
"TransactionRollback",
7099 "Restoring ability to autoaparse: %s", hName);
7136 using namespace clang;
7137 if (
const Decl *D = LH.findScope(cls, cling::LookupHelper::NoDiagnostics,
7139 if (!D->isFromASTFile()) {
7141 Warning(
"GetClassSharedLibsForModule",
"Decl found for %s is not part of a module", cls);
7144 class ModuleCollector :
public ConstDeclVisitor<ModuleCollector> {
7145 llvm::DenseSet<Module *> &m_TopLevelModules;
7148 ModuleCollector(llvm::DenseSet<Module *> &TopLevelModules) : m_TopLevelModules(TopLevelModules) {}
7149 void Collect(
const Decl *D) { Visit(D); }
7151 void VisitDecl(
const Decl *D)
7161 if (!D->hasOwningModule())
7163 if (Module *M = D->getOwningModule()->getTopLevelModule())
7164 m_TopLevelModules.insert(M);
7167 void VisitTemplateArgument(
const TemplateArgument &TA)
7169 switch (TA.getKind()) {
7170 case TemplateArgument::Null:
7171 case TemplateArgument::Integral:
7172 case TemplateArgument::Pack:
7173 case TemplateArgument::NullPtr:
7174 case TemplateArgument::StructuralValue:
7175 case TemplateArgument::Expression:
7176 case TemplateArgument::Template:
7177 case TemplateArgument::TemplateExpansion:
return;
7178 case TemplateArgument::Type:
7179 if (
const TagType *TagTy = dyn_cast<TagType>(TA.getAsType()))
7180 return Visit(TagTy->getDecl());
7182 case TemplateArgument::Declaration:
return Visit(TA.getAsDecl());
7184 llvm_unreachable(
"Invalid TemplateArgument::Kind!");
7187 void VisitClassTemplateSpecializationDecl(
const ClassTemplateSpecializationDecl *CTSD)
7189 if (CTSD->getOwningModule())
7192 VisitDecl(CTSD->getSpecializedTemplate());
7193 const TemplateArgumentList &ArgList = CTSD->getTemplateArgs();
7194 for (
const TemplateArgument *Arg = ArgList.data(), *ArgEnd = Arg + ArgList.size(); Arg != ArgEnd; ++Arg) {
7195 VisitTemplateArgument(*Arg);
7200 llvm::DenseSet<Module *> TopLevelModules;
7201 ModuleCollector
m(TopLevelModules);
7204 for (
auto M : TopLevelModules) {
7207 if (!M->LinkLibraries.size())
7210 if (M->Name ==
"Core" && skipCore)
7212 assert(M->LinkLibraries.size() == 1);
7213 if (!result.empty())
7215 result += M->LinkLibraries[0].Library;
7238 llvm::StringRef className = cls;
7244 if (className.contains(
"(lambda)"))
7248 cling::LookupHelper &LH =
fInterpreter->getLookupHelper();
7250 if (!libs.empty()) {
7256 if (!cls || !*cls) {
7261 TEnvRec* libs_record =
nullptr;
7262 libs_record =
fMapfile->Lookup(cls);
7264 const char* libs = libs_record->
GetValue();
7265 return (*libs) ? libs :
nullptr;
7272 c.ReplaceAll(
"::",
"@@");
7275 c.ReplaceAll(
" ",
"-");
7279 TEnvRec* libs_record =
nullptr;
7282 const char* libs = libs_record->
GetValue();
7283 return (*libs) ? libs :
nullptr;
7297 cling::Interpreter *interp,
7298 bool skipLoadedLibs =
true)
7301 if (!llvm::sys::path::is_absolute(lib)) {
7302 if (!
gSystem->FindDynamicLibrary(LibFullPath,
true)) {
7303 Error(
"TCling__GetSharedLibImmediateDepsSlow",
"Cannot find library '%s'", lib.c_str());
7307 assert(llvm::sys::fs::exists(lib) &&
"Must exist!");
7308 lib = llvm::sys::path::filename(lib).str();
7311 auto ObjF = llvm::object::ObjectFile::createObjectFile(LibFullPath.
Data());
7313 Warning(
"TCling__GetSharedLibImmediateDepsSlow",
"Failed to read object file %s", lib.c_str());
7317 llvm::object::ObjectFile *BinObjFile = ObjF.get().getBinary();
7319 std::set<string> DedupSet;
7320 std::string Result = lib +
' ';
7321 for (
const auto &S : BinObjFile->symbols()) {
7322 uint32_t Flags = llvm::cantFail(S.getFlags());
7324 if (!(Flags & llvm::object::SymbolRef::SF_Undefined))
7328 if (Flags & llvm::object::SymbolRef::SF_Weak)
7330 llvm::Expected<StringRef> SymNameErr = S.getName();
7332 Warning(
"GetSharedLibDepsForModule",
"Failed to read symbol");
7335 llvm::StringRef SymName = SymNameErr.
get();
7336 if (SymName.empty())
7339 if (BinObjFile->isELF()) {
7343 if (SymName.contains(
"@GLIBCXX") || SymName.contains(
"@CXXABI") ||
7344 SymName.contains(
"@GLIBC") || SymName.contains(
"@GCC"))
7352 static constexpr llvm::StringRef RegisterClasses(
"_Jv_RegisterClasses");
7353 static constexpr llvm::StringRef RegisterCloneTable(
"_ITM_registerTMCloneTable");
7354 static constexpr llvm::StringRef DeregisterCloneTable(
"_ITM_deregisterTMCloneTable");
7355 if (SymName == RegisterClasses ||
7356 SymName == RegisterCloneTable ||
7357 SymName == DeregisterCloneTable)
7362 if (skipLoadedLibs) {
7364 if (llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(SymNameForDlsym))
7369 std::string found = interp->getDynamicLibraryManager()->searchLibrariesForSymbol(SymName,
false);
7375 if (!found.empty()) {
7376 std::string cand = llvm::sys::path::filename(found).str();
7377 if (!DedupSet.insert(cand).second)
7380 Result += cand +
' ';
7390 llvm::SmallString<256> rootmapName;
7391 if (!lib.starts_with(
"lib"))
7392 rootmapName.append(
"lib");
7394 rootmapName.append(llvm::sys::path::filename(lib));
7395 llvm::sys::path::replace_extension(rootmapName,
"rootmap");
7397 if (
gCling->GetRootMapFiles()->FindObject(rootmapName.c_str()))
7401 llvm::StringRef rootmapNameNoLib = rootmapName.str();
7402 if (rootmapNameNoLib.consume_front(
"lib"))
7403 return gCling->GetRootMapFiles()->FindObject(rootmapNameNoLib.data());
7410 if (
gCling->HasPCMForLibrary(lib.data()))
7426 if (llvm::sys::path::is_absolute(lib) && !llvm::sys::fs::exists(lib))
7430 llvm::SmallString<512> rootmapName(lib);
7431 llvm::sys::path::replace_extension(rootmapName,
"rootmap");
7432 if (llvm::sys::fs::exists(rootmapName)) {
7434 Info(
"Load",
"loading %s", rootmapName.c_str());
7441 Warning(
"TCling::GetSharedLibDeps",
"Precomputed dependencies available but scanning '%s'", lib);
7446 if (!libs.empty()) {
7452 if (!
fMapfile || !lib || !lib[0]) {
7462 size_t len = libname.
Length();
7463 while ((rec = (
TEnvRec*) next())) {
7464 const char* libs = rec->
GetValue();
7465 if (!strncmp(libs, libname.
Data(), len) && strlen(libs) >= len
7466 && (!libs[len] || libs[len] ==
' ' || libs[len] ==
'.')) {
7479#if defined(R__MUST_REVISIT)
7480#if R__MUST_REVISIT(6,2)
7481 Warning(
"IsErrorMessagesEnabled",
"Interface not available yet.");
7493#if defined(R__MUST_REVISIT)
7494#if R__MUST_REVISIT(6,2)
7495 Warning(
"SetErrorMessages",
"Interface not available yet.");
7511 llvm::SmallVector<std::string, 10> includePaths;
7513 fInterpreter->GetIncludePaths(includePaths,
false,
true);
7514 if (
const size_t nPaths = includePaths.size()) {
7515 assert(!(nPaths & 1) &&
"GetIncludePath, number of paths and options is not equal");
7517 for (
size_t i = 0; i < nPaths; i += 2) {
7522 if (includePaths[i] !=
"-I")
7556 assert(fout !=
nullptr &&
"DisplayIncludePath, 'fout' parameter is null");
7558 llvm::SmallVector<std::string, 10> includePaths;
7560 fInterpreter->GetIncludePaths(includePaths,
false,
true);
7561 if (
const size_t nPaths = includePaths.size()) {
7562 assert(!(nPaths & 1) &&
"DisplayIncludePath, number of paths and options is not equal");
7564 std::string allIncludes(
"include path:");
7565 for (
size_t i = 0; i < nPaths; i += 2) {
7567 allIncludes += includePaths[i];
7569 if (includePaths[i] !=
"-I")
7571 allIncludes += includePaths[i + 1];
7574 fprintf(fout,
"%s\n", allIncludes.c_str());
7594#if defined(R__MUST_REVISIT)
7595#if R__MUST_REVISIT(6,2)
7596 Warning(
"GenericError",
"Interface not available yet.");
7624#if defined(R__MUST_REVISIT)
7625#if R__MUST_REVISIT(6,2)
7626 Warning(
"GetSecurityError",
"Interface not available yet.");
7639 cling::Interpreter::CompilationResult compRes;
7641 return compRes == cling::Interpreter::kFailure;
7660 TTHREAD_TLS_DECL(std::string,buffer);
7662 return buffer.c_str();
7743#if defined(R__MUST_REVISIT)
7744#if R__MUST_REVISIT(6,2)
7745 Warning(
"SetErrmsgcallback",
"Interface not available yet.");
7754 &
fInterpreter->getDiagnostics().getDiagnosticOptions(),
7756 [] (clang::DiagnosticsEngine::Level Level,
const std::string &
Info) {
7757 if (Level == clang::DiagnosticsEngine::Warning) {
7758 ::Warning(
"cling",
"%s", Info.c_str());
7759 }
else if (Level == clang::DiagnosticsEngine::Error
7760 || Level == clang::DiagnosticsEngine::Fatal) {
7766 fInterpreter->replaceDiagnosticConsumer(consumer,
true);
7768 fInterpreter->replaceDiagnosticConsumer(
nullptr);
7787 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
7788 std::string canonical = DLM->lookupLibrary(path);
7789 if (canonical.empty()) {
7793 cling::Interpreter::CompilationResult compRes;
7795 return compRes == cling::Interpreter::kFailure;
7799 return std::unique_ptr<TInterpreterValue>(
new TClingValue);
7806 std::vector<std::string>& completions)
7819 return compRes!=cling::Interpreter::kSuccess ? 0 : 1 ;
7826 using namespace cling;
7840 if (value.isValid() && value.needsManagedAllocation()) {
7861 auto iSpecObj = iSpecObjMap->second.find(Name);
7862 if (iSpecObj != iSpecObjMap->second.end()) {
7864 return iSpecObj->second;
7871 ASTContext&
C = SemaR.getASTContext();
7872 Preprocessor &PP = SemaR.getPreprocessor();
7873 Parser& P =
const_cast<Parser&
>(
fInterpreter->getParser());
7874 Preprocessor::CleanupAndRestoreCacheRAII cleanupRAII(PP);
7875 Parser::ParserCurTokRestoreRAII savedCurToken(P);
7878 Token& Tok =
const_cast<Token&
>(P.getCurToken());
7879 Tok.setKind(tok::semi);
7885 Sema::ContextAndScopeRAII pushedDCAndS(SemaR,
C.getTranslationUnitDecl(),
7888 TObject* specObj =
gROOT->FindSpecialObject(Name, LookupCtx);
7891 Error(
"GetObjectAddress",
"Got a special object without LookupCtx!");
7905 clang::CXXRecordDecl* klass)
const
7907 using namespace clang;
7908 ASTContext& Ctx = klass->getASTContext();
7909 FriendDecl::FriendUnion friendUnion(function);
7912 FriendDecl* friendDecl = FriendDecl::Create(Ctx, klass, sl, friendUnion, sl);
7913 klass->pushFriendDecl(friendDecl);
7927 if (func)
return ((
TClingCallFunc*)func)->GetDecl()->getCanonicalDecl();
7998 f->Exec(address, &val);
8006 f->ExecWithReturn(address,
ret);
8012 const void* args[] ,
8017 f->ExecWithArgsAndReturn(address, args, nargs,
ret);
8025 return f->ExecInt(address);
8033 return f->ExecInt64(address);
8041 return f->ExecDouble(address);
8064 return (MethodInfo_t*)
f->FactoryMethod();
8072 f->IgnoreExtraArgs(ignore);
8089 return f->IsValid();
8098 return f->IFacePtr();
8162 f->SetArgArray(paramArr, nparam);
8179 f->SetFunc(ci, method, params, offset);
8188 f->SetFunc(ci, method, params, objectIsConst, offset);
8206 f->SetFuncProto(ci, method,
proto, offset, mode);
8216 f->SetFuncProto(ci, method,
proto, objectIsConst, offset, mode);
8226 llvm::SmallVector<clang::QualType, 4> funcProto;
8227 for (std::vector<TypeInfo_t*>::const_iterator iter =
proto.begin(), end =
proto.end();
8228 iter != end; ++iter) {
8229 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
8231 f->SetFuncProto(ci, method, funcProto, offset, mode);
8239 TClingCallFunc*
f = (TClingCallFunc*) func;
8240 TClingClassInfo* ci = (TClingClassInfo*) info;
8241 llvm::SmallVector<clang::QualType, 4> funcProto;
8242 for (std::vector<TypeInfo_t*>::const_iterator iter =
proto.begin(), end =
proto.end();
8243 iter != end; ++iter) {
8244 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
8246 f->SetFuncProto(ci, method, funcProto, objectIsConst, offset, mode);
8251 TClingCallFunc *
f = (TClingCallFunc *)func;
8252 std::string wrapper_name;
8253 std::string wrapper;
8254 f->get_wrapper_code(wrapper_name, wrapper);
8281 const clang::DeclContext *ctxt =
nullptr;
8283 ctxt = clang::Decl::castToDeclContext(((
TClingClassInfo*)info)->GetDecl());
8285 ctxt =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
8290 const clang::Decl *decl =
reinterpret_cast<const clang::Decl*
>(declid);
8294 const clang::DeclContext *declDC = decl->getDeclContext();
8297 if (declDC->isTransparentContext()) {
8298 declDC = declDC->getParent();
8301 if (
const auto *declRD = llvm::dyn_cast<clang::RecordDecl>(declDC)) {
8302 if (declRD->isAnonymousStructOrUnion()) {
8303 declDC = declRD->getParent();
8307 if (
const auto *declNS = llvm::dyn_cast<clang::NamespaceDecl>(declDC)) {
8308 if (declNS->isAnonymousNamespace() || declNS->isInlineNamespace()) {
8309 declDC = declNS->getParent();
8316 return declDC->Equals(ctxt);
8427 TClinginfo->
Init(tagnum);
8500 return TClinginfo->
Next();
8548 return TClinginfo->
Size();
8556 return TClinginfo->
Tagnum();
8572 TTHREAD_TLS_DECL(std::string,output);
8574 return output.c_str();
8582 return TClinginfo->
Name();
8590 return TClinginfo->
Title();
8627 ClassInfo_t* base)
const
8640 return TClinginfo->
Next();
8648 return TClinginfo->
Next(onlyDirect);
8656 return TClinginfo->
Offset(address, isDerivedObject);
8669 return TClinginfo->
GetBaseOffset(TClinginfoBase, address, isDerivedObject);
8685 return (ClassInfo_t *)TClinginfo->
GetBase();
8693 return TClinginfo->
Tagnum();
8701 TTHREAD_TLS_DECL(std::string,output);
8703 return output.c_str();
8711 return TClinginfo->
Name();
8756 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
8757 const clang::ValueDecl* vd = llvm::dyn_cast_or_null<clang::ValueDecl>(decl);
8790 return TClinginfo->
Next();
8798 return TClinginfo->
Offset();
8846 return TClinginfo->
Name();
8854 return TClinginfo->
Title();
8861 TTHREAD_TLS_DECL(std::string,result);
8865 return result.c_str();
8872 Decl* decl =
static_cast<Decl*
>(
const_cast<void*
>(declId));
8873 ASTContext &C = decl->getASTContext();
8874 decl->addAttr(AnnotateAttr::CreateImplicit(C, attribute,
nullptr, 0));
8885 cling::Interpreter &interp,
8888 const clang::TypeDecl* td = llvm::dyn_cast<clang::TypeDecl>(decl->getDeclContext());
8891 clang::QualType qualType(td->getTypeForDecl(),0);
8893 unsigned int level = 0;
8894 for(
size_t cursor =
name.length()-1; cursor != 0; --cursor) {
8895 if (
name[cursor] ==
'>') ++level;
8896 else if (
name[cursor] ==
'<' && level) --level;
8897 else if (level == 0 &&
name[cursor] ==
':') {
8898 name.erase(0,cursor+1);
8910 const auto *FD = llvm::dyn_cast<clang::FunctionDecl>(decl);
8911 if (
const auto *USD = llvm::dyn_cast<clang::UsingShadowDecl>(decl)) {
8912 FD = llvm::dyn_cast<clang::FunctionDecl>(USD->getTargetDecl());
8915 Error(
"GetFunctionName",
"NULL Decl!");
8922 if (llvm::isa<clang::CXXConstructorDecl>(FD))
8926 }
else if (llvm::isa<clang::CXXDestructorDecl>(decl))
8929 output.insert(output.begin(),
'~');
8931 llvm::raw_string_ostream stream(output);
8932 auto printPolicy = decl->getASTContext().getPrintingPolicy();
8934 printPolicy.AnonymousTagLocations =
false;
8935 FD->getNameForDiagnostic(stream, printPolicy,
false);
8965 return (FuncTempInfo_t*)
const_cast<void*
>(declid);
8976 return (FuncTempInfo_t*)ft_info;
8987 return t_info !=
nullptr;
8996 if (!ft_info)
return 0;
8997 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
8998 return ft->getTemplateParameters()->size();
9007 if (!ft_info)
return 0;
9008 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
9009 return ft->getTemplateParameters()->getMinRequiredArguments();
9017 if (!ft_info)
return 0;
9022 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
9024 switch (ft->getAccess()) {
9025 case clang::AS_public:
9028 case clang::AS_protected:
9031 case clang::AS_private:
9034 case clang::AS_none:
9035 if (ft->getDeclContext()->isNamespace())
9040 assert(
false &&
"Unexpected value for the access property value in Clang");
9044 const clang::FunctionDecl *fd = ft->getTemplatedDecl();
9046 if (fd && fd->getStorageClass() == clang::SC_Static)
9049 if (
const clang::CXXMethodDecl *md =
9050 llvm::dyn_cast<clang::CXXMethodDecl>(fd)) {
9051 if (md->getMethodQualifiers().hasConst()) {
9054 if (md->isVirtual()) {
9057 if (md->isPureVirtual()) {
9060 if (
const clang::CXXConstructorDecl *cd =
9061 llvm::dyn_cast<clang::CXXConstructorDecl>(md)) {
9062 if (cd->isExplicit()) {
9066 else if (
const clang::CXXConversionDecl *cd =
9067 llvm::dyn_cast<clang::CXXConversionDecl>(md)) {
9068 if (cd->isExplicit()) {
9082 if (!ft_info)
return 0;
9087 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
9088 const clang::FunctionDecl *fd = ft->getTemplatedDecl();
9090 if (fd->isOverloadedOperator())
9092 if (llvm::isa<clang::CXXConversionDecl>(fd))
9094 if (llvm::isa<clang::CXXConstructorDecl>(fd))
9096 if (llvm::isa<clang::CXXDestructorDecl>(fd))
9098 if (fd->isInlined())
9109 if (!ft_info)
return;
9110 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
9122 if (!ft_info)
return;
9123 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
9127 if (
const RedeclarableTemplateDecl *AnnotFD
9129 if (AnnotateAttr *A = AnnotFD->getAttr<AnnotateAttr>()) {
9130 output = A->getAnnotation().str();
9134 if (!ft->isFromASTFile()) {
9185 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
9219 return info->
NArg();
9235 return info->
Next();
9262 return (TypeInfo_t*)info->
Type();
9270 TTHREAD_TLS_DECL(
TString, mangled_name);
9273 return mangled_name;
9291 return info->
Name();
9321 return info->
Title();
9329 return MethodInfo_MethodCallReturnType(func->fInfo);
9331 return EReturnType::kOther;
9340 if (info && info->
IsValid()) {
9342 clang::QualType QT( typeinfo->
GetQualType().getCanonicalType() );
9343 if (QT->isEnumeralType()) {
9344 return EReturnType::kLong;
9345 }
else if (QT->isPointerType()) {
9347 QT = llvm::cast<clang::PointerType>(QT)->getPointeeType();
9348 if ( QT->isCharType() ) {
9349 return EReturnType::kString;
9351 return EReturnType::kOther;
9353 }
else if ( QT->isFloatingType() ) {
9354 int sz = typeinfo->
Size();
9355 if (sz == 4 || sz == 8) {
9357 return EReturnType::kDouble;
9359 return EReturnType::kOther;
9361 }
else if ( QT->isIntegerType() ) {
9362 int sz = typeinfo->
Size();
9371 return EReturnType::kLong;
9373 return EReturnType::kOther;
9376 return EReturnType::kOther;
9379 return EReturnType::kOther;
9415 return (MethodArgInfo_t*)
9432 return info->
Next();
9456 return info->
Name();
9480 return (TypeInfo_t*) info->
Type();
9540 return TClinginfo->
Name();
9564 return TClinginfo->
Size();
9622 const char*
name)
const
9642 return TClinginfo->
Next();
9658 return TClinginfo->
Size();
9674 return TClinginfo->
Name();
9682 return TClinginfo->
Title();
9689 clang::QualType QT1 = clang::QualType::getFromOpaquePtr(QualTypePtr1);
9690 clang::QualType QT2 = clang::QualType::getFromOpaquePtr(QualTypePtr2);
9691 return fInterpreter->getCI()->getASTContext().hasSameType(QT1, QT2);
9698 clang::QualType QT = clang::QualType::getFromOpaquePtr(QualTypePtr);
9699 return QT->hasIntegerRepresentation();
9706 clang::QualType QT = clang::QualType::getFromOpaquePtr(QualTypePtr);
9707 return QT->hasSignedIntegerRepresentation();
9714 clang::QualType QT = clang::QualType::getFromOpaquePtr(QualTypePtr);
9715 return QT->hasUnsignedIntegerRepresentation();
9722 clang::QualType QT = clang::QualType::getFromOpaquePtr(QualTypePtr);
9723 return QT->hasFloatingRepresentation();
9730 clang::QualType QT = clang::QualType::getFromOpaquePtr(QualTypePtr);
9731 return QT->hasPointerRepresentation();
9738 clang::QualType QT = clang::QualType::getFromOpaquePtr(QualTypePtr);
9739 return QT->isVoidPointerType();
9748 Error(
"SnapshotMutexState",
"fRecurseCount != 0 even though initial mutex state is unset!");
9764 Error(
"ForgetMutexState",
"mutex state's recurse count already 0!");
9780 std::unique_ptr<MutexStateAndRecurseCountDelta> uniqueP{typedDelta};
9781 gCoreMutex->Apply(std::move(typedDelta->fDelta));
9783 R__ASSERT(
fInitialMutex.fRecurseCount == 0 &&
"Inconsistent state of fInitialMutex! Another thread within Interpreter critical section.");
9794 Error(
"ApplyToInterpreterMutex",
9795 "After returning from user code that turned on thread safety support, we notice that fInitialMutex is already used ... "
9796 "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.");
9811 uniqueP->fDelta =
gCoreMutex->Rewind(*uniqueP->fInitialState.fState);
9812 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
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).
int Ssiz_t
String size (currently int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
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.
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
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.
float Float_t
Float 4 bytes (float).
const char Option_t
Option string (const char).
TClass *(* DictFuncPtr_t)()
externTApplication * gApplication
externTClassTable * 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. Use static initialization to insure only on...
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. This is just supposed to make a C++ mo...
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)
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
#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.
externInt_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.
#define R__LOCKGUARD_CLING(mutex)
externTInterpreter * gCling
externTVirtualMutex * gInterpreterMutex
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Bool_t R_ISREG(Int_t mode)
externTVirtualMutex * gGlobalMutex
#define R__LOCKGUARD(mutex)
#define R__WRITE_LOCKGUARD(mutex)
#define R__READ_LOCKGUARD(mutex)
virtual std::unique_ptr< State > GetStateBefore()=0
Storage_t const & get() const
Const access to the underlying stl container.
static Longptr_t ExecuteFile(const char *file, Int_t *error=nullptr, Bool_t keep=kFALSE)
Execute a file containing a C++ macro (static method).
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)
Bool_t CallShowMembers(const void *obj, TMemberInspector &insp, Bool_t isTransient=kFALSE) const
Call ShowMembers() on the obj of this class type, passing insp and parent.
std::atomic< TListOfEnums * > fEnums
static Bool_t HasNoInfoOrEmuOrFwdDeclaredDecl(const char *)
virtual void PostLoadCheck()
Do the initialization that can only be done after the CINT dictionary has been fully populated and ca...
static TClass * LoadClass(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
Int_t Size() const
Return size of object of this class.
static DictFuncPtr_t GetDict(const char *cname)
Return a pointer to the dictionary loading function generated by rootcint.
TObjArray * fStreamerInfo
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
ClassInfo_t * GetClassInfo() const
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
void ResetCaches()
To clean out all caches.
Long_t Property() const override
Returns the properties of the TClass as a bit field stored as a Long_t value.
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.
Version_t GetClassVersion() const
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
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) 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 IsAutoLoadingEnabled() const
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
const clang::Type * GetType() const
ptrdiff_t GetBaseOffset(TClingClassInfo *toBase, void *address, bool isDerivedObject)
bool IsScopedEnum() const
ROOT::TMetaUtils::EIOCtorCategory HasDefaultConstructor(bool checkio=false, std::string *type_name=nullptr) const
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
TDictionary::DeclId_t GetDeclId() const
void DeleteArray(void *arena, bool dtorOnly, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
void * New(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
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
std::vector< std::string > GetUsingNamespaces()
bool IsBase(const char *name) const
void Delete(void *arena, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Emulation of the CINT DataMemberInfo class.
const char * TypeName() const
const char * TypeTrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
int MaxIndex(int dim) const
llvm::StringRef ValidArrayIndex() const
const char * Name() const override
long TypeProperty() const
virtual const char * Name() const
virtual bool IsValid() const
virtual const clang::Decl * GetDecl() const
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.
std::string GetMangledName() const
const char * TypeName() const
const char * Name() const override
const clang::FunctionDecl * GetTargetFunctionDecl() const
Get the FunctionDecl, or if this represents a UsingShadowDecl, the underlying target FunctionDecl.
const char * GetPrototype()
long ExtraProperty() const
void * 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
clang::QualType GetQualType() const
void Init(const char *name)
const char * TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Return the normalized name of the type (i.e.
Emulation of the CINT TypedefInfo class.
const char * TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Get the name of the underlying type of the current typedef.
long Property() const
Return a bit mask of metadata about the current typedef.
const char * Name() const override
Get the name of the current typedef.
void Init(const char *name)
Lookup named typedef and reset the iterator to point to it.
int Next()
Increment the iterator.
int Size() const
Return the size in bytes of the underlying type of the current typedef.
Bridge between cling::Value and ROOT.
bool Append(const std::string &str)
Append string to the storage if not added already.
std::hash< std::string > fHashFunc
std::set< size_t > fLinesHashSet
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 stored TCling state for declarations included in transaction `T'.
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. The caller of this function should be hold...
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.
TCling(const char *name, const char *title, const char *const argv[], void *interpLibHandle)
Initialize the cling interpreter interface.
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
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. headers is a 0-terminated array of...
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
ECheckClassInfo CheckClassInfo(const char *name, Bool_t autoload, Bool_t isClassOrNamespaceOnly=kFALSE) final
Checks if an entity with the specified name is defined in Cling.
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
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 SetClassInfo(TClass *cl, Bool_t reload=kFALSE, Bool_t silent=kFALSE) final
Set pointer to the TClingClassInfo in TClass.
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. The caller of this function should be holdin...
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)
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 void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void Add(TObject *obj)=0
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
Bool_t Contains(const char *name) const
All ROOT classes may have RTTI (run time type identification) support added.
Bool_t IsPersistent() const
Basic data type descriptor (datatype information is obtained from CINT).
EMemberSelection
Kinds of members to include in lists.
TList * GetListOfKeys() const override
void GetObject(const char *namecycle, T *&ptr)
Get an object with proper type checking.
The TEnumConstant class implements the constants of the enum type.
The TEnum class implements the enum type.
const TSeqCollection * GetConstants() const
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
DeclId_t GetDeclId() const
const char * GetValue() const
const char * GetName() const override
Returns name of object.
The TEnv class reads config files, by default named .rootrc.
Bool_t IgnoreDuplicates(Bool_t ignore)
If set to true, no warnings in case of duplicates are issued.
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...
THashTable implements a hash table to store TObject's.
virtual const void * GetValAddr() const =0
This class defines an abstract interface to a generic command line interpreter.
int(* AutoLoadCallBack_t)(const char *)
friend class SuspendAutoParsing
std::vector< std::pair< std::string, int > > FwdDeclArgsToKeepCollection_t
TDictionary::DeclId_t DeclId_t
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...
TObject * FindObject(const char *name) const override
Specialize FindObject to do search for the a data member just by name or create it if its not already...
TDictionary * Find(DeclId_t id) const
Return (after creating it if necessary) the TDataMember describing the data member corresponding to t...
TClass * GetClass() const
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
TEnum * Find(DeclId_t id) const
Return the TEnum corresponding to the Decl 'id' or NULL if it does not exist.
TEnum * Get(DeclId_t id, const char *name)
Return (after creating it if necessary) the TEnum describing the enum corresponding to the Decl 'id'.
TClass * GetClass() const
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TFunctionTemplate * Get(DeclId_t id)
Return (after creating it if necessary) the TMethod or TFunction describing the function correspondin...
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TFunction * Find(DeclId_t id) const
Return the TMethod or TFunction describing the function corresponding to the Decl 'id'.
void Add(TObject *obj) override
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Abstract base class for accessing the data-members of a class.
void DecrementNestedTransient()
const char * GetParent() const
void IncrementNestedTransient()
virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr)
EObjectPointerState GetObjectValidity() const
virtual Bool_t IsTreatingNonAccessibleTypes()
void SetObjectValidity(EObjectPointerState val)
void InspectMember(const T &obj, const char *name, Bool_t isTransient)
Each ROOT method (see TMethod) has a linked list of its arguments.
const char * GetFullTypeName() const
Get full type description of method argument, e.g.: "class TDirectory*".
const char * GetDefault() const
Get default value of method argument.
Each ROOT class (see TClass) has a linked list of methods.
virtual TList * GetListOfMethodArgs()
Returns methodarg list and additionally updates fDataMember in TMethod by calling FindDataMember();.
const char * GetName() const override
Returns name of object.
Int_t GetEntriesFast() const
virtual void Expand(Int_t newSize)
Expand or shrink the array to newSize elements.
Int_t GetEntries() const override
Return the number of objects in array (i.e.
TObject * At(Int_t idx) const override
TObject * UncheckedAt(Int_t i) const
Collectable string class.
Mother of all ROOT objects.
Bool_t TestBit(UInt_t f) 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 TClass * IsA() const
TObject()
TObject constructor.
@ 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!
static const TString & GetSharedLibDir()
Get the shared libraries directory in the installation.
Sequenceable collection abstract base class.
void Add(TObject *obj) override
Describes a persistent version of a class.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
void Clear()
Clear string without changing its capacity.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Ssiz_t Last(char c) const
Find last occurrence of a character c.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Prepend(const char *cs)
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
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()
void(off) SmallVectorTemplateBase< T
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
The namespace of The Lean Mean C++ Option Parser.
externTVirtualRWMutex * gCoreMutex
RooArgList L(Args_t &&... args)
RooArgSet S(Args_t &&... args)
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 *)
constexpr Double_t C()
Velocity of light in .
RAII used to store Parser, Sema, Preprocessor state for recursive parsing.
void ShortType(std::string &answer, int mode)
Return the absolute type of typeDesc into the string answ.
Int_t fRecurseCount
Interpreter-related functions will push the "entry" lock state to *this.