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 "llvm/IR/GlobalValue.h"
119#include "llvm/IR/Module.h"
121#include "llvm/Support/DynamicLibrary.h"
122#include "llvm/Support/raw_ostream.h"
123#include "llvm/Support/Path.h"
124#include "llvm/Support/Process.h"
125#include "llvm/Object/ELFObjectFile.h"
126#include "llvm/Object/ObjectFile.h"
127#include "llvm/Object/SymbolicFile.h"
128#include "llvm/Support/FileSystem.h"
142#include <unordered_map>
143#include <unordered_set>
150#define R__DLLEXPORT __attribute__ ((visibility ("default")))
158#include <mach-o/dyld.h>
159#include <mach-o/loader.h>
173#if defined(__CYGWIN__)
174#include <sys/cygwin.h>
175#define HMODULE void *
177 __declspec(dllimport)
void * __stdcall GetCurrentProcess();
178 __declspec(dllimport)
bool __stdcall EnumProcessModules(
void *,
void **,
unsigned long,
unsigned long *);
179 __declspec(dllimport)
unsigned long __stdcall GetModuleFileNameExW(
void *,
void *,
wchar_t *,
unsigned long);
186# define STDIN_FILENO 0
189# define STDOUT_FILENO 1
192# define STDERR_FILENO 2
201#undef GetModuleFileName
202#define RTLD_DEFAULT ((void *)::GetModuleHandle(NULL))
203#define dlsym(library, function_name) ::GetProcAddress((HMODULE)library, function_name)
204#define dlopen(library_name, flags) ::LoadLibraryA(library_name)
205#define dlclose(library) ::FreeLibrary((HMODULE)library)
206#define R__DLLEXPORT __declspec(dllexport)
214 return D->getDeclContext();
217 return llvm::dyn_cast<clang::NamespaceDecl>(DC);
220 return llvm::dyn_cast<clang::RecordDecl>(DC);
223 return DC->dumpDeclContext();
232 return ((clang::Decl*)D)->dump();
235 if (clang::NamedDecl* ND = llvm::dyn_cast<clang::NamedDecl>(D)) {
238 llvm::raw_string_ostream OS(
name);
239 ND->getNameForDiagnostic(OS, D->getASTContext().getPrintingPolicy(),
242 printf(
"%s\n",
name.c_str());
250 return D->isInvalidDecl();
254 assert(info && info->
IsValid());
255 return info->
GetDecl()->isInvalidDecl();
259using namespace clang;
263 static const std::string gInterpreterClassDef = R
"ICF(
265#define ClassDef(name, id) \
266_ClassDefInterp_(name,id,virtual,) \
267static int DeclFileLine() { return __LINE__; }
269#define ClassDefNV(name, id) \
270_ClassDefInterp_(name,id,,) \
271static int DeclFileLine() { return __LINE__; }
272#undef ClassDefOverride
273#define ClassDefOverride(name, id) \
274_ClassDefInterp_(name,id,,override) \
275static int DeclFileLine() { return __LINE__; }
278 static const std::string gNonInterpreterClassDef = R
"ICF(
279#define __ROOTCLING__ 1
281#define ClassDef(name,id) \
282_ClassDefOutline_(name,id,virtual,) \
283static int DeclFileLine() { return __LINE__; }
285#define ClassDefNV(name, id)\
286_ClassDefOutline_(name,id,,)\
287static int DeclFileLine() { return __LINE__; }
288#undef ClassDefOverride
289#define ClassDefOverride(name, id)\
290_ClassDefOutline_(name,id,,override)\
291static int DeclFileLine() { return __LINE__; }
295 static const std::string gClassDefInterpMacro = R
"ICF(
298#define _ClassDefInterp_(name,id,virtual_keyword, overrd) \
301 static TClass *Class() { static TClass* sIsA = 0; if (!sIsA) sIsA = TClass::GetClass(#name); return sIsA; } \
302 static const char *Class_Name() { return #name; } \
303 virtual_keyword Bool_t CheckTObjectHashConsistency() const overrd { return true; } \
304 static Version_t Class_Version() { return id; } \
305 static TClass *Dictionary() { return 0; } \
306 virtual_keyword TClass *IsA() const overrd { return name::Class(); } \
307 virtual_keyword void ShowMembers(TMemberInspector&insp) const overrd { ::ROOT::Class_ShowMembers(name::Class(), this, insp); } \
308 virtual_keyword void Streamer(TBuffer&) overrd { ::Error("Streamer", "Cannot stream interpreted class."); } \
309 void StreamerNVirtual(TBuffer&ClassDef_StreamerNVirtual_b) { name::Streamer(ClassDef_StreamerNVirtual_b); } \
310 static const char *DeclFileName() { return __FILE__; } \
311 static int ImplFileLine() { return 0; } \
312 static const char *ImplFileName() { return __FILE__; }
343 return ((
TCling*)
gCling)->LibraryLoadingFailed(errmessage, libStem, permanent, resolved);
382 static vector<const NamedDecl*> updateList;
385 if (entered) topLevel =
kFALSE;
400 updateList.push_back(TD);
403 while (!updateList.empty()) {
405 updateList.pop_back();
412 const clang::Decl* D =
static_cast<const clang::Decl*
>(enumObj->
GetDeclId());
413 if(
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(D)) {
415 for (EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(),
416 EDE = ED->enumerator_end(); EDI != EDE; ++EDI) {
418 std::string constbuf;
419 if (
const NamedDecl* END = llvm::dyn_cast<NamedDecl>(*EDI)) {
420 PrintingPolicy Policy((*EDI)->getASTContext().getPrintingPolicy());
421 llvm::raw_string_ostream stream(constbuf);
423 Policy.AnonymousTagLocations =
false;
424 (END)->getNameForDiagnostic(stream, Policy,
false);
426 const char* constantName = constbuf.c_str();
430 const llvm::APSInt valAPSInt = (*EDI)->getInitVal();
431 if (valAPSInt.isSigned()) {
432 value = valAPSInt.getSExtValue();
434 value = valAPSInt.getZExtValue();
441 DataMemberInfo_t* dmInfo = (DataMemberInfo_t*) tcDmInfo;
445 enumConstant =
new TEnumConstant(dmInfo, constantName, value, enumObj);
452 globals->
Add(enumConstant);
465 const clang::Decl* D =
static_cast<const clang::Decl*
>(VD);
467 if (
const EnumDecl* ED = llvm::dyn_cast<EnumDecl>(D)) {
469 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
470 llvm::raw_string_ostream stream(buf);
472 Policy.AnonymousTagLocations =
false;
473 ED->getNameForDiagnostic(stream, Policy,
false);
479 const char*
name = buf.c_str();
490 const clang::Decl* D =
static_cast<const clang::Decl*
>(DV);
492 if (!D->isCanonicalDecl() && !isa<clang::NamespaceDecl>(D)
493 && !dyn_cast<clang::RecordDecl>(D))
return;
495 if (isa<clang::FunctionDecl>(D->getDeclContext())
496 || isa<clang::TagDecl>(D->getDeclContext()))
500 if (
const clang::CXXRecordDecl* RD = dyn_cast<clang::CXXRecordDecl>(D)) {
501 if (RD->getDescribedClassTemplate())
503 }
else if (
const clang::FunctionDecl* FD = dyn_cast<clang::FunctionDecl>(D)) {
504 if (FD->getDescribedFunctionTemplate())
508 if (
const RecordDecl *TD = dyn_cast<RecordDecl>(D)) {
509 if (TD->isCanonicalDecl() || TD->isThisDeclarationADefinition())
512 else if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
514 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
518 }
else if (
const NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(D)) {
523 if (!isa<TranslationUnitDecl>(ND->getDeclContext()))
527 if (isa<EnumDecl>(ND))
532 if (!(isa<VarDecl>(ND)))
536 if (
gROOT->GetListOfGlobals()->FindObject(ND->getNameAsString().c_str()))
540 gROOT->GetListOfGlobals()->Add(
new TGlobal((DataMemberInfo_t *)
542 cast<ValueDecl>(ND), 0)));
574 const char* canonicalName) {
575 ((
TCling*)
gCling)->LibraryLoaded(dyLibHandle, canonicalName);
580 ((
TCling *)
gCling)->RegisterRdictForLoadPCM(pcmFileNameFullPath, pcmContent);
584 const char* canonicalName) {
585 ((
TCling*)
gCling)->LibraryUnloaded(dyLibHandle, canonicalName);
591 return ((
TCling*)
gCling)->GetObjectAddress(Name, LookupCtx);
601 auto tcling =
new TCling(
"C++",
"cling C++ Interpreter", argv);
602 cling::DynamicLibraryManager::ExposeHiddenSharedLibrarySymbols(interpLibHandle);
625 return ((
TCling*)
gCling)->GetClassSharedLibs(className);
631 return ((
TCling*)
gCling)->IsAutoLoadNamespaceCandidate(nsDecl);
636 string file(fileName);
642 string &args,
string &io,
string &fname)
644 string file(fileName);
645 TString f, amode, arguments, aclicio;
647 mode = amode.
Data(); args = arguments.
Data();
648 io = aclicio.
Data(); fname =
f.Data();
658 char *__unDName(
char *demangled,
const char *mangled,
int out_len,
659 void * (* pAlloc )(
size_t),
void (* pFree )(
void *),
660 unsigned short int flags);
672 using namespace clang;
673 if (NamespaceDecl* nsd = llvm::dyn_cast<NamespaceDecl>(decl)){
677 if (ClassTemplateDecl* ctd = llvm::dyn_cast<ClassTemplateDecl>(decl)){
689 return ((
TCling*)
gCling)->LazyFunctionCreatorAutoload(mangled_name);
698 const std::vector<std::string> &headers,
699 const std::vector<std::string> &fwdDecls,
700 const std::vector<std::string> &unknown)
706 if (classes.empty()) {
710 const std::string& className = classes[0];
712 TString fileName =
"AutoDict_";
713 std::string::const_iterator sIt;
714 for (sIt = className.begin(); sIt != className.end(); ++sIt) {
715 if (*sIt ==
'<' || *sIt ==
'>' ||
716 *sIt ==
' ' || *sIt ==
'*' ||
717 *sIt ==
',' || *sIt ==
'&' ||
725 if (classes.size() > 1) {
727 std::vector<std::string>::const_iterator it = classes.begin();
728 while ((++it) != classes.end()) {
729 for (
UInt_t cursor = 0; cursor != it->length(); ++cursor) {
730 chk = chk * 3 + it->at(cursor);
743 static const std::set<std::string> sSTLTypes {
744 "vector",
"list",
"forward_list",
"deque",
"map",
"unordered_map",
"multimap",
745 "unordered_multimap",
"set",
"unordered_set",
"multiset",
"unordered_multiset",
746 "queue",
"priority_queue",
"stack",
"iterator"};
747 std::vector<std::string>::const_iterator it;
748 std::string fileContent(
"");
749 for (it = headers.begin(); it != headers.end(); ++it) {
750 fileContent +=
"#include \"" + *it +
"\"\n";
752 for (it = unknown.begin(); it != unknown.end(); ++it) {
758 while (dirbase.
Length() && dirbase !=
"."
759 && dirbase !=
"include" && dirbase !=
"inc"
760 && dirbase !=
"prec_stl") {
764 fileContent +=
TString(
"#include \"") + header +
"\"\n";
767 for (it = fwdDecls.begin(); it != fwdDecls.end(); ++it) {
768 fileContent +=
"class " + *it +
";\n";
770 fileContent +=
"#ifdef __CLING__ \n";
771 fileContent +=
"#pragma link C++ nestedclasses;\n";
772 fileContent +=
"#pragma link C++ nestedtypedefs;\n";
773 for (it = classes.begin(); it != classes.end(); ++it) {
775 size_t posTemplate =
n.find(
'<');
776 std::set<std::string>::const_iterator iSTLType = sSTLTypes.end();
777 if (posTemplate != std::string::npos) {
778 n.erase(posTemplate, std::string::npos);
779 if (
n.compare(0, 5,
"std::") == 0) {
782 iSTLType = sSTLTypes.find(
n);
784 fileContent +=
"#pragma link C++ class ";
785 fileContent += *it +
"+;\n" ;
786 fileContent +=
"#pragma link C++ class ";
787 if (iSTLType != sSTLTypes.end()) {
791 fileContent += *it +
"::*;\n" ;
796 fileContent += *it +
"::*+;\n" ;
799 fileContent +=
"#endif\n";
803 filePointer = fopen(fileName,
"w");
804 if (filePointer == NULL) {
810 fprintf(filePointer,
"%s", fileContent.c_str());
826 const std::vector<std::string> &headers,
827 const std::vector<std::string> &fwdDecls,
828 const std::vector<std::string> &unknown)
834 std::vector<std::string> classes;
835 classes.push_back(className);
863 void exceptionErrorHandler(
void * ,
864 const std::string& reason,
866 throw std::runtime_error(std::string(
">>> Interpreter compilation error:\n") + reason);
880 class clangDiagSuppr {
882 clangDiagSuppr(clang::DiagnosticsEngine& diag): fDiagEngine(diag){
883 fOldDiagValue = fDiagEngine.getIgnoreAllWarnings();
884 fDiagEngine.setIgnoreAllWarnings(
true);
888 fDiagEngine.setIgnoreAllWarnings(fOldDiagValue);
891 clang::DiagnosticsEngine& fDiagEngine;
913 unsigned long offset = 0;
914 if (strncmp(tname.c_str(),
"const ", 6) == 0) {
917 unsigned long end = tname.length();
918 while( end && (tname[end-1]==
'&' || tname[end-1]==
'*' || tname[end-1]==
']') ) {
919 if ( tname[end-1]==
']' ) {
921 while ( end && tname[end-1]!=
'[' ) --end;
925 std::string innerbuf;
927 if (end != tname.length()) {
928 innerbuf = tname.substr(offset,end-offset);
929 inner = innerbuf.c_str();
931 inner = tname.c_str()+offset;
935 if (
gROOT->GetListOfClasses()->FindObject(inner)
945 const char *newname =
type->GetFullTypeName();
947 newname =
"Long64_t";
949 newname =
"ULong64_t";
951 if (strcmp(inner,newname) == 0) {
954 if (offset) result =
"const ";
956 if ( end != tname.length() ) {
957 result += tname.substr(end,tname.length()-end);
959 if (result == tname) result.clear();
965 if (lastPos != inner)
969 const auto enName = lastPos;
970 const auto scopeNameSize = ((
Long64_t)lastPos - (
Long64_t)inner) /
sizeof(
decltype(*lastPos)) - 2;
971 char *scopeName =
new char[scopeNameSize + 1];
972 strncpy(scopeName, inner, scopeNameSize);
973 scopeName[scopeNameSize] =
'\0';
975 if (
auto scope =
static_cast<TClass *
>(
gROOT->GetListOfClasses()->FindObject(scopeName))) {
976 auto enumTable =
dynamic_cast<const THashList *
>(scope->GetListOfEnums(
false));
977 if (enumTable && enumTable->THashList::FindObject(enName)) {
delete [] scopeName;
return true; }
981 auto listOfEnums = scope->GetListOfEnums();
983 auto enumTable =
dynamic_cast<const THashList *
>(listOfEnums);
984 if (enumTable && enumTable->THashList::FindObject(enName)) {
delete [] scopeName;
return true; }
991 auto enumTable =
dynamic_cast<const THashList *
>(
gROOT->GetListOfEnums());
992 if (enumTable && enumTable->THashList::FindObject(inner))
return true;
1015 return fContent.c_str();
1023 bool notPresent = fLinesHashSet.emplace(fHashFunc(str)).second;
1037static bool LoadModule(
const std::string &ModuleName, cling::Interpreter &interp)
1047 assert(!currentDir.empty());
1050 ::Info(
"TCling::__LoadModule",
"Preloading module %s. \n",
1051 ModuleName.c_str());
1053 return interp.loadModule(ModuleName,
true);
1059static void LoadModules(
const std::vector<std::string> &modules, cling::Interpreter &interp)
1061 for (
const auto &modName : modules)
1067 const static bool foundSymbol = dlsym(RTLD_DEFAULT,
"usedToIdentifyRootClingByDlSym");
1072static bool HasASTFileOnDisk(clang::Module *M,
const clang::Preprocessor &PP, std::string *FullFileName =
nullptr)
1074 const HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
1076 std::string ModuleFileName;
1077 if (!HSOpts.PrebuiltModulePaths.empty())
1079 ModuleFileName = PP.getHeaderSearchInfo().getPrebuiltModuleFileName(M->Name);
1081 *FullFileName = ModuleFileName;
1083 return !ModuleFileName.empty();
1089 CompilerInstance &CI = *interp.getCI();
1090 Preprocessor &PP = CI.getPreprocessor();
1091 auto ModuleManager = CI.getModuleManager();
1092 assert(ModuleManager);
1097 if (ModuleIndexPath.empty())
1100 ModuleManager->resetForReload();
1101 ModuleManager->loadGlobalIndex();
1102 GlobalModuleIndex *GlobalIndex = ModuleManager->getGlobalIndex();
1107 ModuleMap &MMap = PP.getHeaderSearchInfo().getModuleMap();
1108 bool RecreateIndex =
false;
1109 for (ModuleMap::module_iterator
I = MMap.module_begin(), E = MMap.module_end();
I != E; ++
I) {
1110 Module *TheModule =
I->second;
1115 RecreateIndex =
true;
1117 if (RecreateIndex) {
1118 cling::Interpreter::PushTransactionRAII deserRAII(&interp);
1119 clang::GlobalModuleIndex::UserDefinedInterestingIDs IDs;
1121 struct DefinitionFinder :
public RecursiveASTVisitor<DefinitionFinder> {
1122 DefinitionFinder(clang::GlobalModuleIndex::UserDefinedInterestingIDs& IDs,
1123 clang::TranslationUnitDecl* TU) : DefinitionIDs(IDs) {
1126 bool VisitNamedDecl(NamedDecl *ND) {
1127 if (!ND->isFromASTFile())
1129 if (!ND->getIdentifier())
1132 if (ND->getAccess() == AS_protected || ND->getAccess() == AS_private)
1135 if (TagDecl *TD = llvm::dyn_cast<TagDecl>(ND)) {
1136 if (TD->isCompleteDefinition())
1138 }
else if (NamespaceDecl *NSD = llvm::dyn_cast<NamespaceDecl>(ND)) {
1139 Register(NSD,
false);
1141 else if (TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(ND))
1147 clang::GlobalModuleIndex::UserDefinedInterestingIDs &DefinitionIDs;
1148 void Register(
const NamedDecl* ND,
bool AddSingleEntry =
true) {
1149 assert(ND->isFromASTFile());
1152 if (!ND->hasOwningModule()) {
1154 SourceManager &SM = ND->getASTContext().getSourceManager();
1155 SourceLocation Loc = ND->getLocation();
1156 const FileEntry *FE = SM.getFileEntryForID(SM.getFileID(Loc));
1158 assert(FE->getName().contains(
"input_line_"));
1163 Module *OwningModule = ND->getOwningModule()->getTopLevelModule();
1164 assert(OwningModule);
1165 assert(!ND->getName().empty() &&
"Empty name");
1166 if (AddSingleEntry && DefinitionIDs.count(ND->getName()))
1172 DefinitionIDs[ND->getName()].push_back(OwningModule->getASTFile());
1175 DefinitionFinder defFinder(IDs, CI.getASTContext().getTranslationUnitDecl());
1177 llvm::cantFail(GlobalModuleIndex::writeIndex(CI.getFileManager(),
1178 CI.getPCHContainerReader(),
1181 ModuleManager->resetForReload();
1182 ModuleManager->loadGlobalIndex();
1183 GlobalIndex = ModuleManager->getGlobalIndex();
1192 if (!clingInterp.getCI()->getLangOpts().Modules)
1196 cling::Interpreter::PushTransactionRAII deserRAII(&clingInterp);
1214 LoadModule(
"_Builtin_intrinsics", clingInterp);
1218 std::vector<std::string> CoreModules = {
"ROOT_Foundation_C",
1221 "ROOT_Foundation_Stage1_NoRTTI",
1230 std::vector<std::string> CommonModules = {
"MathCore"};
1236 std::vector<std::string> FIXMEModules = {
"Hist"};
1237 clang::CompilerInstance &CI = *clingInterp.getCI();
1238 clang::Preprocessor &PP = CI.getPreprocessor();
1239 ModuleMap &MMap = PP.getHeaderSearchInfo().getModuleMap();
1240 if (MMap.findModule(
"RInterface"))
1241 FIXMEModules.push_back(
"RInterface");
1245 GlobalModuleIndex *GlobalIndex =
nullptr;
1247 bool supportedPlatform =
1250#elif defined(R__MACOSX)
1257 llvm::Optional<std::string> envUseGMI = llvm::sys::Process::GetEnv(
"ROOT_USE_GMI");
1258 if (envUseGMI.hasValue()) {
1261 "Cannot convert '%s' to bool, setting to false!",
1262 envUseGMI->c_str());
1266 if (supportedPlatform == value)
1267 ::Warning(
"TCling__RegisterCxxModules",
"Global module index is%sused already!",
1268 (value) ?
" " :
" not ");
1269 supportedPlatform = value;
1272 if (supportedPlatform) {
1276 GlobalIndex = CI.getModuleManager()->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->IsMissingRequirement)
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);
1380#ifdef R__USE_CXXMODULES
1384 llvm::install_fatal_error_handler(&exceptionErrorHandler);
1388 std::vector<std::string> clingArgsStorage;
1389 clingArgsStorage.push_back(
"cling4root");
1390 for (
const char*
const* arg = argv; *arg; ++arg)
1391 clingArgsStorage.push_back(*arg);
1394 if (!fromRootCling) {
1399 clingArgsStorage.push_back(
"-I" + interpInclude);
1402 clingArgsStorage.push_back(
"-I" + interpInclude +
"/cling");
1405 clingArgsStorage.push_back(
"-I" + interpInclude +
"/cling/plugins/include");
1416 std::string pchFilename = interpInclude +
"/allDict.cxx.pch";
1421 clingArgsStorage.push_back(
"-include-pch");
1422 clingArgsStorage.push_back(pchFilename);
1425 clingArgsStorage.push_back(
"-Wno-undefined-inline");
1426 clingArgsStorage.push_back(
"-fsigned-char");
1427 clingArgsStorage.push_back(
"-O1");
1430 clingArgsStorage.push_back(
"-mllvm");
1431 clingArgsStorage.push_back(
"-optimize-regalloc=0");
1435 llvm::Optional<std::string> EnvOpt = llvm::sys::Process::GetEnv(
"EXTRA_CLING_ARGS");
1436 if (EnvOpt.hasValue()) {
1437 StringRef Env(*EnvOpt);
1438 while (!Env.empty()) {
1440 std::tie(Arg, Env) = Env.split(
' ');
1441 clingArgsStorage.push_back(Arg.str());
1445 auto GetEnvVarPath = [](
const std::string &EnvVar,
1446 std::vector<std::string> &Paths) {
1447 llvm::Optional<std::string> EnvOpt = llvm::sys::Process::GetEnv(EnvVar);
1448 if (EnvOpt.hasValue()) {
1449 StringRef Env(*EnvOpt);
1450 while (!Env.empty()) {
1453 if (std::find(Paths.begin(), Paths.end(), Arg.str()) == Paths.end())
1454 Paths.push_back(Arg.str());
1460 std::vector<std::string> Paths;
1469 GetEnvVarPath(
"CLING_PREBUILT_MODULE_PATH", Paths);
1470 std::string EnvVarPath;
1471 for (
const std::string& P : Paths)
1474 gSystem->
Setenv(
"CLING_PREBUILT_MODULE_PATH", EnvVarPath.c_str());
1478 EnvOpt = llvm::sys::Process::GetEnv(
"ROOT_CLING_TIMING");
1479 if (EnvOpt.hasValue())
1480 clingArgsStorage.push_back(
"-ftime-report");
1487 std::vector<std::string> ModuleMaps;
1490 GetEnvVarPath(
"CLING_MODULEMAP_FILES", ModuleMaps);
1494 if (llvm::sys::fs::exists(cwd + ModuleMapSuffix))
1495 ModuleMaps.push_back(cwd + ModuleMapSuffix);
1497 for (
const std::string& M : ModuleMaps)
1498 clingArgsStorage.push_back(
"-fmodule-map-file=" + M);
1500 std::string ModulesCachePath;
1501 EnvOpt = llvm::sys::Process::GetEnv(
"CLING_MODULES_CACHE_PATH");
1502 if (EnvOpt.hasValue()){
1503 StringRef Env(*EnvOpt);
1504 assert(llvm::sys::fs::exists(Env) &&
"Path does not exist!");
1505 ModulesCachePath = Env.str();
1510 clingArgsStorage.push_back(
"-fmodules-cache-path=" + ModulesCachePath);
1513 std::vector<const char*> interpArgs;
1514 for (std::vector<std::string>::const_iterator iArg = clingArgsStorage.begin(),
1515 eArg = clingArgsStorage.end(); iArg != eArg; ++iArg)
1516 interpArgs.push_back(iArg->c_str());
1523 if (!fromRootCling) {
1525 interpArgs.push_back(
"-fmodules");
1526 interpArgs.push_back(
"-fno-implicit-module-maps");
1530 interpArgs.push_back(
"-Rmodule-build");
1536 interpArgs.push_back(
"-fno-autolink");
1541 interpArgs.push_back(
"-ffast-math");
1547 extraArgs && *extraArgs; ++extraArgs) {
1548 if (!strcmp(*extraArgs,
"-resource-dir")) {
1550 llvmResourceDir = *(++extraArgs);
1552 interpArgs.push_back(*extraArgs);
1557 interpArgs.push_back(arg.c_str());
1561 cling::Interpreter::ModuleFileExtensions extensions;
1562 EnvOpt = llvm::sys::Process::GetEnv(
"ROOTDEBUG_RDICT");
1563 if (!EnvOpt.hasValue())
1564 extensions.push_back(std::make_shared<TClingRdictModuleFileExtension>());
1566 fInterpreter = llvm::make_unique<cling::Interpreter>(interpArgs.size(),
1568 llvmResourceDir, extensions);
1571 fInterpreter->getCI()->getPreprocessorOpts().DisablePCHValidation =
true;
1575 fInterpreter->getCI()->getLangOpts().SpellChecking =
false;
1580 static llvm::raw_fd_ostream fMPOuts (STDOUT_FILENO,
false);
1600 if (!fromRootCling) {
1605 fInterpreter->getRuntimeOptions().AllowRedefinition = 1;
1610 std::unique_ptr<TClingCallbacks>
1616 if (!fromRootCling) {
1617 cling::DynamicLibraryManager& DLM = *
fInterpreter->getDynamicLibraryManager();
1622 auto ShouldPermanentlyIgnore = [](llvm::StringRef FileName) ->
bool{
1623 llvm::StringRef stem = llvm::sys::path::stem(FileName);
1624 return stem.startswith(
"libNew") || stem.startswith(
"libcppyy_backend");
1627 DLM.initializeDyld(ShouldPermanentlyIgnore);
1666 assert(
GetRootMapFiles() == 0 &&
"Must be called before LoadLibraryMap!");
1685 auto setFactory = []() {
1689 static bool doneFactory = setFactory();
1701 if (llvm::sys::fs::exists(pcmFileNameFullPath)) {
1702 ::Error(
"TCling::RegisterRdictForLoadPCM",
"Rdict '%s' is both in Module extension and in File system.", pcmFileNameFullPath.c_str());
1719 if (listOfKeys && ((listOfKeys->GetSize() == 0) ||
1720 ((listOfKeys->GetSize() == 1) &&
1721 !strcmp(((
TKey *)listOfKeys->At(0))->GetName(),
"EMPTY")
1728 ::Info(
"TCling::LoadPCMImpl",
"reading protoclasses for %s \n", pcmFile.
GetName());
1734 auto listOfGlobals =
gROOT->GetListOfGlobals();
1735 auto listOfEnums =
dynamic_cast<THashList *
>(
gROOT->GetListOfEnums());
1737 for (
auto selEnum : *enums) {
1738 const char *enumScope = selEnum->
GetTitle();
1739 const char *enumName = selEnum->GetName();
1740 if (strcmp(enumScope,
"") == 0) {
1743 if (!listOfEnums->THashList::FindObject(enumName)) {
1744 ((
TEnum *)selEnum)->SetClass(
nullptr);
1745 listOfEnums->Add(selEnum);
1747 for (
auto enumConstant : *
static_cast<TEnum *
>(selEnum)->GetConstants()) {
1748 if (!listOfGlobals->FindObject(enumConstant)) {
1749 listOfGlobals->Add(enumConstant);
1756 if (!nsTClassEntry) {
1759 auto listOfEnums = nsTClassEntry->
fEnums.load();
1770 if (listOfEnums && !listOfEnums->THashList::FindObject(enumName)) {
1771 ((
TEnum *)selEnum)->SetClass(nsTClassEntry);
1772 listOfEnums->Add(selEnum);
1780 pcmFile.
GetObject(
"__ProtoClasses", protoClasses);
1783 for (
auto obj : *protoClasses) {
1793 for (
auto proto : *protoClasses) {
1801 ::Error(
"TCling::LoadPCM",
"Inconsistent TClassTable for %s",
proto->GetName());
1812 protoClasses->
Clear();
1813 delete protoClasses;
1817 pcmFile.
GetObject(
"__Typedefs", dataTypes);
1819 for (
auto typedf : *dataTypes)
1820 gROOT->GetListOfTypes()->Add(typedf);
1833 assert(!pcmFileNameFullPath.empty());
1834 assert(llvm::sys::path::is_absolute(pcmFileNameFullPath));
1837 TString pcmFileName = pcmFileNameFullPath;
1845 llvm::SaveAndRestore<Int_t> SaveGDebug(
gDebug);
1848 ::Info(
"TCling::LoadPCM",
"Loading ROOT PCM %s", pcmFileName.
Data());
1853 if (llvm::sys::fs::is_symlink_file(pcmFileNameFullPath))
1858 llvm::StringRef pcmContent = pendingRdict->second;
1860 std::string RDictFileOpts = pcmFileNameFullPath +
"?filetype=pcm";
1861 TMemFile pcmMemFile(RDictFileOpts.c_str(), range);
1870 if (!llvm::sys::fs::exists(pcmFileNameFullPath)) {
1871 ::Error(
"TCling::LoadPCM",
"ROOT PCM %s file does not exist",
1872 pcmFileNameFullPath.data());
1875 ::Info(
"TCling::LoadPCM",
"In-memory ROOT PCM candidate %s\n",
1876 rdict.first.c_str());
1880 if (!
gROOT->IsRootFile(pcmFileName)) {
1881 Fatal(
"LoadPCM",
"The file %s is not a ROOT as was expected\n", pcmFileName.
Data());
1884 TFile pcmFile(pcmFileName +
"?filetype=pcm",
"READ");
1891 using namespace clang;
1893 class ExtLexicalStorageAdder:
public RecursiveASTVisitor<ExtLexicalStorageAdder>{
1898 bool VisitRecordDecl(clang::RecordDecl* rcd){
1900 Info(
"ExtLexicalStorageAdder",
1901 "Adding external lexical storage to class %s",
1902 rcd->getNameAsString().c_str());
1903 auto reDeclPtr = rcd->getMostRecentDecl();
1905 reDeclPtr->setHasExternalLexicalStorage();
1906 }
while ((reDeclPtr = reDeclPtr->getPreviousDecl()));
1919 const std::string &ModuleMapName )
const
1921 assert(llvm::sys::path::is_absolute(FullPath));
1922 Preprocessor &PP =
fInterpreter->getCI()->getPreprocessor();
1923 FileManager &FM = PP.getFileManager();
1926 const DirectoryEntry *DE = FM.getDirectory(FullPath);
1928 HeaderSearch &HS = PP.getHeaderSearchInfo();
1929 HeaderSearchOptions &HSOpts = HS.getHeaderSearchOpts();
1930 const auto &ModPaths = HSOpts.PrebuiltModulePaths;
1931 bool pathExists = std::find(ModPaths.begin(), ModPaths.end(), FullPath) != ModPaths.end();
1933 HSOpts.AddPrebuiltModulePath(FullPath);
1938 llvm::SmallString<256> ModuleMapFileName(DE->getName());
1939 llvm::sys::path::append(ModuleMapFileName, ModuleMapName);
1940 const FileEntry *FE = FM.getFile(ModuleMapFileName,
false,
1943 if (!HS.loadModuleMapFile(FE,
false))
1945 Error(
"RegisterPrebuiltModulePath",
"Could not load modulemap in %s", ModuleMapFileName.c_str());
1962 "libforward_listDict",
1970 "libunordered_setDict",
1971 "libunordered_multisetDict",
1972 "libunordered_mapDict",
1973 "libunordered_multimapDict",
1981 char dyLibError[1000];
1982 FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
1983 dyLibError,
sizeof(dyLibError), NULL);
1985 const char *dyLibError = dlerror();
1987 ::Error(
"TCling::RegisterModule",
"Cannot open shared library %s for dictionary %s:\n %s", dyLibName, modulename,
1988 (dyLibError) ? dyLibError :
"");
2025 const char** headers,
2026 const char** includePaths,
2027 const char* payloadCode,
2028 const char* fwdDeclsCode,
2029 void (*triggerFunc)(),
2031 const char** classesHeaders,
2032 Bool_t lateRegistration ,
2039 if (fromRootCling)
return;
2048 bool isACLiC = strstr(modulename,
"_ACLiC_dict") !=
nullptr;
2049 if (hasHeaderParsingOnDemand && isACLiC) {
2051 Info(
"TCling::RegisterModule",
2052 "Header parsing on demand is active but this is an Aclic library. Disabling it for this library.");
2053 hasHeaderParsingOnDemand =
false;
2067 for (
const char** inclPath = includePaths; *inclPath; ++inclPath) {
2070 cling::Transaction* T = 0;
2072 for (
auto& fwdDeclArgToSkipPair : fwdDeclsArgToSkip){
2073 const std::string& fwdDecl = fwdDeclArgToSkipPair.first;
2074 const int nArgsToSkip = fwdDeclArgToSkipPair.second;
2075 auto compRes =
fInterpreter->declare(fwdDecl.c_str(), &T);
2076 assert(cling::Interpreter::kSuccess == compRes &&
2077 "A fwd declaration could not be compiled");
2078 if (compRes!=cling::Interpreter::kSuccess){
2079 Warning(
"TCling::RegisterModule",
2080 "Problems in declaring string '%s' were encountered.",
2095 TString code = gNonInterpreterClassDef;
2097 code += payloadCode;
2099 std::string dyLibName = cling::DynamicLibraryManager::getSymbolLocation(triggerFunc);
2100 assert(!llvm::sys::fs::is_symlink_file(dyLibName));
2102 if (dyLibName.empty()) {
2103 ::Error(
"TCling::RegisterModule",
"Dictionary trigger function for %s not found", modulename);
2108 bool isSharedLib = cling::DynamicLibraryManager::isSharedLibrary(dyLibName);
2110 bool wasDlopened =
false;
2115 if (!lateRegistration) {
2122 void* dyLibHandle = dlopen(dyLibName.c_str(), RTLD_LAZY | RTLD_GLOBAL);
2132 if (hasHeaderParsingOnDemand && fwdDeclsCode){
2135 std::string fwdDeclsCodeLessEnums;
2139 std::string fwdDeclsLine;
2140 std::istringstream fwdDeclsCodeStr(fwdDeclsCode);
2141 std::vector<std::string> scopes;
2142 while (std::getline(fwdDeclsCodeStr, fwdDeclsLine)) {
2143 const auto enumPos = fwdDeclsLine.find(
"enum __attribute__((annotate(\"");
2145 if (enumPos != std::string::npos) {
2152 auto nsPos = fwdDeclsLine.find(
"namespace");
2153 R__ASSERT(nsPos < enumPos &&
"Inconsistent enum and enclosing scope parsing!");
2154 while (nsPos < enumPos && nsPos != std::string::npos) {
2156 const auto nsNameStart = nsPos + 10;
2157 const auto nsNameEnd = fwdDeclsLine.find(
'{', nsNameStart);
2158 const auto nsName = fwdDeclsLine.substr(nsNameStart, nsNameEnd - nsNameStart);
2159 scopes.push_back(nsName);
2160 nsPos = fwdDeclsLine.find(
"namespace", nsNameEnd);
2163 clang::DeclContext* DC = 0;
2164 for (
auto &&aScope: scopes) {
2165 DC = cling::utils::Lookup::Namespace(&
fInterpreter->getSema(), aScope.c_str(), DC);
2171 if (scopes.empty() || DC) {
2175 size_t posEnumName = fwdDeclsLine.rfind(
"\"))) ");
2176 R__ASSERT(posEnumName != std::string::npos &&
"Inconsistent enum fwd decl!");
2178 while (isspace(fwdDeclsLine[posEnumName]))
2180 size_t posEnumNameEnd = fwdDeclsLine.find(
" : ", posEnumName);
2181 R__ASSERT(posEnumNameEnd != std::string::npos &&
"Inconsistent enum fwd decl (end)!");
2182 while (isspace(fwdDeclsLine[posEnumNameEnd]))
2186 std::string enumName = fwdDeclsLine.substr(posEnumName,
2187 posEnumNameEnd - posEnumName + 1);
2189 if (clang::NamedDecl* enumDecl
2190 = cling::utils::Lookup::Named(&
fInterpreter->getSema(),
2191 enumName.c_str(), DC)) {
2194 R__ASSERT(llvm::dyn_cast<clang::EnumDecl>(enumDecl) &&
"not an enum decl!");
2201 fwdDeclsCodeLessEnums += fwdDeclsLine +
"\n";
2205 if (!fwdDeclsCodeLessEnums.empty()){
2206 auto compRes =
fInterpreter->declare(fwdDeclsCodeLessEnums, &T);
2207 assert(cling::Interpreter::kSuccess == compRes &&
2208 "The forward declarations could not be compiled");
2209 if (compRes!=cling::Interpreter::kSuccess){
2210 Warning(
"TCling::RegisterModule",
2211 "Problems in compiling forward declarations for module %s: '%s'",
2212 modulename, fwdDeclsCodeLessEnums.c_str()) ;
2220 ExtLexicalStorageAdder elsa;
2221 for (
auto dciIt = T->decls_begin();dciIt!=T->decls_end();dciIt++){
2222 cling::Transaction::DelayCallInfo& dci = *dciIt;
2223 for(
auto dit = dci.m_DGR.begin(); dit != dci.m_DGR.end(); ++dit) {
2224 clang::Decl* declPtr = *dit;
2225 elsa.TraverseDecl(declPtr);
2239 for (
const char** classesHeader = classesHeaders; *classesHeader; ++classesHeader) {
2240 temp=*classesHeader;
2242 size_t theTemplateHash = 0;
2243 bool addTemplate =
false;
2244 size_t posTemplate = temp.find(
'<');
2245 if (posTemplate != std::string::npos) {
2247 std::string templateName = temp.substr(0, posTemplate);
2253 for (
const char** classesHeader_inner = classesHeader; 0!=strcmp(*classesHeader_inner,
"@"); ++classesHeader_inner,++classesHeader){
2255 if (payloadCode == *classesHeader_inner ){
2257 if (addTemplate)
fPayloads.insert(theTemplateHash);
2260 Info(
"TCling::RegisterModule",
2261 "Adding a header for %s", temp.c_str());
2267 addTemplate =
false;
2275 bool ModuleWasSuccessfullyLoaded =
false;
2277 std::string ModuleName = modulename;
2278 if (llvm::StringRef(modulename).startswith(
"lib"))
2279 ModuleName = llvm::StringRef(modulename).substr(3).str();
2284 clang::Preprocessor &PP = TheSema.getPreprocessor();
2285 std::string ModuleMapName;
2287 ModuleMapName = ModuleName +
".modulemap";
2289 ModuleMapName =
"module.modulemap";
2297 if (!ModuleWasSuccessfullyLoaded) {
2299 clang::HeaderSearch &headerSearch = PP.getHeaderSearchInfo();
2300 clang::ModuleMap &moduleMap = headerSearch.getModuleMap();
2301 if (moduleMap.findModule(ModuleName))
2302 Info(
"TCling::RegisterModule",
"Module %s in modulemap failed to load.", ModuleName.c_str());
2307 llvm::SmallString<256> pcmFileNameFullPath(dyLibName);
2310 llvm::sys::fs::make_absolute(pcmFileNameFullPath);
2311 llvm::sys::path::remove_filename(pcmFileNameFullPath);
2312 llvm::sys::path::append(pcmFileNameFullPath,
2314 LoadPCM(pcmFileNameFullPath.str().str());
2321 clangDiagSuppr diagSuppr(TheSema.getDiagnostics());
2323#if defined(R__MUST_REVISIT)
2324#if R__MUST_REVISIT(6,2)
2325 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
2329 if (!ModuleWasSuccessfullyLoaded && !hasHeaderParsingOnDemand){
2332 const cling::Transaction* watermark =
fInterpreter->getLastTransaction();
2333 cling::Interpreter::CompilationResult compRes =
fInterpreter->parseForModule(code.
Data());
2339 assert(cling::Interpreter::kSuccess == compRes &&
2340 "Payload code of a dictionary could not be parsed correctly.");
2341 if (compRes!=cling::Interpreter::kSuccess) {
2342 Warning(
"TCling::RegisterModule",
2343 "Problems declaring payload for module %s.", modulename) ;
2356 if (!ModuleWasSuccessfullyLoaded && !hasHeaderParsingOnDemand) {
2359 "#undef __ROOTCLING__\n"
2360 + gInterpreterClassDef +
2365 assert(isSharedLib);
2368 dlclose(dyLibHandle);
2374 ASTContext &C = CI.getASTContext();
2382 if (IdentifierInfoLookup *External = C.Idents.getExternalIdentifierLookup()) {
2383 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
2384 for (llvm::StringRef Ident = Iter->Next(); !Ident.empty(); Ident = Iter->Next()) {
2385 std::string
I = Ident.str();
2409 typedef std::vector<std::pair<TClass*,DictFuncPtr_t> >::iterator iterator;
2415 if ( i->first == oldcl ) {
2438 const char* input_line,
2439 cling::Interpreter::CompilationResult& compRes,
2440 cling::Value* result)
2443 return metaProcessor->process(input_line, compRes, result);
2445 catch (cling::InterpreterException&
ex)
2447 Error(
"HandleInterpreterException",
"%s.\n%s",
ex.what(),
"Execution of your code was aborted.");
2449 compRes = cling::Interpreter::kFailure;
2458 if (
auto ie =
dynamic_cast<const cling::InterpreterException*
>(&
e)) {
2484 gROOT->SetLineIsProcessing();
2488 gROOT->SetLineHasBeenProcessed();
2501 gROOT->SetLineIsProcessing();
2503 struct InterpreterFlagsRAII {
2504 cling::Interpreter* fInterpreter;
2505 bool fWasDynamicLookupEnabled;
2507 InterpreterFlagsRAII(cling::Interpreter* interp):
2508 fInterpreter(interp),
2509 fWasDynamicLookupEnabled(interp->isDynamicLookupEnabled())
2511 fInterpreter->enableDynamicLookup(
true);
2513 ~InterpreterFlagsRAII() {
2514 fInterpreter->enableDynamicLookup(fWasDynamicLookupEnabled);
2515 gROOT->SetLineHasBeenProcessed();
2523 cling::Value result;
2524 cling::Interpreter::CompilationResult compRes = cling::Interpreter::kSuccess;
2525 if (!strncmp(sLine.
Data(),
".L", 2) || !strncmp(sLine.
Data(),
".x", 2) ||
2526 !strncmp(sLine.
Data(),
".X", 2)) {
2534 aclicMode, arguments, io);
2535 if (aclicMode.
Length()) {
2537 R__ASSERT(aclicMode[0]==
'+' &&
"ACLiC mode must start with a +");
2539 if (aclicMode[1]==
'+') {
2545 compRes = cling::Interpreter::kFailure;
2547 if (strncmp(sLine.
Data(),
".L", 2) != 0) {
2550 if (arguments.
Length()==0) {
2559 mod_line = function + arguments + io;
2565 size_t unnamedMacroOpenCurly;
2568 std::string codeline;
2571 std::ifstream in(fname, std::ifstream::binary);
2573 std::getline(in, codeline);
2574 code += codeline +
"\n";
2576 unnamedMacroOpenCurly
2577 = cling::utils::isUnnamedMacro(code,
fInterpreter->getCI()->getLangOpts());
2581 if (unnamedMacroOpenCurly != std::string::npos) {
2583 unnamedMacroOpenCurly);
2593 if (0!=strncmp(sLine.
Data(),
".autodict ",10) && sLine !=
".autodict") {
2598 bool isInclusionDirective = sLine.
Contains(
"\n#include") || sLine.
BeginsWith(
"#include");
2599 if (isInclusionDirective) {
2607 if (result.isValid())
2616 case cling::Interpreter::kSuccess: *error =
kNoError;
break;
2617 case cling::Interpreter::kFailure: *error =
kRecoverable;
break;
2618 case cling::Interpreter::kMoreInputExpected: *error =
kProcessing;
break;
2621 if (compRes == cling::Interpreter::kSuccess
2623 && !result.isVoid())
2625 return result.simplisticCastAs<
Longptr_t>();
2652 if (path[0] ==
'-' && path[1] ==
'I')
2677 static const TClassRef clRefString(
"std::string");
2678 if (clRefString == cl) {
2688 const char* cobj = (
const char*) obj;
2695 auto inspInspect = [&] (ptrdiff_t offset){
2701 switch(complexType) {
2708 inspInspect(
sizeof(
float));
2713 inspInspect(
sizeof(
double));
2718 inspInspect(
sizeof(
int));
2723 inspInspect(
sizeof(
long));
2728 static clang::PrintingPolicy
2730 if (printPol.Indentation) {
2732 printPol.Indentation = 0;
2733 printPol.SuppressInitializers =
true;
2736 const char* clname = cl->
GetName();
2739 const clang::ASTContext& astContext =
fInterpreter->getCI()->getASTContext();
2740 const clang::Decl *scopeDecl = 0;
2741 const clang::Type *recordType = 0;
2745 scopeDecl = clingCI->
GetDecl();
2746 recordType = clingCI->
GetType();
2748 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
2750 scopeDecl = lh.findScope(clname, cling::LookupHelper::NoDiagnostics,
2754 Error(
"InspectMembers",
"Cannot find Decl for class %s", clname);
2757 const clang::CXXRecordDecl* recordDecl
2758 = llvm::dyn_cast<const clang::CXXRecordDecl>(scopeDecl);
2760 Error(
"InspectMembers",
"Cannot find Decl for class %s is not a CXXRecordDecl.", clname);
2769 astContext.getASTRecordLayout(recordDecl);
2771 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2772 eField = recordDecl->field_end(); iField != eField; ++iField) {}
2775 const clang::ASTRecordLayout& recLayout
2776 = astContext.getASTRecordLayout(recordDecl);
2783 if (cl->
Size() != recLayout.getSize().getQuantity()) {
2784 Error(
"InspectMembers",
"TClass and cling disagree on the size of the class %s, respectively %d %lld\n",
2788 unsigned iNField = 0;
2791 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2792 eField = recordDecl->field_end(); iField != eField;
2793 ++iField, ++iNField) {
2796 clang::QualType memberQT = iField->getType();
2801 memberQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, memberQT,
fNormalizedCtxt->
GetConfig(),
false );
2802 if (memberQT.isNull()) {
2803 std::string memberName;
2804 llvm::raw_string_ostream stream(memberName);
2806 printPol.AnonymousTagLocations =
false;
2807 iField->getNameForDiagnostic(stream, printPol,
true );
2809 Error(
"InspectMembers",
2810 "Cannot retrieve QualType for member %s while inspecting class %s",
2811 memberName.c_str(), clname);
2814 const clang::Type* memType = memberQT.getTypePtr();
2816 std::string memberName;
2817 llvm::raw_string_ostream stream(memberName);
2819 printPol.AnonymousTagLocations =
false;
2820 iField->getNameForDiagnostic(stream, printPol,
true );
2822 Error(
"InspectMembers",
2823 "Cannot retrieve Type for member %s while inspecting class %s",
2824 memberName.c_str(), clname);
2828 const clang::Type* memNonPtrType = memType;
2829 Bool_t ispointer =
false;
2830 if (memNonPtrType->isPointerType()) {
2832 clang::QualType ptrQT
2833 = memNonPtrType->getAs<clang::PointerType>()->getPointeeType();
2838 ptrQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, ptrQT,
fNormalizedCtxt->
GetConfig(),
false );
2839 if (ptrQT.isNull()) {
2840 std::string memberName;
2841 llvm::raw_string_ostream stream(memberName);
2843 printPol.AnonymousTagLocations =
false;
2844 iField->getNameForDiagnostic(stream, printPol,
true );
2846 Error(
"InspectMembers",
2847 "Cannot retrieve pointee Type for member %s while inspecting class %s",
2848 memberName.c_str(), clname);
2851 memNonPtrType = ptrQT.getTypePtr();
2855 llvm::SmallString<8> arraySize;
2856 const clang::ArrayType* arrType = memNonPtrType->getAsArrayTypeUnsafe();
2857 unsigned arrLevel = 0;
2858 bool haveErrorDueToArray =
false;
2862 const clang::ConstantArrayType* constArrType =
2863 clang::dyn_cast<clang::ConstantArrayType>(arrType);
2865 constArrType->getSize().toStringUnsigned(arraySize);
2868 clang::QualType subArrQT = arrType->getElementType();
2869 if (subArrQT.isNull()) {
2870 std::string memberName;
2871 llvm::raw_string_ostream stream(memberName);
2873 printPol.AnonymousTagLocations =
false;
2874 iField->getNameForDiagnostic(stream, printPol,
true );
2876 Error(
"InspectMembers",
2877 "Cannot retrieve QualType for array level %d (i.e. element type of %s) for member %s while inspecting class %s",
2878 arrLevel, subArrQT.getAsString(printPol).c_str(),
2879 memberName.c_str(), clname);
2880 haveErrorDueToArray =
true;
2883 arrType = subArrQT.getTypePtr()->getAsArrayTypeUnsafe();
2885 if (haveErrorDueToArray) {
2890 std::string fieldName;
2891 if (memType->isPointerType()) {
2896 std::string ioname(iField->getName());
2898 fieldName += ioname;
2899 fieldName += arraySize;
2904 clang::CharUnits offset(astContext.toCharUnitsFromBits(recLayout.getFieldOffset(iNField)));
2905 ptrdiff_t fieldOffset = offset.getQuantity();
2915 auto iFiledQtype = iField->getType();
2916 if (
auto tagDecl = iFiledQtype->getAsTagDecl()){
2917 auto declAccess = tagDecl->getAccess();
2918 if (declAccess == AS_private || declAccess == AS_protected) {
2924 insp.
Inspect(
const_cast<TClass*
>(cl), insp.
GetParent(), fieldName.c_str(), cobj + fieldOffset, isTransient);
2927 const clang::CXXRecordDecl* fieldRecDecl = memNonPtrType->getAsCXXRecordDecl();
2928 if (fieldRecDecl && !fieldRecDecl->isAnonymousStructOrUnion()) {
2931 std::string sFieldRecName;
2934 clang::QualType(memNonPtrType,0),
2944 insp.
InspectMember(sFieldRecName.c_str(), cobj + fieldOffset,
2945 (fieldName +
'.').c_str(), transient);
2953 unsigned iNBase = 0;
2954 for (clang::CXXRecordDecl::base_class_const_iterator iBase
2955 = recordDecl->bases_begin(), eBase = recordDecl->bases_end();
2956 iBase != eBase; ++iBase, ++iNBase) {
2957 clang::QualType baseQT = iBase->getType();
2958 if (baseQT.isNull()) {
2959 Error(
"InspectMembers",
2960 "Cannot find QualType for base number %d while inspecting class %s",
2964 const clang::CXXRecordDecl* baseDecl
2965 = baseQT->getAsCXXRecordDecl();
2967 Error(
"InspectMembers",
2968 "Cannot find CXXRecordDecl for base number %d while inspecting class %s",
2973 std::string sBaseName;
2975 std::vector<TClass*> foundClasses;
2977 if (foundClasses.size()==1){
2978 baseCl=foundClasses[0];
2991 std::string qualNameForDiag;
2993 Error(
"InspectMembers",
2994 "Cannot find TClass for base class %s", qualNameForDiag.c_str() );
2999 if (iBase->isVirtual()) {
3002 Error(
"InspectMembers",
3003 "Base %s of class %s is virtual but no object provided",
3004 sBaseName.c_str(), clname);
3012 baseOffset = ci->
GetBaseOffset(baseCi,
const_cast<void*
>(obj),
3014 if (baseOffset == -1) {
3015 Error(
"InspectMembers",
3016 "Error calculating offset of virtual base %s of class %s",
3017 sBaseName.c_str(), clname);
3020 Error(
"InspectMembers",
3021 "Cannot calculate offset of virtual base %s of class %s",
3022 sBaseName.c_str(), clname);
3027 baseOffset = recLayout.getBaseClassOffset(baseDecl).getQuantity();
3074 bool oldDynLookup =
fInterpreter->isDynamicLookupEnabled();
3103 return fInterpreter->getDynamicLibraryManager()->isLibraryLoaded(tLibName.
Data());
3118 llvm::StringRef ModuleName(libname);
3119 ModuleName = llvm::sys::path::stem(ModuleName);
3120 ModuleName.consume_front(
"lib");
3128 clang::ModuleMap &moduleMap =
fInterpreter->getCI()->getPreprocessor().getHeaderSearchInfo().getModuleMap();
3129 clang::Module *M = moduleMap.findModule(ModuleName);
3130 return M && !M->IsMissingRequirement && M->getASTFile();
3148 std::string file_name = filename;
3149 size_t at = std::string::npos;
3150 while ((at = file_name.find(
"/./")) != std::string::npos)
3151 file_name.replace(at, 3,
"/");
3153 std::string filesStr =
"";
3154 llvm::raw_string_ostream filesOS(filesStr);
3155 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
3156 cling::ClangInternalState::printIncludedFiles(filesOS, SM);
3159 llvm::SmallVector<llvm::StringRef, 100> files;
3160 llvm::StringRef(filesStr).split(files,
"\n");
3162 std::set<std::string> fileMap;
3164 for (llvm::SmallVector<llvm::StringRef, 100>::const_iterator
3165 iF = files.begin(), iE = files.end(); iF != iE; ++iF) {
3166 if ((*iF) == file_name.c_str())
return kTRUE;
3167 fileMap.insert(*iF);
3170 if (fileMap.empty())
return kFALSE;
3173 TString sFilename(file_name.c_str());
3175 && fileMap.count(sFilename.
Data())) {
3183 while (incPath.
Index(
" :") != -1) {
3187 sFilename = file_name.c_str();
3189 && fileMap.count(sFilename.
Data())) {
3198 const clang::DirectoryLookup *CurDir = 0;
3199 clang::Preprocessor &PP =
fInterpreter->getCI()->getPreprocessor();
3200 clang::HeaderSearch &HS = PP.getHeaderSearchInfo();
3201 const clang::FileEntry *FE = HS.LookupFile(file_name.c_str(),
3202 clang::SourceLocation(),
3205 clang::ArrayRef<std::pair<
const clang::FileEntry *,
3206 const clang::DirectoryEntry *>>(),
3217 if (FE && FE->isValid()) {
3219 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
3221 clang::FileID FID = SM.translateFile(FE);
3222 if (!FID.isInvalid() && FID.getHashValue() == 0)
3225 clang::SrcMgr::SLocEntry SLocE = SM.getSLocEntry(FID);
3226 if (SLocE.isFile() && SLocE.getFile().getContentCache()->getRawBuffer() == 0)
3228 if (!FID.isInvalid())
3232 sFilename = FE->getName();
3234 && fileMap.count(sFilename.
Data())) {
3242#if defined(R__MACOSX)
3250static bool R__UpdateLibFileForLinking(
TString &lib)
3252 const char *mapfile =
nullptr;
3254 mapfile =
"/System/Library/dyld/dyld_shared_cache_x86_64.map";
3256 mapfile =
"/System/Library/dyld/dyld_shared_cache_arm64e.map";
3258 #error unsupported architecture
3260 if (std::ifstream cacheMap{mapfile}) {
3262 while (getline(cacheMap,
line)) {
3263 if (
line.find(lib) != std::string::npos) {
3281static int callback_for_dl_iterate_phdr(
struct dl_phdr_info *info,
size_t size,
void *data)
3284 static std::unordered_set<
decltype(info->dlpi_addr)> sKnownLoadedLibBaseAddrs;
3286 auto newLibs =
static_cast<std::vector<std::string>*
>(data);
3287 if (!sKnownLoadedLibBaseAddrs.count(info->dlpi_addr)) {
3289 if (info->dlpi_name && info->dlpi_name[0]
3290 && strncmp(info->dlpi_name,
"linux-vdso.so", 13)
3291 && strncmp(info->dlpi_name,
"linux-vdso32.so", 15)
3292 && strncmp(info->dlpi_name,
"linux-vdso64.so", 15)
3293 && strncmp(info->dlpi_name,
"linux-gate.so", 13))
3294 newLibs->emplace_back(info->dlpi_name);
3295 sKnownLoadedLibBaseAddrs.insert(info->dlpi_addr);
3308#if defined(R__WIN32) || defined(__CYGWIN__)
3309 HMODULE hModules[1024];
3311 unsigned long cbModules;
3313 hProcess = (
void *)::GetCurrentProcess();
3314 ::EnumProcessModules(hProcess, hModules,
sizeof(hModules), &cbModules);
3316 for (i = 1; i < (cbModules /
sizeof(
void *)); i++) {
3317 static const int bufsize = 260;
3318 wchar_t winname[bufsize];
3319 char posixname[bufsize];
3320 ::GetModuleFileNameExW(hProcess, hModules[i], winname, bufsize);
3321#if defined(__CYGWIN__)
3322 cygwin_conv_path(CCP_WIN_W_TO_POSIX, winname, posixname, bufsize);
3324 std::wstring wpath = winname;
3325 std::replace(wpath.begin(), wpath.end(),
'\\',
'/');
3326 string path(wpath.begin(), wpath.end());
3327 strncpy(posixname, path.c_str(), bufsize);
3333#elif defined(R__MACOSX)
3337 while (
const mach_header* mh = _dyld_get_image_header(imageIndex)) {
3339 if (mh->filetype == MH_DYLIB) {
3340 if (
const char* imageName = _dyld_get_image_name(imageIndex)) {
3348#elif defined(R__LINUX)
3352 std::vector<std::string> newLibs;
3353 dl_iterate_phdr(callback_for_dl_iterate_phdr, &newLibs);
3354 for (
auto &&lib: newLibs)
3357 Error(
"TCling::UpdateListOfLoadedSharedLibraries",
3358 "Platform not supported!");
3364static bool StartsWithStrLit(
const char *haystack,
const char (&needle)[
N]) {
3365 return !strncmp(haystack, needle,
N - 1);
3376 if (!filename)
return;
3380 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
3381 if (!DLM->isLibraryLoaded(filename)) {
3382 DLM->loadLibrary(filename,
true ,
true );
3385#if defined(R__MACOSX)
3387 auto lenFilename = strlen(filename);
3388 auto isInMacOSSystemDir = [](
const char *fn) {
3389 return StartsWithStrLit(fn,
"/usr/lib/") || StartsWithStrLit(fn,
"/System/Library/");
3391 if (!strcmp(filename,
"cl_kernels")
3394 || StartsWithStrLit(filename,
"/usr/lib/system/")
3395 || StartsWithStrLit(filename,
"/usr/lib/libc++")
3396 || StartsWithStrLit(filename,
"/System/Library/Frameworks/")
3397 || StartsWithStrLit(filename,
"/System/Library/PrivateFrameworks/")
3398 || StartsWithStrLit(filename,
"/System/Library/CoreServices/")
3399 || StartsWithStrLit(filename,
"/usr/lib/libSystem")
3400 || StartsWithStrLit(filename,
"/usr/lib/libstdc++")
3401 || StartsWithStrLit(filename,
"/usr/lib/libicucore")
3402 || StartsWithStrLit(filename,
"/usr/lib/libbsm")
3403 || StartsWithStrLit(filename,
"/usr/lib/libobjc")
3404 || StartsWithStrLit(filename,
"/usr/lib/libresolv")
3405 || StartsWithStrLit(filename,
"/usr/lib/libauto")
3406 || StartsWithStrLit(filename,
"/usr/lib/libcups")
3407 || StartsWithStrLit(filename,
"/usr/lib/libDiagnosticMessagesClient")
3408 || StartsWithStrLit(filename,
"/usr/lib/liblangid")
3409 || StartsWithStrLit(filename,
"/usr/lib/libCRFSuite")
3410 || StartsWithStrLit(filename,
"/usr/lib/libpam")
3411 || StartsWithStrLit(filename,
"/usr/lib/libOpenScriptingUtil")
3412 || StartsWithStrLit(filename,
"/usr/lib/libextension")
3413 || StartsWithStrLit(filename,
"/usr/lib/libAudioToolboxUtility")
3414 || StartsWithStrLit(filename,
"/usr/lib/liboah")
3415 || StartsWithStrLit(filename,
"/usr/lib/libRosetta")
3416 || StartsWithStrLit(filename,
"/usr/lib/libCoreEntitlements")
3417 || StartsWithStrLit(filename,
"/usr/lib/libssl.")
3418 || StartsWithStrLit(filename,
"/usr/lib/libcrypto.")
3424 || StartsWithStrLit(filename,
"/usr/lib/system/libsystem_kernel")
3425 || StartsWithStrLit(filename,
"/usr/lib/system/libsystem_platform")
3426 || StartsWithStrLit(filename,
"/usr/lib/system/libsystem_pthread")
3431 || (lenFilename > 4 && !strcmp(filename + lenFilename - 4,
".tbd")))
3434 R__UpdateLibFileForLinking(sFileName);
3435 filename = sFileName.
Data();
3436#elif defined(__CYGWIN__)
3438 static const int bufsize = 260;
3439 char posixwindir[bufsize];
3440 char *windir = getenv(
"WINDIR");
3442 cygwin_conv_path(CCP_WIN_A_TO_POSIX, windir, posixwindir, bufsize);
3444 snprintf(posixwindir,
sizeof(posixwindir),
"/Windows/");
3445 if (strstr(filename, posixwindir) ||
3446 strstr(filename,
"/usr/bin/cyg"))
3448#elif defined(R__WIN32)
3449 if (strstr(filename,
"/Windows/"))
3451#elif defined (R__LINUX)
3452 if (strstr(filename,
"/ld-linux")
3453 || strstr(filename,
"linux-gnu/")
3454 || strstr(filename,
"/libstdc++.")
3455 || strstr(filename,
"/libgcc")
3456 || strstr(filename,
"/libc.")
3457 || strstr(filename,
"/libdl.")
3458 || strstr(filename,
"/libm."))
3475 assert(!
IsFromRootCling() &&
"Trying to load library from rootcling!");
3479 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
3480 std::string canonLib = DLM->lookupLibrary(filename);
3481 cling::DynamicLibraryManager::LoadLibResult res
3482 = cling::DynamicLibraryManager::kLoadLibNotFound;
3483 if (!canonLib.empty()) {
3485 res = DLM->loadLibrary(filename, system,
true);
3489 cling::Interpreter::CompilationResult compRes;
3491 if (compRes == cling::Interpreter::kSuccess)
3492 res = cling::DynamicLibraryManager::kLoadLibSuccess;
3496 if (res == cling::DynamicLibraryManager::kLoadLibSuccess) {
3500 case cling::DynamicLibraryManager::kLoadLibSuccess:
return 0;
3501 case cling::DynamicLibraryManager::kLoadLibAlreadyLoaded:
return 1;
3551 Warning(
"Calc",
"waiting for cling thread to free");
3554 gROOT->SetLineIsProcessing();
3561 cling::Value valRef;
3562 cling::Interpreter::CompilationResult cr = cling::Interpreter::kFailure;
3566 catch (cling::InterpreterException&
ex)
3568 Error(
"Calc",
"%s.\n%s",
ex.what(),
"Evaluation of your expression was aborted.");
3570 cr = cling::Interpreter::kFailure;
3573 if (cr != cling::Interpreter::kSuccess) {
3581 if (!valRef.isValid()) {
3590 if (valRef.isVoid()) {
3597 gROOT->SetLineHasBeenProcessed();
3600 return valRef.simplisticCastAs<
Longptr_t>();
3607 void (*histaddFunc)(
const char*
line))
3612#if defined(R__MUST_REVISIT)
3613#if R__MUST_REVISIT(6,2)
3614 Warning(
"SetGetline",
"Cling should support the equivalent of SetGetlineFunc(getlineFunc, histaddFunc)");
3627 if ((std::distance(T.decls_begin(), T.decls_end()) != 1)
3628 || T.deserialized_decls_begin() != T.deserialized_decls_end()
3629 || T.macros_begin() != T.macros_end()
3630 || ((!T.getFirstDecl().isNull()) && ((*T.getFirstDecl().begin()) != T.getWrapperFD()))) {
3653 std::set<TObject*>::iterator iSpecial = ((std::set<TObject*>*)
fgSetOfSpecials)->find(obj);
3671#if defined(R__MUST_REVISIT)
3672#if R__MUST_REVISIT(6,2)
3674 Warning(
"Reset",
"Cling should support the equivalent of scratch_upto(&fDictPos)");
3684#if defined(R__MUST_REVISIT)
3685#if R__MUST_REVISIT(6,2)
3687 Warning(
"ResetAll",
"Cling should support the equivalent of complete reset (unload everything but the startup decls.");
3714#if defined(R__MUST_REVISIT)
3715#if R__MUST_REVISIT(6,2)
3717 Warning(
"ResetGlobalVar",
"Cling should support the equivalent of resetglobalvar(obj)");
3729#if defined(R__MUST_REVISIT)
3730#if R__MUST_REVISIT(6,2)
3732 Warning(
"RewindDictionary",
"Cling should provide a way to revert transaction similar to rewinddictionary()");
3743#if defined(R__MUST_REVISIT)
3744#if R__MUST_REVISIT(6,2)
3746 Warning(
"DeleteGlobal",
"Cling should provide the equivalent of deleteglobal(obj), see also DeleteVariable.");
3758#if defined(R__MUST_REVISIT)
3759#if R__MUST_REVISIT(6,2)
3760 Warning(
"DeleteVariable",
"should do more that just reseting the value to zero");
3765 llvm::StringRef srName(
name);
3766 const char* unscopedName =
name;
3767 llvm::StringRef::size_type posScope = srName.rfind(
"::");
3768 const clang::DeclContext* declCtx = 0;
3769 if (posScope != llvm::StringRef::npos) {
3770 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
3771 const clang::Decl* scopeDecl
3772 = lh.findScope(srName.substr(0, posScope),
3773 cling::LookupHelper::WithDiagnostics);
3775 Error(
"DeleteVariable",
"Cannot find enclosing scope for variable %s",
3779 declCtx = llvm::dyn_cast<clang::DeclContext>(scopeDecl);
3781 Error(
"DeleteVariable",
3782 "Enclosing scope for variable %s is not a declaration context",
3786 unscopedName += posScope + 2;
3790 clang::NamedDecl* nVarDecl
3791 = cling::utils::Lookup::Named(&
fInterpreter->getSema(), unscopedName, declCtx);
3793 Error(
"DeleteVariable",
"Unknown variable %s",
name);
3796 clang::VarDecl* varDecl = llvm::dyn_cast<clang::VarDecl>(nVarDecl);
3798 Error(
"DeleteVariable",
"Entity %s is not a variable",
name);
3802 clang::QualType qType = varDecl->getType();
3803 const clang::Type*
type = qType->getUnqualifiedDesugaredType();
3806 if (
type->isPointerType()) {
3807 int** ppInt = (
int**)
fInterpreter->getAddressOfGlobal(GlobalDecl(varDecl));
3809 if (ppInt) *ppInt = 0;
3819#if defined(R__MUST_REVISIT)
3820#if R__MUST_REVISIT(6,2)
3822 Warning(
"SaveContext",
"Cling should provide a way to record a state watermark similar to store_dictposition(&fDictPos)");
3832#if defined(R__MUST_REVISIT)
3833#if R__MUST_REVISIT(6,2)
3835 Warning(
"SaveGlobalsContext",
"Cling should provide a way to record a watermark for the list of global variable similar to store_dictposition(&fDictPosGlobals)");
3883 std::tuple<int,double> value;
3887 size_t offset0 = ((
char*)&(std::get<0>(value))) - ((
char*)&value);
3888 size_t offset1 = ((
char*)&(std::get<1>(value))) - ((
char*)&value);
3890 size_t ascOffset0 = ((
char*)&(asc.
_0)) - ((
char*)&asc);
3891 size_t ascOffset1 = ((
char*)&(asc.
_1)) - ((
char*)&asc);
3893 size_t desOffset0 = ((
char*)&(des.
_0)) - ((
char*)&des);
3894 size_t desOffset1 = ((
char*)&(des.
_1)) - ((
char*)&des);
3896 if (offset0 == ascOffset0 && offset1 == ascOffset1) {
3898 }
else if (offset0 == desOffset0 && offset1 == desOffset1) {
3905static std::string
AlternateTuple(
const char *classname,
const cling::LookupHelper& lh)
3908 std::string alternateName =
"TEmulatedTuple";
3909 alternateName.append( classname + 5 );
3911 std::string fullname =
"ROOT::Internal::" + alternateName;
3912 if (lh.findScope(fullname, cling::LookupHelper::NoDiagnostics,
3916 std::string guard_name;
3918 std::ostringstream guard;
3919 guard <<
"ROOT_INTERNAL_TEmulated_";
3920 guard << guard_name;
3922 std::ostringstream alternateTuple;
3923 alternateTuple <<
"#ifndef " << guard.str() <<
"\n";
3924 alternateTuple <<
"#define " << guard.str() <<
"\n";
3925 alternateTuple <<
"namespace ROOT { namespace Internal {\n";
3926 alternateTuple <<
"template <class... Types> struct TEmulatedTuple;\n";
3927 alternateTuple <<
"template <> struct " << alternateName <<
" {\n";
3932 unsigned int nMember = 0;
3933 auto iter = tupleContent.
fElements.begin() + 1;
3934 auto theEnd = tupleContent.
fElements.end() - 1;
3935 while (iter != theEnd) {
3936 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
3943 unsigned int nMember = tupleContent.
fElements.size() - 3;
3944 auto iter = tupleContent.
fElements.rbegin() + 1;
3945 auto theEnd = tupleContent.
fElements.rend() - 1;
3946 while (iter != theEnd) {
3947 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
3954 Fatal(
"TCling::SetClassInfo::AlternateTuple",
3955 "Layout of std::tuple on this platform is unexpected.");
3960 alternateTuple <<
"};\n";
3961 alternateTuple <<
"}}\n";
3962 alternateTuple <<
"#endif\n";
3964 Error(
"Load",
"Could not declare %s",alternateName.c_str());
3967 alternateName =
"ROOT::Internal::" + alternateName;
3968 return alternateName;
4011 if (strncmp(cl->
GetName(),
"tuple<",strlen(
"tuple<"))==0) {
4047 zombieCandidate =
kTRUE;
4054 zombieCandidate =
kTRUE;
4108 static const char *anonEnum =
"anonymous enum ";
4109 static const int cmplen = strlen(anonEnum);
4136 const char *classname =
name;
4139 class MaybeSuspendAutoLoadParse {
4140 int fStoreAutoLoad = 0;
4141 int fStoreAutoParse = 0;
4142 bool fSuspendedAutoParse =
false;
4144 MaybeSuspendAutoLoadParse(
int autoload) {
4145 fStoreAutoLoad = ((
TCling*)
gCling)->SetClassAutoLoading(autoload);
4149 fSuspendedAutoParse =
true;
4150 fStoreAutoParse = ((
TCling*)
gCling)->SetSuspendAutoParsing(
true);
4153 ~MaybeSuspendAutoLoadParse() {
4154 if (fSuspendedAutoParse)
4155 ((
TCling*)
gCling)->SetSuspendAutoParsing(fStoreAutoParse);
4156 ((
TCling*)
gCling)->SetClassAutoLoading(fStoreAutoLoad);
4160 MaybeSuspendAutoLoadParse autoLoadParseRAII( autoload );
4162 autoLoadParseRAII.SuspendAutoParsing();
4171 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
4172 const clang::Type *
type = 0;
4173 const clang::Decl *decl
4174 = lh.findScope(classname,
4175 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4176 : cling::LookupHelper::NoDiagnostics,
4180 decl = lh.findScope(buf,
4181 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4182 : cling::LookupHelper::NoDiagnostics,
4199 clang::ClassTemplateSpecializationDecl *tmpltDecl =
4200 llvm::dyn_cast_or_null<clang::ClassTemplateSpecializationDecl>
4201 (
type->getAsCXXRecordDecl());
4202 if (tmpltDecl && !tmpltDecl->getPointOfInstantiation().isValid()) {
4219 if (tci.
Property() & propertiesMask) {
4220 bool hasClassDefInline =
false;
4221 if (isClassOrNamespaceOnly) {
4227 if (hasDictionary.IsValid() && implLineFunc.IsValid()) {
4229 bool success =
false;
4230 std::tie(success, lineNumber) =
4232 hasClassDefInline = success && (lineNumber == -1);
4240 if (hasClassDefInline)
4279 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
4280 const clang::Decl *decl
4281 = lh.findClassTemplate(
name,
4282 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4283 : cling::LookupHelper::NoDiagnostics);
4285 std::string strname =
"std::";
4287 decl = lh.findClassTemplate(strname,
4288 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4289 : cling::LookupHelper::NoDiagnostics);
4315 cl->
fBase = listOfBase;
4331 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
4334 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
4337 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
4338 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
4339 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(), declEnd = allDeclContexts.end();
4340 declIter != declEnd; ++declIter) {
4342 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
4343 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
4344 if (
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(*DI)) {
4347 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
4348 llvm::raw_string_ostream stream(buf);
4350 Policy.AnonymousTagLocations =
false;
4351 ED->getNameForDiagnostic(stream, Policy,
false);
4355 const char*
name = buf.c_str();
4379 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
4383 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
4386 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
4387 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
4388 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(),
4389 declEnd = allDeclContexts.end(); declIter != declEnd; ++declIter) {
4391 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
4392 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
4393 if (
const clang::FunctionTemplateDecl* FTD = dyn_cast<clang::FunctionTemplateDecl>(*DI)) {
4394 funcTempList->
Get(FTD);
4452 if (
m->fMethodArgs) {
4463 m->fMethodArgs = arglist;
4502 if (llvm::isa<clang::NamespaceDecl>(cli->
GetDecl())) {
4511 Error(
"GenerateTClass",
4512 "Cannot find %s::Class_Version()! Class version might be wrong.",
4519 if (newvers == -1) {
4527 newvers = callfunc.
ExecInt(0);
4529 Error(
"GenerateTClass",
4530 "Cannot invoke %s::Class_Version()! Class version might be wrong.",
4534 if (newvers != oldvers) {
4551static void GenerateTClass_GatherInnerIncludes(cling::Interpreter *interp,
TString &includes,
TClingClassInfo *info)
4555 const clang::ClassTemplateSpecializationDecl *templateCl
4556 = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(info->
GetDecl());
4558 for(
unsigned int i=0; i < templateCl->getTemplateArgs().
size(); ++i) {
4559 const clang::TemplateArgument &arg( templateCl->getTemplateArgs().get(i) );
4560 if (arg.getKind() == clang::TemplateArgument::Type) {
4563 if (!uType->isFundamentalType() && !uType->isEnumeralType()) {
4565 const clang::CXXRecordDecl *argdecl = uType->getAsCXXRecordDecl();
4568 TClingClassInfo subinfo(interp,*(argdecl->getASTContext().getRecordType(argdecl).getTypePtr()));
4569 GenerateTClass_GatherInnerIncludes(interp, includes, &subinfo);
4572 llvm::raw_string_ostream OS(Result);
4573 arg.print(argdecl->getASTContext().getPrintingPolicy(),OS);
4574 Warning(
"TCling::GenerateTClass",
"Missing header file for %s",OS.str().c_str());
4589 if (!info || !info->
IsValid()) {
4590 Fatal(
"GenerateTClass",
"Requires a valid ClassInfo object");
4595 std::string classname;
4599 Info(
"GenerateTClass",
"Will (try to) generate the compiled TClass for %s.",classname.c_str());
4603 GenerateTClass_GatherInnerIncludes(
fInterpreter,includes,info);
4609 Error(
"GenerateTClass",
"Even though the dictionary generation for %s seemed successful we can't find the TClass bootstrap!",classname.c_str());
4615 cl =
new TClass(classinfo, version, 0, 0, -1, -1, silent);
4621 cl =
new TClass(classinfo, 1, 0, 0, -1, -1, silent);
4646 if (classes == 0 || classes[0] == 0) {
4647 Error(
"TCling::GenerateDictionary",
"Cannot generate dictionary without passing classes.");
4651 std::vector<std::string> listClasses;
4653 const char* current = classes, *prev = classes;
4657 if (*current ==
';') {
4658 listClasses.push_back(std::string(prev, current - prev));
4661 else if (*(current + 1) == 0) {
4662 listClasses.push_back(std::string(prev, current + 1 - prev));
4666 std::vector<std::string> listIncludes;
4670 const char* current = includes, *prev = includes;
4674 if (*current ==
';') {
4675 listIncludes.push_back(std::string(prev, current - prev));
4678 else if (*(current + 1) == 0) {
4679 listIncludes.push_back(std::string(prev, current + 1 - prev));
4685 std::vector<std::string>(), std::vector<std::string>());
4706 if (
const ValueDecl* decl = (
const ValueDecl*)
d){
4709 if (hasIoName && ioName !=
name)
return 0;
4721 using namespace clang;
4723 DeclarationName DName = &SemaR.Context.Idents.get(
name);
4725 LookupResult
R(SemaR, DName, SourceLocation(), Sema::LookupOrdinaryName,
4726 Sema::ForExternalRedeclaration);
4730 cling::utils::Lookup::Named(&SemaR,
R);
4732 LookupResult::Filter
F =
R.makeFilter();
4734 while (
F.hasNext()) {
4735 NamedDecl *D =
F.next();
4736 if (isa<VarDecl>(D) || isa<FieldDecl>(D) || isa<EnumConstantDecl>(D) ||
4737 isa<IndirectFieldDecl>(D))
4743 if (
R.isSingleResult())
4744 return R.getFoundDecl();
4756 const clang::Decl* possibleEnum = 0;
4761 const clang::DeclContext* dc = 0;
4762 if (
const clang::Decl* D = cci->
GetDecl()) {
4763 if (!(dc = dyn_cast<clang::NamespaceDecl>(D))) {
4764 dc = dyn_cast<clang::RecordDecl>(D);
4771 possibleEnum = cling::utils::Lookup::Tag(&
fInterpreter->getSema(),
name, dc);
4773 Error(
"TCling::GetEnum",
"DeclContext not found for %s .\n",
name);
4782 if (possibleEnum && (possibleEnum != (clang::Decl*)-1)
4783 && isa<clang::EnumDecl>(possibleEnum)) {
4784 return possibleEnum;
4796 llvm::StringRef mangled_name = gv->getName();
4811 std::string scopename(demangled_name_c);
4812 free(demangled_name_c);
4818 std::string dataname;
4820 if (!strncmp(scopename.c_str(),
"typeinfo for ",
sizeof(
"typeinfo for ")-1)) {
4821 scopename.erase(0,
sizeof(
"typeinfo for ")-1);
4822 }
else if (!strncmp(scopename.c_str(),
"vtable for ",
sizeof(
"vtable for ")-1)) {
4823 scopename.erase(0,
sizeof(
"vtable for ")-1);
4826 std::string::size_type pos = scopename.rfind(
'(');
4827 if (pos != std::string::npos) {
4831 pos = scopename.rfind(
':');
4832 if (pos != std::string::npos) {
4833 if ((pos != 0) && (scopename[pos-1] ==
':')) {
4834 dataname = scopename.substr(pos+1);
4835 scopename.erase(pos-1);
4839 dataname = scopename;
4847 if (scopename.size()) {
4863 Error(
"GetDataMemberWithValue()",
"not implemented");
4873 Error(
"GetDataMemberAtAddr()",
"not implemented");
4883 const char* params,
Bool_t objectIsConst )
4895 func.
SetFunc(&gcl, method, params, &offset);
4901 return mangled_name;
4916 GetMethod(method,
proto, objectIsConst, 0 , mode).GetMangledName();
4928 const char* params,
Bool_t objectIsConst )
4940 func.
SetFunc(&gcl, method, params, &offset);
4969 std::vector<DeclId_t>& res)
const
4972 clang::ASTContext& Ctx = S.Context;
4973 const clang::Decl* CtxDecl
4975 Ctx.getTranslationUnitDecl();
4976 auto RecDecl = llvm::dyn_cast<const clang::RecordDecl>(CtxDecl);
4977 const clang::DeclContext* DeclCtx = RecDecl;
4980 DeclCtx = dyn_cast<clang::NamespaceDecl>(CtxDecl);
4981 if (!DeclCtx)
return;
4983 clang::DeclarationName DName;
4988 if (RecDecl->getNameAsString() == funcname) {
4989 clang::QualType QT = Ctx.getTypeDeclType(RecDecl);
4990 DName = Ctx.DeclarationNames.getCXXConstructorName(Ctx.getCanonicalType(QT));
4991 }
else if (funcname[0] ==
'~' && RecDecl->getNameAsString() == funcname + 1) {
4992 clang::QualType QT = Ctx.getTypeDeclType(RecDecl);
4993 DName = Ctx.DeclarationNames.getCXXDestructorName(Ctx.getCanonicalType(QT));
4995 DName = &Ctx.Idents.get(funcname);
4998 DName = &Ctx.Idents.get(funcname);
5002 clang::LookupResult
R(S, DName, clang::SourceLocation(),
5003 Sema::LookupOrdinaryName, clang::Sema::NotForRedeclaration);
5004 R.suppressDiagnostics();
5005 S.LookupQualifiedName(
R,
const_cast<DeclContext*
>(DeclCtx));
5006 if (
R.empty())
return;
5008 res.reserve(res.size() + (
R.end() -
R.begin()));
5009 for (clang::LookupResult::iterator IR =
R.begin(), ER =
R.end();
5011 if (
const clang::FunctionDecl* FD
5012 = llvm::dyn_cast<const clang::FunctionDecl>(*IR)) {
5013 if (!FD->getDescribedFunctionTemplate()) {
5016 }
else if (
const auto *USD = llvm::dyn_cast<const clang::UsingShadowDecl>(*IR)) {
5018 if (llvm::isa<clang::FunctionDecl>(USD->getTargetDecl())) {
5162 func.
SetFunc(&cl, function, params, &offset);
5178 const char* params,
Bool_t objectIsConst,
int* error)
5191 void* address = (
void*)((
Longptr_t)addr + offset);
5198 const char* params,
int* error)
5200 Execute(obj,cl,method,params,
false,error);
5215 Error(
"Execute",
"No method was defined");
5224 if (argc > nparms) {
5225 Error(
"Execute",
"Too many parameters to call %s, got %d but expected at most %d.",method->
GetName(),argc,nparms);
5228 if (nparms != argc) {
5238 Int_t firstDefault = -1;
5239 for (
Int_t i = 0; i < nparms; i ++) {
5246 if (firstDefault >= 0) {
5247 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);
5249 Error(
"Execute",
"Too few arguments to call %s, got only %d but expected %d.",method->
GetName(),argc,nparms);
5255 const char* listpar =
"";
5260 for (
Int_t i = 0; i < argc; i ++) {
5269 chpar += (nxtpar->
String()).ReplaceAll(
"\"",
"\\\"");
5276 complete += nxtpar->
String();
5279 listpar = complete.
Data();
5299 void* address = (
void*)((
Longptr_t)addr + offset);
5306 const void* args[] ,
5311 Error(
"ExecuteWithArgsAndReturn",
"No method was defined");
5338 Warning(
"GetTopLevelMacroName",
"Must change return type!");
5385#if defined(R__MUST_REVISIT)
5386#if R__MUST_REVISIT(6,0)
5387 Warning(
"GetCurrentMacroName",
"Must change return type!");
5400 TTHREAD_TLS_DECL(std::string,t);
5402 if (!strstr(typeDesc,
"(*)(")) {
5403 const char *s = strchr(typeDesc,
' ');
5404 const char *template_start = strchr(typeDesc,
'<');
5405 if (!strcmp(typeDesc,
"long long")) {
5408 else if (!strncmp(typeDesc,
"unsigned ", s + 1 - typeDesc)) {
5415 else if (s && (template_start == 0 || (s < template_start))) {
5425 auto l = t.length();
5426 while (
l > 0 && (t[
l - 1] ==
'*' || t[
l - 1] ==
'&'))
5434 assert(rootmapfile && *rootmapfile);
5436 llvm::StringRef libName = llvm::sys::path::filename(rootmapfile);
5437 libName.consume_back(
".rootmap");
5439 return !
gInterpreter->HasPCMForLibrary(libName.str().c_str());
5450 if (!(rootmapfile && *rootmapfile))
5457 const std::map<char, unsigned int> keyLenMap = {{
'c',6},{
'n',10},{
't',8},{
'h',7},{
'e',5},{
'v',4}};
5459 std::string rootmapfileNoBackslash(rootmapfile);
5461 std::replace(rootmapfileNoBackslash.begin(), rootmapfileNoBackslash.end(),
'\\',
'/');
5468 std::string lineDirective = std::string(
"\n#line 2 \"Forward declarations from ") + rootmapfileNoBackslash +
"\"\n";
5470 std::ifstream
file(rootmapfileNoBackslash);
5473 std::string lib_name;
5475 bool newFormat =
false;
5476 while (getline(
file,
line,
'\n')) {
5477 if (!newFormat && (
line.compare(0, 8,
"Library.") == 0 ||
line.compare(0, 8,
"Declare.") == 0)) {
5483 if (
line.compare(0, 9,
"{ decls }") == 0) {
5486 while (getline(
file,
line,
'\n')) {
5489 if (!uniqueString) {
5490 Error(
"ReadRootmapFile",
"Cannot handle \"{ decls }\" sections in custom rootmap file %s",
5491 rootmapfileNoBackslash.c_str());
5494 if (!lineDirective.empty())
5495 uniqueString->
Append(lineDirective);
5499 const char firstChar =
line[0];
5500 if (firstChar ==
'[') {
5502 auto brpos =
line.find(
']');
5503 if (brpos == string::npos)
5505 lib_name =
line.substr(1, brpos - 1);
5507 while (lib_name[nspaces] ==
' ')
5510 lib_name.replace(0, nspaces,
"");
5512 TString lib_nameTstr(lib_name.c_str());
5517 Info(
"ReadRootmapFile",
"new section for %s", lib_nameTstr.
Data());
5519 Info(
"ReadRootmapFile",
"section for %s (library does not exist)", lib_nameTstr.
Data());
5525 auto keyLenIt = keyLenMap.find(firstChar);
5526 if (keyLenIt == keyLenMap.end())
5528 unsigned int keyLen = keyLenIt->second;
5530 const char *keyname =
line.c_str() + keyLen;
5532 Info(
"ReadRootmapFile",
"class %s in %s", keyname, lib_name.c_str());
5535 if (lib_name != isThere->
GetValue()) {
5536 if (firstChar ==
'n') {
5538 Info(
"ReadRootmapFile",
"namespace %s found in %s is already in %s", keyname, lib_name.c_str(),
5540 }
else if (firstChar ==
'h') {
5545 Warning(
"ReadRootmapFile",
"%s %s found in %s is already in %s",
line.substr(0, keyLen).c_str(),
5546 keyname, lib_name.c_str(), isThere->
GetValue());
5550 Info(
"ReadRootmapFile",
"Key %s was already defined for %s", keyname, lib_name.c_str());
5611 using namespace clang;
5613 class ExtVisibleStorageAdder:
public RecursiveASTVisitor<ExtVisibleStorageAdder>{
5619 ExtVisibleStorageAdder(std::unordered_set<const NamespaceDecl*>& nsSet): fNSSet(nsSet) {};
5620 bool VisitNamespaceDecl(NamespaceDecl* nsDecl) {
5625 nsDecl->setHasExternalVisibleStorage();
5626 fNSSet.insert(nsDecl);
5629 bool VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl* specDecl) {
5632 if (specDecl->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
5634 specDecl->setHasExternalLexicalStorage();
5646 std::unordered_set<const NamespaceDecl*>& fNSSet;
5693 for (
Int_t j = 0; j < i; j++) {
5704 Info(
"LoadLibraryMap",
"%s",
d.Data());
5709 if (
f.EndsWith(
".rootmap")) {
5715 Info(
"LoadLibraryMap",
" rootmap file: %s", p.
Data());
5733 if (
f.BeginsWith(
"rootmap")) {
5738 Warning(
"LoadLibraryMap",
"please rename %s to end with \".rootmap\"", p.
Data());
5751 if (rootmapfile && *rootmapfile) {
5758 else if (res == -3) {
5768 while ((rec = (
TEnvRec*) next())) {
5770 if (!strncmp(cls.
Data(),
"Library.", 8) && cls.
Length() > 8) {
5789 Info(
"LoadLibraryMap",
"class %s in %s", cls.
Data(), wlib);
5792 Info(
"LoadLibraryMap",
"class %s in %s (library does not exist)", cls.
Data(), lib);
5798 else if (!strncmp(cls.
Data(),
"Declare.", 8) && cls.
Length() > 8) {
5808 cling::Transaction* T =
nullptr;
5810 assert(cling::Interpreter::kSuccess == compRes &&
"A declaration in a rootmap could not be compiled");
5812 if (compRes!=cling::Interpreter::kSuccess){
5814 "Problems in %s declaring '%s' were encountered.", rootmapfile, uniqueString.
Data()) ;
5819 for (
auto declIt = T->decls_begin(); declIt < T->decls_end(); ++declIt) {
5820 if (declIt->m_DGR.isSingleDecl()) {
5821 if (Decl* D = declIt->m_DGR.getSingleDecl()) {
5822 if (clang::isa<TagDecl>(D) || clang::isa<NamespaceDecl>(D)) {
5823 evsAdder.TraverseDecl(D);
5858 for (
Int_t ilib = 0; ilib < nrSharedLibs; ilib++) {
5865 TString rootMapBaseStr = sharedLibBaseStr;
5866 if (sharedLibBaseStr.
EndsWith(
".dll")) {
5869 else if (sharedLibBaseStr.
EndsWith(
".DLL")) {
5872 else if (sharedLibBaseStr.
EndsWith(
".so")) {
5875 else if (sharedLibBaseStr.
EndsWith(
".sl")) {
5878 else if (sharedLibBaseStr.
EndsWith(
".dl")) {
5881 else if (sharedLibBaseStr.
EndsWith(
".a")) {
5885 Error(
"ReloadAllSharedLibraryMaps",
"Unknown library type %s", sharedLibBaseStr.
Data());
5889 rootMapBaseStr +=
".rootmap";
5892 Error(
"ReloadAllSharedLibraryMaps",
"Could not find rootmap %s in path", rootMapBaseStr.
Data());
5899 Error(
"ReloadAllSharedLibraryMaps",
"Error loading map %s", rootMap);
5934 if (!
fMapfile || !library || !*library) {
5942 size_t len = libname.
Length();
5947 while ((rec = (
TEnvRec *) next())) {
5958 if (!strncmp(cls.
Data(),
"Library.", 8) && cls.
Length() > 8) {
5967 if (!strncmp(lib, libname.
Data(), len)) {
5969 Error(
"UnloadLibraryMap",
"entry for <%s, %s> not found in library map table", cls.
Data(), lib);
5977 TString library_rootmap(library);
5978 if (!library_rootmap.
EndsWith(
".rootmap"))
5979 library_rootmap.
Append(
".rootmap");
6032 free(demangled_name);
6050 std::string demangled_name(demangled_name_c);
6051 free(demangled_name_c);
6064 result =
AutoLoad(demangled_name.c_str(), knowDictNotLoaded);
6083 if (
gROOT->LoadClass(cls, deplib) == 0) {
6086 "loaded dependent library %s for %s", deplib, cls);
6091 "failure loading dependent library %s for %s",
6096 if (lib && lib[0]) {
6097 if (
gROOT->LoadClass(cls, lib) == 0) {
6100 "loaded library %s for %s", lib, cls);
6106 "failure loading library %s for %s", lib, cls);
6121 bool nameIsNormalized)
6127 if (!visited.insert(std::string(cls)).second)
6137 for (
auto element :
proto->GetData()) {
6138 if (element->IsBasic())
6140 const char *subtypename = element->GetTypeName();
6156 if (classinfo &&
gInterpreter->ClassInfo_IsValid(classinfo)
6160 while (
gInterpreter->DataMemberInfo_Next(memberinfo)) {
6193 Info(
"TCling::AutoLoad",
"Explicitly disabled (the class name is %s)", cls);
6213 Info(
"TCling::AutoLoad",
6214 "Trying to autoload for %s", cls);
6219 Info(
"TCling::AutoLoad",
6220 "Disabled due to gROOT or gInterpreter being invalid/not ready (the class name is %s)", cls);
6241 std::unordered_set<std::string> visited;
6250 cling::Interpreter *interpreter)
6252 std::string code = gNonInterpreterClassDef ;
6259 code += (
"#include \"");
6263 code += (
"#ifdef __ROOTCLING__\n"
6264 "#undef __ROOTCLING__\n"
6265 + gInterpreterClassDef +
6268 cling::Interpreter::CompilationResult cr;
6274 Sema &SemaR = interpreter->getSema();
6276 clangDiagSuppr diagSuppr(SemaR.getDiagnostics());
6278 #if defined(R__MUST_REVISIT)
6279 #if R__MUST_REVISIT(6,2)
6280 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
6284 cr = interpreter->parseForModule(code);
6302 Int_t nHheadersParsed = 0;
6303 unsigned long offset = 0;
6304 if (strncmp(cls,
"const ", 6) == 0) {
6309 bool skipFirstEntry =
false;
6310 std::vector<std::string> autoparseKeys;
6311 if (strchr(cls,
'<')) {
6317 if (!autoparseKeys.empty() && !autoparseKeys[0].empty()) {
6322 TString templateName(autoparseKeys[0]);
6323 auto tokens = templateName.
Tokenize(
"::");
6324 clang::NamedDecl* previousScopeAsNamedDecl =
nullptr;
6325 clang::DeclContext* previousScopeAsContext =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
6327 previousScopeAsContext =
fInterpreter->getSema().getStdNamespace();
6329 for (
Int_t tk = 0; tk < nTokens; ++tk) {
6330 auto scopeObj = tokens->UncheckedAt(tk);
6331 auto scopeName = ((
TObjString*) scopeObj)->String().Data();
6332 previousScopeAsNamedDecl = cling::utils::Lookup::Named(&
fInterpreter->getSema(), scopeName, previousScopeAsContext);
6334 if ((clang::NamedDecl*)-1 == previousScopeAsNamedDecl)
break;
6335 previousScopeAsContext = llvm::dyn_cast_or_null<clang::DeclContext>(previousScopeAsNamedDecl);
6336 if (!previousScopeAsContext)
break;
6340 if ((clang::NamedDecl*)-1 != previousScopeAsNamedDecl) {
6341 if (
auto templateDecl = llvm::dyn_cast_or_null<clang::ClassTemplateDecl>(previousScopeAsNamedDecl)) {
6342 if (
auto templatedDecl = templateDecl->getTemplatedDecl()) {
6343 skipFirstEntry = templatedDecl->hasDefinition();
6350 if (topLevel) autoparseKeys.emplace_back(cls);
6352 for (
const auto & apKeyStr : autoparseKeys) {
6353 if (skipFirstEntry) {
6354 skipFirstEntry=
false;
6357 if (apKeyStr.empty())
continue;
6358 const char *apKey = apKeyStr.c_str();
6362 Info(
"TCling::AutoParse",
6363 "Starting autoparse for %s\n", apKey);
6368 const cling::Transaction *T =
fInterpreter->getCurrentTransaction();
6370 auto const &hNamesPtrs = iter->second;
6372 Info(
"TCling::AutoParse",
6373 "We can proceed for %s. We have %s headers.", apKey, std::to_string(hNamesPtrs.size()).c_str());
6375 for (
auto & hName : hNamesPtrs) {
6377 if (0 !=
fPayloads.count(normNameHash)) {
6378 float initRSSval=0.f, initVSIZEval=0.f;
6380 (
void) initVSIZEval;
6383 "Parsing full payload for %s", apKey);
6390 if (cRes != cling::Interpreter::kSuccess) {
6391 if (hName[0] ==
'\n')
6392 Error(
"AutoParse",
"Error parsing payload code for class %s with content:\n%s", apKey, hName);
6401 Info(
"Autoparse",
">>> RSS key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initRSSval, endRSSval, endRSSval-initRSSval);
6402 Info(
"Autoparse",
">>> VSIZE key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initVSIZEval, endVSIZEval, endVSIZEval-initVSIZEval);
6408 "Parsing single header %s", hName);
6411 if (cRes != cling::Interpreter::kSuccess) {
6412 Error(
"AutoParse",
"Error parsing headerfile %s for class %s.", hName, apKey);
6424 if (strchr(apKey,
'<')) {
6431 return nHheadersParsed;
6441 if (llvm::StringRef(cls).contains(
"(lambda)"))
6455 Info(
"TCling::AutoParse",
6456 "Trying to autoparse for %s", cls);
6478 return nHheadersParsed > 0 ? 1 : 0;
6486 StringRef errMsg(errmessage);
6487 if (errMsg.contains(
"undefined symbol: ")) {
6489 std::string mangled_name = std::string(errMsg.split(
"undefined symbol: ").second);
6490 void* res = ((
TCling*)
gCling)->LazyFunctionCreatorAutoload(mangled_name);
6491 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
6492 if (res && DLM && (DLM->loadLibrary(libStem, permanent, resolved) == cling::DynamicLibraryManager::kLoadLibSuccess))
6505 const cling::DynamicLibraryManager &DLM) {
6508 auto LibLoader = [](
const std::string& LibName) ->
bool {
6509 if (
gSystem->
Load(LibName.c_str(),
"",
false) < 0) {
6510 Error(
"TCling__LazyFunctionCreatorAutoloadForModule",
6511 "Failed to load library %s", LibName.c_str());
6521 assert(!llvm::StringRef(mangled_name).startswith(
"__") &&
"Already added!");
6522 std::string libName = DLM.searchLibrariesForSymbol(
'_' + mangled_name,
6525 std::string libName = DLM.searchLibrariesForSymbol(mangled_name,
6529 assert(!llvm::StringRef(libName).startswith(
"libNew") &&
6530 "We must not resolve symbols from libNew!");
6532 if (libName.empty())
6535 if (!LibLoader(libName))
6538 return llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(mangled_name);
6555 mangled_name.c_str())) {
6566 std::string
name(demangled_name_c);
6567 free(demangled_name_c);
6575 std::string::size_type pos =
name.find(
"__thiscall ");
6576 if (pos != std::string::npos) {
6577 name.erase(0, pos +
sizeof(
"__thiscall ")-1);
6579 pos =
name.find(
"__cdecl ");
6580 if (pos != std::string::npos) {
6581 name.erase(0, pos +
sizeof(
"__cdecl ")-1);
6583 if (!strncmp(
name.c_str(),
"typeinfo for ",
sizeof(
"typeinfo for ")-1)) {
6584 name.erase(0,
sizeof(
"typeinfo for ")-1);
6585 }
else if (!strncmp(
name.c_str(),
"vtable for ",
sizeof(
"vtable for ")-1)) {
6586 name.erase(0,
sizeof(
"vtable for ")-1);
6587 }
else if (!strncmp(
name.c_str(),
"operator",
sizeof(
"operator")-1)
6588 && !isalnum(
name[
sizeof(
"operator")])) {
6590 name.erase(0,
sizeof(
"operator")-1);
6591 pos =
name.rfind(
'(');
6592 if (pos != std::string::npos) {
6593 name.erase(0, pos + 1);
6594 pos =
name.find(
",");
6595 if (pos != std::string::npos) {
6599 pos =
name.rfind(
" const");
6600 if (pos != std::string::npos) {
6601 name.erase(pos, strlen(
" const"));
6603 while (!
name.empty() && strchr(
"&*",
name.back()))
6623 while (libs.
Tokenize(lib, posLib)) {
6633 void* addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(mangled_name.c_str());
6655 const NamedDecl *oldDef = llvm::dyn_cast_or_null<NamedDecl>(cci->
GetDecl());
6656 if (!oldDef || (def && def != oldDef)) {
6670 if (!alias && def !=
nullptr)
6693 const TagDecl *td = dyn_cast<TagDecl>(ND);
6694 const NamespaceDecl *ns = dyn_cast<NamespaceDecl>(ND);
6695 const NamedDecl *canon =
nullptr;
6700 canon = tdDef = td->getDefinition();
6704 if (!tdDef->isCompleteDefinition() || llvm::isa<clang::FunctionDecl>(tdDef->getDeclContext())) {
6710 auto declName = tdDef->getNameAsString();
6721 clang::QualType
type(tdDef->getTypeForDecl(), 0);
6724 canon = ns->getCanonicalDecl();
6725 name = ND->getQualifiedNameAsString();
6727 name = ND->getQualifiedNameAsString();
6776 std::set<TClass*> modifiedTClasses;
6781 bool isTUTransaction =
false;
6782 if (!T.empty() && T.decls_begin() + 1 == T.decls_end() && !T.hasNestedTransactions()) {
6783 clang::Decl* FirstDecl = *(T.decls_begin()->m_DGR.begin());
6784 if (llvm::isa<clang::TranslationUnitDecl>(FirstDecl)) {
6787 isTUTransaction =
true;
6791 std::set<const void*> TransactionDeclSet;
6792 if (!isTUTransaction && T.decls_end() - T.decls_begin()) {
6793 const clang::Decl* WrapperFD = T.getWrapperFD();
6794 for (cling::Transaction::const_iterator
I = T.decls_begin(), E = T.decls_end();
6796 if (
I->m_Call != cling::Transaction::kCCIHandleTopLevelDecl
6797 &&
I->m_Call != cling::Transaction::kCCIHandleTagDeclDefinition)
6800 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
6801 DE =
I->m_DGR.end(); DI != DE; ++DI) {
6802 if (*DI == WrapperFD)
6804 TransactionDeclSet.insert(*DI);
6805 ((
TCling*)
gCling)->HandleNewDecl(*DI,
false, modifiedTClasses);
6812 for (cling::Transaction::const_iterator
I = T.deserialized_decls_begin(),
6813 E = T.deserialized_decls_end();
I != E; ++
I) {
6814 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
6815 DE =
I->m_DGR.end(); DI != DE; ++DI)
6816 if (TransactionDeclSet.find(*DI) == TransactionDeclSet.end()) {
6832 std::vector<TClass*> modifiedTClassesDiff(modifiedTClasses.size());
6833 std::vector<TClass*>::iterator it;
6834 it = set_difference(modifiedTClasses.begin(), modifiedTClasses.end(),
6837 modifiedTClassesDiff.begin());
6838 modifiedTClassesDiff.resize(it - modifiedTClassesDiff.begin());
6841 ((
TCling*)
gCling)->GetModTClasses().insert(modifiedTClassesDiff.begin(),
6842 modifiedTClassesDiff.end());
6843 for (std::vector<TClass*>::const_iterator
I = modifiedTClassesDiff.begin(),
6844 E = modifiedTClassesDiff.end();
I != E; ++
I) {
6846 if (!
gROOT->GetListOfClasses()->FindObject(*
I)) {
6868 cling::Transaction::const_nested_iterator iNested = T.nested_begin();
6869 for (cling::Transaction::const_iterator
I = T.decls_begin(), E = T.decls_end();
6871 if (
I->m_Call == cling::Transaction::kCCIHandleVTable)
6873 if (
I->m_Call == cling::Transaction::kCCINone) {
6879 for (
auto &D :
I->m_DGR)
6905 if (D->isFromASTFile())
6913 if (isa<VarDecl>(D) || isa<FieldDecl>(D) || isa<EnumConstantDecl>(D)) {
6919 }
else if (isa<FunctionDecl>(D)) {
6921 }
else if (isa<FunctionTemplateDecl>(D)) {
6923 }
else if (isa<EnumDecl>(D)) {
6934 }
else if (isa<RecordDecl>(D) || isa<NamespaceDecl>(D)) {
6935 if (isa<RecordDecl>(D) && !cast<RecordDecl>(D)->isCompleteDefinition())
6938 std::vector<TClass *> Classes;
6941 for (
auto &C : Classes) {
6946 for (
auto &
I : cast<DeclContext>(D)->decls())
6950 if (D->getKind() != Decl::Namespace
6951 || cast<NamespaceDecl>(D)->isOriginalNamespace())
6952 C->ResetClassInfo();
6964 std::size_t normNameHash = triter->second;
6970 auto const &hNamesPtrs = iter->second;
6971 for (
auto &hName : hNamesPtrs) {
6973 Info(
"TransactionRollback",
6974 "Restoring ability to autoaparse: %s", hName);
7011 using namespace clang;
7012 if (
const Decl *D = LH.findScope(cls, cling::LookupHelper::NoDiagnostics,
7014 if (!D->isFromASTFile()) {
7016 Warning(
"GetClassSharedLibsForModule",
"Decl found for %s is not part of a module", cls);
7019 class ModuleCollector :
public ConstDeclVisitor<ModuleCollector> {
7020 llvm::DenseSet<Module *> &m_TopLevelModules;
7023 ModuleCollector(llvm::DenseSet<Module *> &TopLevelModules) : m_TopLevelModules(TopLevelModules) {}
7024 void Collect(
const Decl *D) { Visit(D); }
7026 void VisitDecl(
const Decl *D)
7036 if (!D->hasOwningModule())
7038 if (Module *M = D->getOwningModule()->getTopLevelModule())
7039 m_TopLevelModules.insert(M);
7042 void VisitTemplateArgument(
const TemplateArgument &
TA)
7044 switch (
TA.getKind()) {
7045 case TemplateArgument::Null:
7046 case TemplateArgument::Integral:
7047 case TemplateArgument::Pack:
7048 case TemplateArgument::NullPtr:
7049 case TemplateArgument::Expression:
7050 case TemplateArgument::Template:
7051 case TemplateArgument::TemplateExpansion:
return;
7052 case TemplateArgument::Type:
7053 if (
const TagType *TagTy = dyn_cast<TagType>(
TA.getAsType()))
7054 return Visit(TagTy->getDecl());
7056 case TemplateArgument::Declaration:
return Visit(
TA.getAsDecl());
7058 llvm_unreachable(
"Invalid TemplateArgument::Kind!");
7061 void VisitClassTemplateSpecializationDecl(
const ClassTemplateSpecializationDecl *CTSD)
7063 if (CTSD->getOwningModule())
7066 VisitDecl(CTSD->getSpecializedTemplate());
7067 const TemplateArgumentList &ArgList = CTSD->getTemplateArgs();
7068 for (
const TemplateArgument *Arg = ArgList.data(), *ArgEnd = Arg + ArgList.size(); Arg != ArgEnd; ++Arg) {
7069 VisitTemplateArgument(*Arg);
7074 llvm::DenseSet<Module *> TopLevelModules;
7075 ModuleCollector
m(TopLevelModules);
7078 for (
auto M : TopLevelModules) {
7081 if (!M->LinkLibraries.size())
7084 if (M->Name ==
"Core")
7086 assert(M->LinkLibraries.size() == 1);
7087 if (!result.empty())
7089 result += M->LinkLibraries[0].Library;
7105 llvm::StringRef className = cls;
7111 if (className.contains(
"(lambda)"))
7115 cling::LookupHelper &LH =
fInterpreter->getLookupHelper();
7117 if (!libs.empty()) {
7123 if (!cls || !*cls) {
7131 const char* libs = libs_record->
GetValue();
7132 return (*libs) ? libs : 0;
7149 const char* libs = libs_record->
GetValue();
7150 return (*libs) ? libs : 0;
7164 cling::Interpreter *interp,
7165 bool skipLoadedLibs =
true)
7168 if (!llvm::sys::path::is_absolute(lib)) {
7170 Error(
"TCling__GetSharedLibImmediateDepsSlow",
"Cannot find library '%s'", lib.c_str());
7174 assert(llvm::sys::fs::exists(lib) &&
"Must exist!");
7175 lib = llvm::sys::path::filename(lib);
7178 auto ObjF = llvm::object::ObjectFile::createObjectFile(LibFullPath.
Data());
7180 Warning(
"TCling__GetSharedLibImmediateDepsSlow",
"Failed to read object file %s", lib.c_str());
7184 llvm::object::ObjectFile *BinObjFile = ObjF.get().getBinary();
7186 std::set<string> DedupSet;
7187 std::string Result = lib +
' ';
7188 for (
const auto &S : BinObjFile->symbols()) {
7189 uint32_t Flags = S.getFlags();
7190 if (Flags & llvm::object::SymbolRef::SF_Undefined) {
7191 llvm::Expected<StringRef> SymNameErr = S.getName();
7193 Warning(
"GetSharedLibDepsForModule",
"Failed to read symbol");
7196 llvm::StringRef SymName = SymNameErr.get();
7197 if (SymName.empty())
7200 if (BinObjFile->isELF()) {
7204 if (SymName.contains(
"@@GLIBCXX") || SymName.contains(
"@@CXXABI") ||
7205 SymName.contains(
"@@GLIBC") || SymName.contains(
"@@GCC"))
7213 if (SymName ==
"_Jv_RegisterClasses" ||
7214 SymName ==
"_ITM_deregisterTMCloneTable" ||
7215 SymName ==
"_ITM_registerTMCloneTable")
7223 if (skipLoadedLibs && SymName[0] ==
'_'
7224 && llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(SymName.drop_front()))
7229 if (skipLoadedLibs && llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(SymName))
7233 std::string found = interp->getDynamicLibraryManager()->searchLibrariesForSymbol(SymName,
false);
7239 if (!found.empty()) {
7240 std::string cand = llvm::sys::path::filename(found).str();
7241 if (!DedupSet.insert(cand).second)
7244 Result += cand +
' ';
7255 llvm::SmallString<256> rootmapName;
7256 if (!lib.startswith(
"lib"))
7257 rootmapName.append(
"lib");
7259 rootmapName.append(llvm::sys::path::filename(lib));
7260 llvm::sys::path::replace_extension(rootmapName,
"rootmap");
7266 llvm::StringRef rootmapNameNoLib = rootmapName.str();
7267 if (rootmapNameNoLib.consume_front(
"lib"))
7291 if (llvm::sys::path::is_absolute(lib) && !llvm::sys::fs::exists(lib))
7295 llvm::SmallString<512> rootmapName(lib);
7296 llvm::sys::path::replace_extension(rootmapName,
"rootmap");
7297 if (llvm::sys::fs::exists(rootmapName)) {
7299 Info(
"Load",
"loading %s", rootmapName.c_str());
7306 Warning(
"TCling::GetSharedLibDeps",
"Precomputed dependencies available but scanning '%s'", lib);
7311 if (!libs.empty()) {
7317 if (!
fMapfile || !lib || !lib[0]) {
7327 size_t len = libname.
Length();
7328 while ((rec = (
TEnvRec*) next())) {
7329 const char* libs = rec->
GetValue();
7330 if (!strncmp(libs, libname.
Data(), len) && strlen(libs) >= len
7331 && (!libs[len] || libs[len] ==
' ' || libs[len] ==
'.')) {
7344#if defined(R__MUST_REVISIT)
7345#if R__MUST_REVISIT(6,2)
7346 Warning(
"IsErrorMessagesEnabled",
"Interface not available yet.");
7358#if defined(R__MUST_REVISIT)
7359#if R__MUST_REVISIT(6,2)
7360 Warning(
"SetErrorMessages",
"Interface not available yet.");
7376 llvm::SmallVector<std::string, 10> includePaths;
7378 fInterpreter->GetIncludePaths(includePaths,
false,
true);
7379 if (
const size_t nPaths = includePaths.size()) {
7380 assert(!(nPaths & 1) &&
"GetIncludePath, number of paths and options is not equal");
7382 for (
size_t i = 0; i < nPaths; i += 2) {
7387 if (includePaths[i] !=
"-I")
7421 assert(fout != 0 &&
"DisplayIncludePath, 'fout' parameter is null");
7423 llvm::SmallVector<std::string, 10> includePaths;
7425 fInterpreter->GetIncludePaths(includePaths,
false,
true);
7426 if (
const size_t nPaths = includePaths.size()) {
7427 assert(!(nPaths & 1) &&
"DisplayIncludePath, number of paths and options is not equal");
7429 std::string allIncludes(
"include path:");
7430 for (
size_t i = 0; i < nPaths; i += 2) {
7432 allIncludes += includePaths[i];
7434 if (includePaths[i] !=
"-I")
7436 allIncludes += includePaths[i + 1];
7439 fprintf(fout,
"%s\n", allIncludes.c_str());
7458#if defined(R__MUST_REVISIT)
7459#if R__MUST_REVISIT(6,2)
7460 Warning(
"GenericError",
"Interface not available yet.");
7488#if defined(R__MUST_REVISIT)
7489#if R__MUST_REVISIT(6,2)
7490 Warning(
"GetSecurityError",
"Interface not available yet.");
7501 cling::Interpreter::CompilationResult compRes;
7503 return compRes == cling::Interpreter::kFailure;
7522 TTHREAD_TLS_DECL(std::string,buffer);
7524 return buffer.c_str();
7605#if defined(R__MUST_REVISIT)
7606#if R__MUST_REVISIT(6,2)
7607 Warning(
"SetErrmsgcallback",
"Interface not available yet.");
7616 &
fInterpreter->getDiagnostics().getDiagnosticOptions(),
7618 [] (clang::DiagnosticsEngine::Level Level,
const std::string &
Info) {
7619 if (Level == clang::DiagnosticsEngine::Warning) {
7620 ::Warning(
"cling",
"%s", Info.c_str());
7621 }
else if (Level == clang::DiagnosticsEngine::Error
7622 || Level == clang::DiagnosticsEngine::Fatal) {
7628 fInterpreter->replaceDiagnosticConsumer(consumer,
true);
7630 fInterpreter->replaceDiagnosticConsumer(
nullptr);
7647 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
7648 std::string canonical = DLM->lookupLibrary(path);
7649 if (canonical.empty()) {
7653 cling::Interpreter::CompilationResult compRes;
7655 return compRes == cling::Interpreter::kFailure;
7659 return std::unique_ptr<TInterpreterValue>(
new TClingValue);
7666 std::vector<std::string>& completions)
7675 auto V =
reinterpret_cast<cling::Value*
>(value.
GetValAddr());
7677 return compRes!=cling::Interpreter::kSuccess ? 0 : 1 ;
7684 using namespace cling;
7698 if (value.isValid() && value.needsManagedAllocation()) {
7719 auto iSpecObj = iSpecObjMap->second.find(Name);
7720 if (iSpecObj != iSpecObjMap->second.end()) {
7722 return iSpecObj->second;
7729 ASTContext& C = SemaR.getASTContext();
7730 Preprocessor &PP = SemaR.getPreprocessor();
7731 Parser& P =
const_cast<Parser&
>(
fInterpreter->getParser());
7732 Preprocessor::CleanupAndRestoreCacheRAII cleanupRAII(PP);
7733 Parser::ParserCurTokRestoreRAII savedCurToken(P);
7736 Token& Tok =
const_cast<Token&
>(P.getCurToken());
7737 Tok.setKind(tok::semi);
7743 Sema::ContextAndScopeRAII pushedDCAndS(SemaR, C.getTranslationUnitDecl(),
7746 TObject* specObj =
gROOT->FindSpecialObject(Name, LookupCtx);
7749 Error(
"GetObjectAddress",
"Got a special object without LookupCtx!");
7763 clang::CXXRecordDecl* klass)
const
7765 using namespace clang;
7766 ASTContext& Ctx = klass->getASTContext();
7767 FriendDecl::FriendUnion friendUnion(function);
7770 FriendDecl* friendDecl = FriendDecl::Create(Ctx, klass, sl, friendUnion, sl);
7771 klass->pushFriendDecl(friendDecl);
7785 if (func)
return ((
TClingCallFunc*)func)->GetDecl()->getCanonicalDecl();
7856 f->
Exec(address, &val);
7870 const void* args[] ,
8037 f->SetFunc(ci, method, params, offset);
8046 f->SetFunc(ci, method, params, objectIsConst, offset);
8064 f->SetFuncProto(ci, method,
proto, offset, mode);
8074 f->SetFuncProto(ci, method,
proto, objectIsConst, offset, mode);
8084 llvm::SmallVector<clang::QualType, 4> funcProto;
8085 for (std::vector<TypeInfo_t*>::const_iterator iter =
proto.begin(), end =
proto.end();
8086 iter != end; ++iter) {
8087 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
8089 f->SetFuncProto(ci, method, funcProto, offset, mode);
8099 llvm::SmallVector<clang::QualType, 4> funcProto;
8100 for (std::vector<TypeInfo_t*>::const_iterator iter =
proto.begin(), end =
proto.end();
8101 iter != end; ++iter) {
8102 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
8104 f->SetFuncProto(ci, method, funcProto, objectIsConst, offset, mode);
8110 std::string wrapper_name;
8111 std::string wrapper;
8131 const clang::DeclContext *ctxt =
nullptr;
8133 ctxt = clang::Decl::castToDeclContext(((
TClingClassInfo*)info)->GetDecl());
8135 ctxt =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
8140 const clang::Decl *decl =
reinterpret_cast<const clang::Decl*
>(declid);
8144 const clang::DeclContext *declDC = decl->getDeclContext();
8147 if (declDC->isTransparentContext()) {
8148 declDC = declDC->getParent();
8151 if (
const auto *declRD = llvm::dyn_cast<clang::RecordDecl>(declDC)) {
8152 if (declRD->isAnonymousStructOrUnion()) {
8153 declDC = declRD->getParent();
8157 if (
const auto *declNS = llvm::dyn_cast<clang::NamespaceDecl>(declDC)) {
8158 if (declNS->isAnonymousNamespace() || declNS->isInlineNamespace()) {
8159 declDC = declNS->getParent();
8166 return declDC->Equals(ctxt);
8277 TClinginfo->
Init(tagnum);
8350 return TClinginfo->
Next();
8398 return TClinginfo->
Size();
8406 return TClinginfo->
Tagnum();
8422 TTHREAD_TLS_DECL(std::string,
output);
8432 return TClinginfo->
Name();
8440 return TClinginfo->
Title();
8477 ClassInfo_t* base)
const
8490 return TClinginfo->
Next();
8498 return TClinginfo->
Next(onlyDirect);
8506 return TClinginfo->
Offset(address, isDerivedObject);
8519 return TClinginfo->
GetBaseOffset(TClinginfoBase, address, isDerivedObject);
8535 return (ClassInfo_t *)TClinginfo->
GetBase();
8543 return TClinginfo->
Tagnum();
8551 TTHREAD_TLS_DECL(std::string,
output);
8561 return TClinginfo->
Name();
8606 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
8607 const clang::ValueDecl* vd = llvm::dyn_cast_or_null<clang::ValueDecl>(decl);
8640 return TClinginfo->
Next();
8648 return TClinginfo->
Offset();
8696 return TClinginfo->
Name();
8704 return TClinginfo->
Title();
8711 TTHREAD_TLS_DECL(std::string,result);
8715 return result.c_str();
8722 Decl* decl =
static_cast<Decl*
>(
const_cast<void*
>(declId));
8723 ASTContext &C = decl->getASTContext();
8724 SourceRange commentRange;
8725 decl->addAttr(
new (C) AnnotateAttr( commentRange, C, attribute, 0 ) );
8736 cling::Interpreter &interp,
8739 const clang::TypeDecl* td = llvm::dyn_cast<clang::TypeDecl>(decl->getDeclContext());
8742 clang::QualType qualType(td->getTypeForDecl(),0);
8744 unsigned int level = 0;
8745 for(
size_t cursor =
name.length()-1; cursor != 0; --cursor) {
8746 if (
name[cursor] ==
'>') ++level;
8747 else if (
name[cursor] ==
'<' && level) --level;
8748 else if (level == 0 &&
name[cursor] ==
':') {
8749 name.erase(0,cursor+1);
8761 const auto *FD = llvm::dyn_cast<clang::FunctionDecl>(decl);
8762 if (
const auto *USD = llvm::dyn_cast<clang::UsingShadowDecl>(decl)) {
8763 FD = llvm::dyn_cast<clang::FunctionDecl>(USD->getTargetDecl());
8766 Error(
"GetFunctionName",
"NULL Decl!");
8773 if (llvm::isa<clang::CXXConstructorDecl>(FD))
8777 }
else if (llvm::isa<clang::CXXDestructorDecl>(decl))
8782 llvm::raw_string_ostream stream(
output);
8783 auto printPolicy = decl->getASTContext().getPrintingPolicy();
8785 printPolicy.AnonymousTagLocations =
false;
8786 FD->getNameForDiagnostic(stream, printPolicy,
false);
8816 return (FuncTempInfo_t*)
const_cast<void*
>(declid);
8827 return (FuncTempInfo_t*)ft_info;
8847 if (!ft_info)
return 0;
8848 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
8849 return ft->getTemplateParameters()->size();
8858 if (!ft_info)
return 0;
8859 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
8860 return ft->getTemplateParameters()->getMinRequiredArguments();
8868 if (!ft_info)
return 0;
8873 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
8875 switch (ft->getAccess()) {
8876 case clang::AS_public:
8879 case clang::AS_protected:
8882 case clang::AS_private:
8885 case clang::AS_none:
8886 if (ft->getDeclContext()->isNamespace())
8894 const clang::FunctionDecl *fd = ft->getTemplatedDecl();
8895 if (
const clang::CXXMethodDecl *md =
8896 llvm::dyn_cast<clang::CXXMethodDecl>(fd)) {
8897 if (md->getMethodQualifiers().hasConst()) {
8900 if (md->isVirtual()) {
8906 if (
const clang::CXXConstructorDecl *cd =
8907 llvm::dyn_cast<clang::CXXConstructorDecl>(md)) {
8908 if (cd->isExplicit()) {
8912 else if (
const clang::CXXConversionDecl *cd =
8913 llvm::dyn_cast<clang::CXXConversionDecl>(md)) {
8914 if (cd->isExplicit()) {
8928 if (!ft_info)
return 0;
8933 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
8934 const clang::FunctionDecl *fd = ft->getTemplatedDecl();
8936 if (fd->isOverloadedOperator())
8938 if (llvm::isa<clang::CXXConversionDecl>(fd))
8940 if (llvm::isa<clang::CXXConstructorDecl>(fd))
8942 if (llvm::isa<clang::CXXDestructorDecl>(fd))
8944 if (fd->isInlined())
8955 if (!ft_info)
return;
8956 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
8968 if (!ft_info)
return;
8969 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
8973 if (
const RedeclarableTemplateDecl *AnnotFD
8975 if (AnnotateAttr *A = AnnotFD->getAttr<AnnotateAttr>()) {
8976 output = A->getAnnotation().str();
8980 if (!ft->isFromASTFile()) {
9030 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
9063 return info->
NArg();
9079 return info->
Next();
9103 return (TypeInfo_t*)info->
Type();
9111 TTHREAD_TLS_DECL(
TString, mangled_name);
9113 return mangled_name;
9129 return info->
Name();
9156 return info->
Title();
9164 return MethodInfo_MethodCallReturnType(func->fInfo);
9166 return EReturnType::kOther;
9175 if (info && info->
IsValid()) {
9177 clang::QualType QT( typeinfo->
GetQualType().getCanonicalType() );
9178 if (QT->isEnumeralType()) {
9179 return EReturnType::kLong;
9180 }
else if (QT->isPointerType()) {
9182 QT = llvm::cast<clang::PointerType>(QT)->getPointeeType();
9183 if ( QT->isCharType() ) {
9184 return EReturnType::kString;
9186 return EReturnType::kOther;
9188 }
else if ( QT->isFloatingType() ) {
9189 int sz = typeinfo->
Size();
9190 if (sz == 4 || sz == 8) {
9192 return EReturnType::kDouble;
9194 return EReturnType::kOther;
9196 }
else if ( QT->isIntegerType() ) {
9197 int sz = typeinfo->
Size();
9206 return EReturnType::kLong;
9208 return EReturnType::kOther;
9211 return EReturnType::kOther;
9214 return EReturnType::kOther;
9250 return (MethodArgInfo_t*)
9267 return info->
Next();
9291 return info->
Name();
9367 return TClinginfo->
Name();
9391 return TClinginfo->
Size();
9441 const char*
name)
const
9461 return TClinginfo->
Next();
9477 return TClinginfo->
Size();
9493 return TClinginfo->
Name();
9501 return TClinginfo->
Title();
9510 Error(
"SnapshotMutexState",
"fRecurseCount != 0 even though initial mutex state is unset!");
9526 Error(
"ForgetMutexState",
"mutex state's recurse count already 0!");
9542 std::unique_ptr<MutexStateAndRecurseCountDelta> uniqueP{typedDelta};
9556 Error(
"ApplyToInterpreterMutex",
9557 "After returning from user code that turned on thread safety support, we notice that fInitialMutex is already used ... "
9558 "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.");
9574 return uniqueP.release();
The file contains utilities which are foundational and could be used across the core component of ROO...
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned long long ULong64_t
TClass *(* DictFuncPtr_t)()
R__EXTERN TApplication * gApplication
R__EXTERN TClassTable * gClassTable
static bool IsFromRootCling()
static void indent(ostringstream &buf, int indent_level)
The file contains facilities to work with C++ module files extensions used to store rdict files.
void TCling__RestoreInterpreterMutex(void *delta)
Re-apply the lock count delta that TCling__ResetInterpreterMutex() caused.
void * llvmLazyFunctionCreator(const std::string &mangled_name)
Autoload a library provided the mangled name of a missing symbol.
void TCling__TransactionRollback(const cling::Transaction &T)
static void RegisterPreIncludedHeaders(cling::Interpreter &clingInterp)
static bool hasParsedRootmapForLibrary(llvm::StringRef lib)
static std::string GetClassSharedLibsForModule(const char *cls, cling::LookupHelper &LH)
void TCling__InvalidateGlobal(const clang::Decl *D)
bool TClingLookupHelper__AutoParse(const char *cname)
Allow calling autoparsing from TMetaUtils.
void * TCling__LockCompilationDuringUserCodeExecution()
Lock the interpreter.
void TCling__UpdateListsOnUnloaded(const cling::Transaction &T)
void TCling__GetNormalizedContext(const ROOT::TMetaUtils::TNormalizedCtxt *&normCtxt)
R__DLLEXPORT clang::DeclContext * TCling__DEBUG__getDeclContext(clang::Decl *D)
ETupleOrdering
Check in what order the member of a tuple are layout.
bool TCling__LibraryLoadingFailed(const std::string &errmessage, const std::string &libStem, bool permanent, bool resolved)
Lookup libraries in LD_LIBRARY_PATH and DYLD_LIBRARY_PATH with mangled_name, which is extracted by er...
static const std::unordered_set< std::string > gIgnoredPCMNames
List of dicts that have the PCM information already in the PCH.
static Bool_t s_IsLibraryLoaded(const char *libname, cling::Interpreter *fInterpreter)
static std::string AlternateTuple(const char *classname, const cling::LookupHelper &lh)
R__DLLEXPORT void TCling__DEBUG__printName(clang::Decl *D)
R__DLLEXPORT void TCling__DEBUG__decl_dump(void *D)
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.
R__DLLEXPORT clang::NamespaceDecl * TCling__DEBUG__DCtoNamespace(clang::DeclContext *DC)
void TCling__UnlockCompilationDuringUserCodeExecution(void *)
Unlock the interpreter.
const char * TCling__GetClassSharedLibs(const char *className)
R__DLLEXPORT clang::RecordDecl * TCling__DEBUG__DCtoRecordDecl(clang::DeclContext *DC)
static bool R__InitStreamerInfoFactory()
Helper to initialize TVirtualStreamerInfo's factor early.
int TCling__AutoParseCallback(const char *className)
int TCling_GenerateDictionary(const std::vector< std::string > &classes, const std::vector< std::string > &headers, const std::vector< std::string > &fwdDecls, const std::vector< std::string > &unknown)
R__DLLEXPORT bool TCling__TEST_isInvalidDecl(clang::Decl *D)
static bool HaveFullGlobalModuleIndex
R__DLLEXPORT void DestroyInterpreter(TInterpreter *interp)
void TCling__LibraryUnloadedRTTI(const void *dyLibHandle, const char *canonicalName)
void TCling__UpdateListsOnCommitted(const cling::Transaction &T, cling::Interpreter *)
const Decl * TCling__GetObjectDecl(TObject *obj)
static ETupleOrdering IsTupleAscending()
R__DLLEXPORT TInterpreter * CreateInterpreter(void *interpLibHandle, const char *argv[])
void TCling__RegisterRdictForLoadPCM(const std::string &pcmFileNameFullPath, llvm::StringRef *pcmContent)
R__DLLEXPORT void TCling__DEBUG__dump(clang::DeclContext *DC)
static void TCling__UpdateClassInfo(const NamedDecl *TD)
Update TClingClassInfo for a class (e.g. upon seeing a definition).
int TCling__CompileMacro(const char *fileName, const char *options)
void * TCling__ResetInterpreterMutex()
Reset the interpreter lock to the state it had before interpreter-related calls happened.
static void * LazyFunctionCreatorAutoloadForModule(const std::string &mangled_name, const cling::DynamicLibraryManager &DLM)
int TCling__AutoLoadCallback(const char *className)
static bool LoadModule(const std::string &ModuleName, cling::Interpreter &interp)
static void RegisterCxxModules(cling::Interpreter &clingInterp)
static void ConstructorName(std::string &name, const clang::Decl *decl, cling::Interpreter &interp, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt)
void TCling__PrintStackTrace()
Print a StackTrace!
static int HandleInterpreterException(cling::MetaProcessor *metaProcessor, const char *input_line, cling::Interpreter::CompilationResult &compRes, cling::Value *result)
Let cling process a command line.
static std::string GetSharedLibImmediateDepsSlow(std::string lib, cling::Interpreter *interp, bool skipLoadedLibs=true)
This interface returns a list of dependent libraries in the form: lib libA.so libB....
static clang::ClassTemplateDecl * FindTemplateInNamespace(clang::Decl *decl)
Find a template decl within N nested namespaces, 0<=N<inf Assumes 1 and only 1 template present and 1...
static void PrintDlError(const char *dyLibName, const char *modulename)
void TCling__LibraryLoadedRTTI(const void *dyLibHandle, const char *canonicalName)
static cling::Interpreter::CompilationResult ExecAutoParse(const char *what, Bool_t header, cling::Interpreter *interpreter)
Parse the payload or header.
static bool requiresRootMap(const char *rootmapfile)
TObject * TCling__GetObjectAddress(const char *Name, void *&LookupCtx)
static void LoadModules(const std::vector< std::string > &modules, cling::Interpreter &interp)
Loads the C++ modules that we require to run any ROOT program.
int TCling__IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *nsDecl)
static bool hasPrecomputedLibraryDeps(llvm::StringRef lib)
void TCling__SplitAclicMode(const char *fileName, string &mode, string &args, string &io, string &fname)
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
R__EXTERN Int_t gErrorIgnoreLevel
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.
R__EXTERN TVirtualMutex * gInterpreterMutex
#define R__LOCKGUARD_CLING(mutex)
R__EXTERN TInterpreter * gCling
char * Form(const char *fmt,...)
Bool_t R_ISREG(Int_t mode)
R__EXTERN TSystem * gSystem
R__EXTERN TVirtualMutex * gGlobalMutex
#define R__LOCKGUARD(mutex)
#define R__WRITE_LOCKGUARD(mutex)
#define R__READ_LOCKGUARD(mutex)
virtual std::unique_ptr< StateDelta > Rewind(const State &earlierState)=0
virtual void Apply(std::unique_ptr< StateDelta > &&delta)=0
virtual std::unique_ptr< State > GetStateBefore()=0
virtual TApplicationImp * GetApplicationImp()
virtual Bool_t IsCmdThread()
static Longptr_t ExecuteFile(const char *file, Int_t *error=0, Bool_t keep=kFALSE)
Execute a file containing a C++ macro (static method).
Each class (see TClass) has a linked list of its base class(es).
TClassRef is used to implement a permanent reference to a TClass object.
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
static TProtoClass * GetProtoNorm(const char *cname)
Given the class normalized name returns the TClassProto object for the class.
static DictFuncPtr_t GetDictNorm(const char *cname)
Given the normalized class name returns the Dictionary() function of a class (uses hash of name).
static TProtoClass * GetProto(const char *cname)
Given the class name returns the TClassProto object for the class.
static Bool_t Check(const char *cname, std::string &normname)
static void Add(const char *cname, Version_t id, const std::type_info &info, DictFuncPtr_t dict, Int_t pragmabits)
Add a class to the class table (this is a static function).
TClass instances represent classes, structs and namespaces in the ROOT type system.
TDataMember * GetDataMember(const char *datamember) const
Return pointer to datamember object with name "datamember".
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
EState fState
cached of the streaming method to use
std::atomic< TList * > fBase
static void AddClassToDeclIdMap(TDictionary::DeclId_t id, TClass *cl)
static: Add a TClass* to the map of classes.
TList * GetListOfFunctionTemplates(Bool_t load=kTRUE)
Return 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.
TObjArray * fStreamerInfo
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
ClassInfo_t * GetClassInfo() const
Long_t Property() const
Returns the properties of the TClass as a bit field stored as a Long_t value.
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
void ResetCaches()
To clean out all caches.
static Int_t ReadRules()
Read the class.rules files from the default location:.
Version_t GetClassVersion() const
std::atomic< Bool_t > fHasRootPcmInfo
C++ Property of the class (is abstract, has virtual table, etc.)
const char * GetDeclFileName() const
Return name of the file containing the declaration of this class.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Emulation of the CINT BaseClassInfo class.
const char * TmpltName() const
const char * Name() const
ptrdiff_t Offset(void *address=0, bool isDerivedObject=true) const
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
TClingClassInfo * GetBase() const
Emulation of the CINT CallFunc class.
void ExecWithReturn(void *address, void *ret=nullptr)
void SetArgs(const char *args)
double ExecDouble(void *address)
void SetArgArray(Longptr_t *argArr, int narg)
Longptr_t ExecInt(void *address)
TInterpreter::CallFuncIFacePtr_t IFacePtr()
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
int get_wrapper_code(std::string &wrapper_name, std::string &wrapper)
void IgnoreExtraArgs(bool ignore)
long long ExecInt64(void *address)
bool IsAutoLoadingEnabled()
void SetAutoParsingSuspended(bool val=true)
void SetAutoLoadingEnabled(bool val=true)
Emulation of the CINT ClassInfo class.
static bool IsEnum(cling::Interpreter *interp, const char *name)
long ClassProperty() const
void Init(const char *name)
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
EDataType GetUnderlyingType() const
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
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
void * InterfaceMethod(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
const clang::FunctionDecl * GetTargetFunctionDecl() const
Get the FunctionDecl, or if this represents a UsingShadowDecl, the underlying target FunctionDecl.
const char * GetPrototype()
long ExtraProperty() const
void CreateSignature(TString &signature) const
TDictionary::DeclId_t GetDeclId() const
TClingTypeInfo * Type() const
Emulation of the CINT TypeInfo class.
std::string NormalizedName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Return the normalized name of the type (i.e.
const char * Name() const override
bool IsValid() const override
clang::QualType GetQualType() const
void Init(const char *name)
const char * TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Return the normalized name of the type (i.e.
Emulation of the CINT TypedefInfo class.
const char * TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Get the name of the underlying type of the current typedef.
long Property() const
Return a bit mask of metadata about the current typedef.
const char * Name() const override
Get the name of the current typedef.
void Init(const char *name)
Lookup named typedef and reset the iterator to point to it.
int Next()
Increment the iterator.
int Size() const
Return the size in bytes of the underlying type of the current typedef.
Bridge between cling::Value and ROOT.
bool Append(const std::string &str)
Append string to the storage if not added already.
This class defines an interface to the cling C++ interpreter.
virtual const char * MethodArgInfo_DefaultValue(MethodArgInfo_t *marginfo) const
static Int_t DeepAutoLoadImpl(const char *cls, std::unordered_set< std::string > &visited, bool nameIsNormalized)
virtual std::string CallFunc_GetWrapperCode(CallFunc_t *func) const
virtual void FuncTempInfo_Name(FuncTempInfo_t *, TString &name) const
Return the name of this function template.
virtual void FuncTempInfo_Title(FuncTempInfo_t *, TString &name) const
Return the comments associates with this function template.
virtual int TypedefInfo_Next(TypedefInfo_t *tinfo) const
virtual bool DiagnoseIfInterpreterException(const std::exception &e) const
virtual bool ClassInfo_IsValid(ClassInfo_t *info) const
virtual bool ClassInfo_IsScopedEnum(ClassInfo_t *info) const
Bool_t HasPCMForLibrary(const char *libname) const
Return true if ROOT has cxxmodules pcm for a given library name.
virtual MethodInfo_t * MethodInfo_FactoryCopy(MethodInfo_t *minfo) const
virtual const char * TypeInfo_Name(TypeInfo_t *) const
DeclId_t GetFunction(ClassInfo_t *cl, const char *funcname)
Return pointer to cling interface function for a method of a class with a certain name.
bool LibraryLoadingFailed(const std::string &, const std::string &, bool, bool)
Longptr_t ProcessLineSynch(const char *line, EErrorCode *error=0)
Let cling process a command line synchronously, i.e we are waiting it will be finished.
virtual bool ClassInfo_HasMethod(ClassInfo_t *info, const char *name) const
std::vector< void * > fRegisterModuleDyLibs
virtual MethodInfo_t * CallFunc_FactoryMethod(CallFunc_t *func) const
virtual bool MethodInfo_IsValid(MethodInfo_t *minfo) const
std::vector< std::string > fAutoLoadLibStorage
virtual const char * DataMemberInfo_TypeTrueName(DataMemberInfo_t *dminfo) const
void CreateListOfDataMembers(TClass *cl) const
Create list of pointers to data members for TClass cl.
void UnRegisterTClassUpdate(const TClass *oldcl)
If the dictionary is loaded, we can remove the class from the list (otherwise the class might be load...
void HandleNewDecl(const void *DV, bool isDeserialized, std::set< TClass * > &modifiedClasses)
void InvalidateCachedDecl(const std::tuple< TListOfDataMembers *, TListOfFunctions *, TListOfFunctionTemplates *, TListOfEnums * > &Lists, const clang::Decl *D)
Invalidate cached TCling information for the given declaration, and removed it from the appropriate o...
virtual const char * MethodInfo_TypeName(MethodInfo_t *minfo) const
bool RegisterPrebuiltModulePath(const std::string &FullPath, const std::string &ModuleMapName="module.modulemap") const
virtual Long_t TypedefInfo_Property(TypedefInfo_t *tinfo) const
virtual void MethodArgInfo_Delete(MethodArgInfo_t *marginfo) const
virtual void LoadFunctionTemplates(TClass *cl) const
Create list of pointers to function templates for TClass cl.
virtual CallFunc_t * CallFunc_Factory() const
virtual TypedefInfo_t * TypedefInfo_FactoryCopy(TypedefInfo_t *tinfo) const
std::vector< const char * > fCurExecutingMacros
void UpdateListsOnCommitted(const cling::Transaction &T)
virtual void SetAllocunlockfunc(void(*)()) const
[Place holder for Mutex Unlock] Provide the interpreter with a way to release a lock used to protect ...
void UpdateListOfTypes()
No op: see TClingCallbacks (used to update the list of types)
const char * GetSharedLibDeps(const char *lib, bool tryDyld=false)
Get the list a libraries on which the specified lib depends.
virtual DeclId_t GetDataMemberAtAddr(const void *addr) const
Return pointer to cling DeclId for a data member with a given name.
virtual int DataMemberInfo_ArrayDim(DataMemberInfo_t *dminfo) const
virtual bool ClassInfo_IsBase(ClassInfo_t *info, const char *name) const
virtual int BaseClassInfo_Next(BaseClassInfo_t *bcinfo) const
virtual void GenericError(const char *error) const
Let the interpreter issue a generic error, and set its error state.
virtual std::string MethodArgInfo_TypeNormalizedName(MethodArgInfo_t *marginfo) const
virtual const char * ClassInfo_TmpltName(ClassInfo_t *info) const
virtual TEnum * CreateEnum(void *VD, TClass *cl) const
virtual EReturnType MethodCallReturnType(TFunction *func) const
virtual int UnloadFile(const char *path) const
virtual int Evaluate(const char *, TInterpreterValue &)
Get the interpreter value corresponding to the statement.
TObject * GetObjectAddress(const char *Name, void *&LookupCtx)
If the interpreter encounters Name, check whether that is an object ROOT could retrieve.
virtual Long_t TypeInfo_Property(TypeInfo_t *tinfo) const
DeclId_t GetFunctionWithPrototype(ClassInfo_t *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Return pointer to cling interface function for a method of a class with a certain prototype,...
bool IsClassAutoLoadingEnabled() const
Returns if class AutoLoading is currently enabled.
void InvalidateGlobal(const clang::Decl *D)
Invalidate cached TCling information for the given global declaration.
void EndOfLineAction()
It calls a "fantom" method to synchronize user keyboard input and ROOT prompt line.
DeclId_t GetFunctionWithValues(ClassInfo_t *cl, const char *method, const char *params, Bool_t objectIsConst=kFALSE)
Return pointer to cling DeclId for a method of a class with a certain prototype, i....
void UpdateListOfLoadedSharedLibraries()
void RegisterModule(const char *modulename, const char **headers, const char **includePaths, const char *payloadCode, const char *fwdDeclsCode, void(*triggerFunc)(), const FwdDeclArgsToKeepCollection_t &fwdDeclsArgToSkip, const char **classesHeaders, Bool_t lateRegistration=false, Bool_t hasCxxModule=false)
Inject the module named "modulename" into cling; load all headers.
virtual const char * DataMemberInfo_ValidArrayIndex(DataMemberInfo_t *dminfo) const
void InitRootmapFile(const char *name)
Create a resource table and read the (possibly) three resource files, i.e. $ROOTSYS/etc/system<name> ...
virtual Longptr_t ClassInfo_GetBaseOffset(ClassInfo_t *fromDerived, ClassInfo_t *toBase, void *address, bool isDerivedObject) const
void CreateListOfMethodArgs(TFunction *m) const
Create list of pointers to method arguments for TMethod m.
virtual void TypedefInfo_Init(TypedefInfo_t *tinfo, const char *name) const
virtual Long_t MethodInfo_ExtraProperty(MethodInfo_t *minfo) const
virtual void ReportDiagnosticsToErrorHandler(bool enable=true)
Report diagnostics to the ROOT error handler (see TError.h).
void LoadPCM(std::string pcmFileNameFullPath)
Tries to load a rdict PCM, issues diagnostics if it fails.
virtual ~TCling()
Destroy the interpreter interface.
void AddFriendToClass(clang::FunctionDecl *, clang::CXXRecordDecl *) const
Inject function as a friend into klass.
Bool_t fCxxModulesEnabled
void RefreshClassInfo(TClass *cl, const clang::NamedDecl *def, bool alias)
Internal function. Actually do the update of the ClassInfo when seeing.
void ExecuteWithArgsAndReturn(TMethod *method, void *address, const void *args[]=0, int nargs=0, void *ret=0) const
virtual void FuncTempInfo_Delete(FuncTempInfo_t *) const
Delete the FuncTempInfo_t.
Bool_t SetSuspendAutoParsing(Bool_t value)
Suspend the Autoparsing of headers.
virtual DataMemberInfo_t * DataMemberInfo_FactoryCopy(DataMemberInfo_t *dminfo) const
virtual CallFuncIFacePtr_t CallFunc_IFacePtr(CallFunc_t *func) const
Longptr_t Calc(const char *line, EErrorCode *error=0)
Directly execute an executable statement (e.g.
virtual void CallFunc_ExecWithReturn(CallFunc_t *func, void *address, void *ret) const
virtual MethodArgInfo_t * MethodArgInfo_Factory() const
virtual void DataMemberInfo_Delete(DataMemberInfo_t *dminfo) const
void ApplyToInterpreterMutex(void *delta)
Re-apply the lock count delta that TCling__ResetInterpreterMutex() caused.
void * LazyFunctionCreatorAutoload(const std::string &mangled_name)
Autoload a library based on a missing symbol.
virtual int LoadFile(const char *path) const
Load a source file or library called path into the interpreter.
void CodeComplete(const std::string &, size_t &, std::vector< std::string > &)
The call to Cling's tab complition.
virtual Long_t FuncTempInfo_Property(FuncTempInfo_t *) const
Return the property of the function template.
virtual TypeInfo_t * MethodInfo_Type(MethodInfo_t *minfo) const
virtual const char * MethodArgInfo_TypeName(MethodArgInfo_t *marginfo) const
Bool_t HandleNewTransaction(const cling::Transaction &T)
Helper function to increase the internal Cling count of transactions that change the AST.
virtual bool ClassInfo_HasDefaultConstructor(ClassInfo_t *info, Bool_t testio=kFALSE) const
virtual bool DataMemberInfo_IsValid(DataMemberInfo_t *dminfo) const
int ReadRootmapFile(const char *rootmapfile, TUniqueString *uniqueString=nullptr)
Read and parse a rootmapfile in its new format, and return 0 in case of success, -1 if the file has a...
Bool_t IsLoaded(const char *filename) const
Return true if the file has already been loaded by cint.
const char * GetSharedLibs()
Return the list of shared libraries loaded into the process.
virtual const char * GetTopLevelMacroName() const
Return the file name of the current un-included interpreted file.
std::map< SpecialObjectLookupCtx_t, SpecialObjectMap_t > fSpecialObjectMaps
virtual DeclId_t GetDataMemberWithValue(const void *ptrvalue) const
NOT IMPLEMENTED.
virtual bool MethodArgInfo_IsValid(MethodArgInfo_t *marginfo) const
Int_t ReloadAllSharedLibraryMaps()
Reload the library map entries coming from all the loaded shared libraries, after first unloading the...
virtual void SetErrmsgcallback(void *p) const
Set a callback to receive error messages.
virtual std::string ToString(const char *type, void *obj)
virtual const char * MethodInfo_Title(MethodInfo_t *minfo) const
virtual int DataMemberInfo_TypeSize(DataMemberInfo_t *dminfo) const
virtual ClassInfo_t * ClassInfo_Factory(Bool_t all=kTRUE) const
virtual const char * MethodInfo_GetMangledName(MethodInfo_t *minfo) const
virtual bool CallFunc_IsValid(CallFunc_t *func) const
virtual const char * BaseClassInfo_TmpltName(BaseClassInfo_t *bcinfo) const
virtual void SetAlloclockfunc(void(*)()) const
[Place holder for Mutex Lock] Provide the interpreter with a way to acquire a lock used to protect cr...
virtual void MethodInfo_CreateSignature(MethodInfo_t *minfo, TString &signature) const
void SnapshotMutexState(ROOT::TVirtualRWMutex *mtx)
virtual Bool_t ClassInfo_Contains(ClassInfo_t *info, DeclId_t declid) const
Return true if the entity pointed to by 'declid' is declared in the context described by 'info'.
std::set< size_t > fPayloads
virtual const char * ClassInfo_Name(ClassInfo_t *info) const
Int_t UnloadLibraryMap(const char *library)
Unload library map entries coming from the specified library.
virtual ClassInfo_t * BaseClassInfo_ClassInfo(BaseClassInfo_t *) const
TObjArray * fRootmapFiles
virtual void CallFunc_Delete(CallFunc_t *func) const
virtual Long_t ClassInfo_ClassProperty(ClassInfo_t *info) const
cling::Interpreter * GetInterpreterImpl() const
virtual bool ClassInfo_IsLoaded(ClassInfo_t *info) const
std::vector< std::pair< TClass *, DictFuncPtr_t > > fClassesToUpdate
virtual int ClassInfo_GetMethodNArg(ClassInfo_t *info, const char *method, const char *proto, Bool_t objectIsConst=false, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
virtual Longptr_t BaseClassInfo_Tagnum(BaseClassInfo_t *bcinfo) const
Int_t DeleteGlobal(void *obj)
Delete obj from Cling symbol table so it cannot be accessed anymore.
virtual const char * GetCurrentMacroName() const
Return the file name of the currently interpreted file, included or not.
virtual void TypeInfo_Delete(TypeInfo_t *tinfo) const
virtual Bool_t LoadText(const char *text) const
Load the declarations from text into the interpreter.
void GetInterpreterTypeName(const char *name, std::string &output, Bool_t full=kFALSE)
The 'name' is known to the interpreter, this function returns the internal version of this name (usua...
void * RewindInterpreterMutex()
Reset the interpreter lock to the state it had before interpreter-related calls happened.
virtual int GetSecurityError() const
Interface to cling function.
virtual UInt_t FuncTempInfo_TemplateMinReqArgs(FuncTempInfo_t *) const
Return the number of required template arguments of the function template described by ft_info.
void ResetGlobals()
Reset in Cling the list of global variables to the state saved by the last call to TCling::SaveGlobal...
Longptr_t ExecuteMacro(const char *filename, EErrorCode *error=0)
Execute a cling macro.
virtual const char * ClassInfo_Title(ClassInfo_t *info) const
virtual void AddAvailableIndentifiers(TSeqCollection &Idents)
virtual Long_t BaseClassInfo_Property(BaseClassInfo_t *bcinfo) const
virtual FuncTempInfo_t * FuncTempInfo_Factory(DeclId_t declid) const
Construct a FuncTempInfo_t.
void * GetInterfaceMethod(TClass *cl, const char *method, const char *params, Bool_t objectIsConst=kFALSE)
Return pointer to cling interface function for a method of a class with parameters params (params is ...
virtual void ClassInfo_Destruct(ClassInfo_t *info, void *arena) const
virtual const char * BaseClassInfo_FullName(BaseClassInfo_t *bcinfo) const
virtual bool ClassInfo_IsEnum(const char *name) const
virtual DataMemberInfo_t * DataMemberInfo_Factory(ClassInfo_t *clinfo, TDictionary::EMemberSelection selection) const
virtual void TypedefInfo_Delete(TypedefInfo_t *tinfo) const
void SetGetline(const char *(*getlineFunc)(const char *prompt), void(*histaddFunc)(const char *line))
Set a getline function to call when input is needed.
virtual Longptr_t BaseClassInfo_Offset(BaseClassInfo_t *toBaseClassInfo, void *address, bool isDerivedObject) const
void RewindDictionary()
Rewind Cling dictionary to the point where it was before executing the current macro.
std::map< std::string, llvm::StringRef > fPendingRdicts
virtual const char * MapCppName(const char *) const
Interface to cling function.
static void UpdateClassInfoWork(const char *name)
virtual bool ClassInfo_IsValidMethod(ClassInfo_t *info, const char *method, const char *proto, Longptr_t *offset, ROOT::EFunctionMatchMode=ROOT::kConversionMatch) const
virtual Long_t FuncTempInfo_ExtraProperty(FuncTempInfo_t *) const
Return the property not already defined in Property See TDictionary's EFunctionProperty.
void PrintIntro()
No-op; see TRint instead.
virtual CallFunc_t * CallFunc_FactoryCopy(CallFunc_t *func) const
virtual const char * DataMemberInfo_Name(DataMemberInfo_t *dminfo) const
Bool_t Declare(const char *code)
Declare code to the interpreter, without any of the interpreter actions that could trigger a re-inter...
Int_t DeleteVariable(const char *name)
Undeclare obj called name.
virtual int ClassInfo_Next(ClassInfo_t *info) const
static void * fgSetOfSpecials
void AddIncludePath(const char *path)
Add a directory to the list of directories in which the interpreter looks for include files.
virtual const char * MethodInfo_Name(MethodInfo_t *minfo) const
void ClearFileBusy()
Reset the interpreter internal state in case a previous action was not correctly terminated.
virtual const char * MethodArgInfo_Name(MethodArgInfo_t *marginfo) const
virtual Long_t ClassInfo_Property(ClassInfo_t *info) const
ROOT::TMetaUtils::TNormalizedCtxt * fNormalizedCtxt
virtual int MethodInfo_Next(MethodInfo_t *minfo) const
const char * TypeName(const char *typeDesc)
Return the absolute type of typeDesc.
void SaveContext()
Save the current Cling state.
std::set< TClass * > & GetModTClasses()
Longptr_t ProcessLine(const char *line, EErrorCode *error=0)
virtual bool TypeInfo_IsValid(TypeInfo_t *tinfo) const
Int_t AutoLoad(const char *classname, Bool_t knowDictNotLoaded=kFALSE)
Load library containing the specified class.
TClingCallbacks * fClingCallbacks
TString GetMangledNameWithPrototype(TClass *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Return the cling mangled name for a method of a class with a certain prototype, i....
void RegisterTClassUpdate(TClass *oldcl, DictFuncPtr_t dict)
Register classes that already existed prior to their dictionary loading and that already had a ClassI...
virtual Long_t DataMemberInfo_Property(DataMemberInfo_t *dminfo) const
void UpdateListOfGlobalFunctions()
No op: see TClingCallbacks (used to update the list of global functions)
virtual const char * MethodInfo_GetPrototype(MethodInfo_t *minfo) const
Longptr_t ProcessLineAsynch(const char *line, EErrorCode *error=0)
Let cling process a command line asynch.
virtual Longptr_t CallFunc_ExecInt(CallFunc_t *func, void *address) const
virtual void * ClassInfo_New(ClassInfo_t *info) const
virtual void TypeInfo_Init(TypeInfo_t *tinfo, const char *funcname) const
Bool_t SetErrorMessages(Bool_t enable=kTRUE)
If error messages are disabled, the interpreter should suppress its failures and warning messages fro...
virtual const char * DataMemberInfo_Title(DataMemberInfo_t *dminfo) const
void TransactionRollback(const cling::Transaction &T)
virtual EDataType ClassInfo_GetUnderlyingType(ClassInfo_t *info) const
virtual void CallFunc_Init(CallFunc_t *func) const
virtual UInt_t FuncTempInfo_TemplateNargs(FuncTempInfo_t *) const
Return the maximum number of template arguments of the function template described by ft_info.
TString GetMangledName(TClass *cl, const char *method, const char *params, Bool_t objectIsConst=kFALSE)
Return the cling mangled name for a method of a class with parameters params (params is a string of a...
virtual void SetTempLevel(int val) const
Create / close a scope for temporaries.
virtual DeclId_t GetDataMember(ClassInfo_t *cl, const char *name) const
Return pointer to cling Decl of global/static variable that is located at the address given by addr.
void RegisterTemporary(const TInterpreterValue &value)
MutexStateAndRecurseCount fInitialMutex
virtual void LoadEnums(TListOfEnums &cl) const
Create list of pointers to enums for TClass cl.
virtual void CallFunc_SetArg(CallFunc_t *func, Long_t param) const
virtual Long_t GetExecByteCode() const
This routines used to return the address of the internal wrapper function (of the interpreter) that w...
virtual void * MethodInfo_InterfaceMethod(MethodInfo_t *minfo) const
Int_t UnloadAllSharedLibraryMaps()
Unload the library map entries coming from all the loaded shared libraries.
virtual void CallFunc_IgnoreExtraArgs(CallFunc_t *func, bool ignore) const
std::vector< cling::Value > * fTemporaries
virtual Long_t MethodInfo_Property(MethodInfo_t *minfo) const
virtual std::unique_ptr< TInterpreterValue > MakeInterpreterValue() const
static Int_t ShallowAutoLoadImpl(const char *cls)
void LibraryLoaded(const void *dyLibHandle, const char *canonicalName)
virtual TypedefInfo_t * TypedefInfo_Factory() const
void UpdateListOfGlobals()
No op: see TClingCallbacks (used to update the list of globals)
void ClearStack()
Delete existing temporary values.
std::map< const cling::Transaction *, size_t > fTransactionHeadersMap
virtual int SetClassAutoparsing(int)
Enable/Disable the Autoparsing of headers.
Bool_t fHeaderParsingOnDemand
virtual int SetClassAutoLoading(int) const
Enable/Disable the AutoLoading of libraries.
Int_t RescanLibraryMap()
Scan again along the dynamic path for library maps.
virtual int DataMemberInfo_Next(DataMemberInfo_t *dminfo) const
void Reset()
Pressing Ctrl+C should forward here.
Int_t Load(const char *filenam, Bool_t system=kFALSE)
Load a library file in cling's memory.
void InspectMembers(TMemberInspector &, const void *obj, const TClass *cl, Bool_t isTransient)
Visit all members over members, recursing over base classes.
std::hash< std::string > fStringHashFunction
const char * GetIncludePath()
Refresh the list of include paths known to the interpreter and return it with -I prepended.
static void RemoveAndInvalidateObject(List &L, Object *O)
virtual void ClassInfo_DeleteArray(ClassInfo_t *info, void *arena, bool dtorOnly) const
virtual void GetFunctionName(const clang::Decl *decl, std::string &name) const
virtual DeclId_t GetEnum(TClass *cl, const char *name) const
Return pointer to cling Decl of global/static variable that is located at the address given by addr.
void GetFunctionOverloads(ClassInfo_t *cl, const char *funcname, std::vector< DeclId_t > &res) const
Insert overloads of name in cl to res.
virtual Longptr_t DataMemberInfo_Offset(DataMemberInfo_t *dminfo) const
virtual void CallFunc_Exec(CallFunc_t *func, void *address) const
virtual int DisplayIncludePath(FILE *fout) const
Interface to cling function.
void RegisterLoadedSharedLibrary(const char *name)
Register a new shared library name with the interpreter; add it to fSharedLibs.
virtual void UpdateEnumConstants(TEnum *enumObj, TClass *cl) const
void SaveGlobalsContext()
Save the current Cling state of global objects.
std::unordered_set< const clang::NamespaceDecl * > fNSFromRootmaps
void ProcessClassesToUpdate()
virtual Long_t MethodArgInfo_Property(MethodArgInfo_t *marginfo) const
virtual const char * GetSTLIncludePath() const
Return the directory containing CINT's stl cintdlls.
Int_t LoadLibraryMap(const char *rootmapfile=0)
Load map between class and library.
virtual std::string MethodInfo_TypeNormalizedName(MethodInfo_t *minfo) const
void Execute(const char *function, const char *params, int *error=0)
Execute a global function with arguments params.
virtual const char * ClassInfo_FullName(ClassInfo_t *info) const
TClass * GenerateTClass(const char *classname, Bool_t emulation, Bool_t silent=kFALSE)
Generate a TClass for the given class.
virtual Longptr_t ClassInfo_Tagnum(ClassInfo_t *info) const
virtual int TypeInfo_Size(TypeInfo_t *tinfo) const
virtual int MethodArgInfo_Next(MethodArgInfo_t *marginfo) const
ROOT::TMetaUtils::TClingLookupHelper * fLookupHelper
virtual const char * TypedefInfo_TrueName(TypedefInfo_t *tinfo) const
Bool_t fIsAutoParsingSuspended
TClass * GetClass(const std::type_info &typeinfo, Bool_t load) const
Demangle the name (from the typeinfo) and then request the class via the usual name based interface (...
DeclId_t GetDeclId(const llvm::GlobalValue *gv) const
Return pointer to cling DeclId for a global value.
virtual std::vector< std::string > GetUsingNamespaces(ClassInfo_t *cl) const
Get the scopes representing using declarations of namespace.
Int_t SetClassSharedLibs(const char *cls, const char *libs)
Register the AutoLoading information for a class.
virtual void ClassInfo_Init(ClassInfo_t *info, const char *funcname) const
virtual TypeInfo_t * TypeInfo_FactoryCopy(TypeInfo_t *) const
Bool_t CheckClassTemplate(const char *name)
Return true if there is a class template by the given name ...
void LoadPCMImpl(TFile &pcmFile)
Tries to load a PCM from TFile; returns true on success.
Bool_t IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *nsDecl)
TObjArray * GetRootMapFiles() const
void * fPrevLoadedDynLibInfo
void UpdateListOfDataMembers(TClass *cl) const
Update the list of pointers to data members for TClass cl This is now a nop.
virtual void SetDeclAttr(DeclId_t, const char *)
virtual Long_t DataMemberInfo_TypeProperty(DataMemberInfo_t *dminfo) const
virtual const char * DataMemberInfo_TypeName(DataMemberInfo_t *dminfo) const
virtual void CallFunc_SetArgs(CallFunc_t *func, const char *param) const
virtual const char * BaseClassInfo_Name(BaseClassInfo_t *bcinfo) const
virtual void MethodInfo_Delete(MethodInfo_t *minfo) const
Interface to cling function.
virtual void CallFunc_SetFunc(CallFunc_t *func, ClassInfo_t *info, const char *method, const char *params, Longptr_t *Offset) const
virtual const char * TypeInfo_TrueName(TypeInfo_t *tinfo) const
std::set< const char * > fParsedPayloadsAddresses
ECheckClassInfo CheckClassInfo(const char *name, Bool_t autoload, Bool_t isClassOrNamespaceOnly=kFALSE)
Checks if an entity with the specified name is defined in Cling.
static void UpdateClassInfo(char *name, Long_t tagnum)
No op: see TClingCallbacks.
virtual void BaseClassInfo_Delete(BaseClassInfo_t *bcinfo) const
void ResetGlobalVar(void *obj)
Reset the Cling 'user' global objects/variables state to the state saved by the last call to TCling::...
std::unique_ptr< cling::Interpreter > fInterpreter
Bool_t IsLibraryLoaded(const char *libname) const
virtual void Initialize()
Initialize the interpreter, once TROOT::fInterpreter is set.
virtual void * FindSym(const char *entry) const
Interface to cling function.
virtual int DataMemberInfo_MaxIndex(DataMemberInfo_t *dminfo, Int_t dim) const
void SetClassInfo(TClass *cl, Bool_t reload=kFALSE)
Set pointer to the TClingClassInfo in TClass.
virtual int TypeInfo_RefType(TypeInfo_t *) const
cling::MetaProcessor * GetMetaProcessorImpl() const
void LoadMacro(const char *filename, EErrorCode *error=0)
Load a macro file in cling's memory.
std::set< size_t > fLookedUpClasses
virtual void CallFunc_ResetArg(CallFunc_t *func) const
virtual Long64_t CallFunc_ExecInt64(CallFunc_t *func, void *address) const
void ResetAll()
Reset the Cling state to its initial state.
virtual void ClassInfo_Delete(ClassInfo_t *info) const
virtual Double_t CallFunc_ExecDouble(CallFunc_t *func, void *address) const
UInt_t AutoParseImplRecurse(const char *cls, bool topLevel)
Helper routine for TCling::AutoParse implementing the actual call to the parser and looping over temp...
virtual const char * TypedefInfo_Title(TypedefInfo_t *tinfo) const
void CreateListOfBaseClasses(TClass *cl) const
Create list of pointers to base class(es) for TClass cl.
void RecursiveRemove(TObject *obj)
Delete object from cling symbol table so it can not be used anymore.
virtual MethodArgInfo_t * MethodArgInfo_FactoryCopy(MethodArgInfo_t *marginfo) const
void UpdateListsOnUnloaded(const cling::Transaction &T)
Invalidate stored TCling state for declarations included in transaction ‘T’.
void UpdateClassInfoWithDecl(const clang::NamedDecl *ND)
Internal function. Inform a TClass about its new TagDecl or NamespaceDecl.
virtual void CallFunc_SetFuncProto(CallFunc_t *func, ClassInfo_t *info, const char *method, const char *proto, Longptr_t *Offset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
Interface to cling function.
virtual const char * ClassInfo_FileName(ClassInfo_t *info) const
virtual void CallFunc_ExecWithArgsAndReturn(CallFunc_t *func, void *address, const void *args[]=0, int nargs=0, void *ret=0) const
DeclId_t GetFunctionTemplate(ClassInfo_t *cl, const char *funcname)
Return pointer to cling interface function for a method of a class with a certain name.
virtual int MethodInfo_NArg(MethodInfo_t *minfo) const
virtual FuncTempInfo_t * FuncTempInfo_FactoryCopy(FuncTempInfo_t *) const
Construct a FuncTempInfo_t.
virtual int TypedefInfo_Size(TypedefInfo_t *tinfo) const
std::unique_ptr< cling::MetaProcessor > fMetaProcessor
virtual const char * TypedefInfo_Name(TypedefInfo_t *tinfo) const
virtual int DisplayClass(FILE *fout, const char *name, int base, int start) const
const char * GetClassSharedLibs(const char *cls)
Get the list of shared libraries containing the code for class cls.
Bool_t IsErrorMessagesEnabled() const
If error messages are disabled, the interpreter should suppress its failures and warning messages fro...
ULong64_t fTransactionCount
virtual Bool_t FuncTempInfo_IsValid(FuncTempInfo_t *) const
Check validity of a FuncTempInfo_t.
virtual BaseClassInfo_t * BaseClassInfo_Factory(ClassInfo_t *info) const
virtual bool TypedefInfo_IsValid(TypedefInfo_t *tinfo) const
virtual MethodInfo_t * MethodInfo_Factory() const
Int_t AutoParse(const char *cls)
Parse the headers relative to the class Returns 1 in case of success, 0 in case of failure.
virtual EReturnType MethodInfo_MethodCallReturnType(MethodInfo_t *minfo) const
void * GetInterfaceMethodWithPrototype(TClass *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Return pointer to cling interface function for a method of a class with a certain prototype,...
virtual TypeInfo_t * TypeInfo_Factory() const
std::map< size_t, std::vector< const char * > > fClassesHeadersMap
virtual int MethodInfo_NDefaultArg(MethodInfo_t *minfo) const
Int_t GenerateDictionary(const char *classes, const char *includes="", const char *options=0)
Generate the dictionary for the C++ classes listed in the first argument (in a semi-colon separated l...
void CreateListOfMethods(TClass *cl) const
Create list of pointers to methods for TClass cl.
void UpdateListOfMethods(TClass *cl) const
Update the list of pointers to method for TClass cl This is now a nop.
virtual void CallFunc_SetArgArray(CallFunc_t *func, Longptr_t *paramArr, Int_t nparam) const
void RegisterRdictForLoadPCM(const std::string &pcmFileNameFullPath, llvm::StringRef *pcmContent)
Register Rdict data for future loading by LoadPCM;.
virtual int ClassInfo_Size(ClassInfo_t *info) const
static void UpdateAllCanvases()
Update all canvases at end the terminal input command.
void LibraryUnloaded(const void *dyLibHandle, const char *canonicalName)
Collection abstract base class.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
virtual Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void Add(TObject *obj)=0
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
TDirectory::TContext keeps track and restore the current directory.
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
Returns name of object.
The TEnv class reads config files, by default named .rootrc.
THashList * GetTable() const
Bool_t IgnoreDuplicates(Bool_t ignore)
If set to true, no warnings in case of duplicates are issued.
virtual void SetRcName(const char *name)
virtual Int_t ReadFile(const char *fname, EEnvLevel level)
Read and parse the resource file for a certain level.
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
Set the value of a resource or create a new resource.
virtual TEnvRec * Lookup(const char *n) const
Loop over all resource records and return the one with name.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Global functions class (global functions are obtained from CINT).
Global variables class (global variables are obtained from CINT).
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
TObject * Remove(TObject *obj)
Remove object from the list.
THashTable implements a hash table to store TObject's.
virtual const void * GetValAddr() const =0
This class defines an abstract interface to a generic command line interpreter.
virtual bool RegisterPrebuiltModulePath(const std::string &FullPath, const std::string &ModuleMapName="module.modulemap") const =0
virtual Bool_t HasPCMForLibrary(const char *libname) const =0
virtual Int_t AutoParse(const char *cls)=0
int(* AutoLoadCallBack_t)(const char *)
virtual const char * GetClassSharedLibs(const char *cls)=0
virtual Bool_t Declare(const char *code)=0
std::vector< std::pair< std::string, int > > FwdDeclArgsToKeepCollection_t
TDictionary::DeclId_t DeclId_t
virtual TObjArray * GetRootMapFiles() const =0
Book space in a file, create I/O buffers, to fill them, (un)compress them.
A collection of TDataMember objects designed for fast access given a DeclId_t and for keep track of T...
TDictionary * Find(DeclId_t id) const
Return (after creating it if necessary) the TDataMember describing the data member corresponding to t...
TClass * GetClass() const
virtual TObject * FindObject(const char *name) const
Specialize FindObject to do search for the a data member just by name or create it if its not already...
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
TEnum * Find(DeclId_t id) const
Return the TEnum corresponding to the Decl 'id' or NULL if it does not exist.
TEnum * Get(DeclId_t id, const char *name)
Return (after creating it if necessary) the TEnum describing the enum corresponding to the Decl 'id'.
TClass * GetClass() const
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TFunctionTemplate * Get(DeclId_t id)
Return (after creating it if necessary) the TMethod or TFunction describing the function correspondin...
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TFunction * Find(DeclId_t id) const
Return the TMethod or TFunction describing the function corresponding to the Decl 'id'.
virtual void Add(TObject *obj)
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
A TMemFile is like a normal TFile except that it reads and writes only from memory.
Abstract base class for accessing the data-members of a class.
const char * GetParent() const
virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr)
EObjectPointerState GetObjectValidity() const
virtual Bool_t IsTreatingNonAccessibleTypes()
void SetObjectValidity(EObjectPointerState val)
void InspectMember(const T &obj, const char *name, Bool_t isTransient)
Each ROOT method (see TMethod) has a linked list of its arguments.
const char * GetFullTypeName() const
Get full type description of method argument, e.g.: "class TDirectory*".
const char * GetDefault() const
Get default value of method argument.
Each ROOT class (see TClass) has a linked list of methods.
virtual TList * GetListOfMethodArgs()
Returns methodarg list and additionally updates fDataMember in TMethod by calling FindDataMember();.
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetName() const
Returns name of object.
Int_t GetEntriesFast() const
virtual void Expand(Int_t newSize)
Expand or shrink the array to newSize elements.
virtual void Compress()
Remove empty slots from array.
Int_t GetEntries() const
Return the number of objects in array (i.e.
virtual void Clear(Option_t *option="")
Remove all objects from the array.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
virtual TObject * Remove(TObject *obj)
Remove object from array.
TObject * At(Int_t idx) const
Collectable string class.
Mother of all ROOT objects.
virtual void Clear(Option_t *="")
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
R__ALWAYS_INLINE Bool_t IsOnHeap() const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual const char * GetTitle() const
Returns title of object.
@ kInvalidObject
if object ctor succeeded but object should not be used
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Persistent version of a TClass.
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
static const TString & GetIncludeDir()
Get the include directory in the installation. Static utility function.
static const char * GetMacroPath()
Get macro search path. Static utility function.
static const std::vector< std::string > & AddExtraInterpreterArgs(const std::vector< std::string > &args)
Provide command line arguments to the interpreter construction.
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
static const char **& GetExtraInterpreterArgs()
INTERNAL function! Used by rootcling to inject interpreter arguments through a C-interface layer.
static const TString & GetLibDir()
Get the library directory in the installation. Static utility function.
Sequenceable collection abstract base class.
virtual void Add(TObject *obj)
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.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Ssiz_t Last(char c) const
Find last occurrence of a character c.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Prepend(const char *cs)
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual void FreeDirectory(void *dirp)
Free a directory.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
virtual const char * Getenv(const char *env)
Get environment variable.
virtual const char * GetIncludePath()
Get the list of include path.
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form:
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
virtual int GetProcInfo(ProcInfo_t *info) const
Returns cpu and memory used by this process into the ProcInfo_t structure.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual const char * GetDynamicPath()
Return the dynamic path (used to find shared libraries).
virtual const char * FindDynamicLibrary(TString &lib, Bool_t quiet=kFALSE)
Find a dynamic library using the system search paths.
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual int CompileMacro(const char *filename, Option_t *opt="", const char *library_name="", const char *build_dir="", UInt_t dirmode=0)
This method compiles and loads a shared library containing the code from the file "filename".
virtual const char * WorkingDirectory()
Return working directory.
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual void Setenv(const char *name, const char *value)
Set environment variable.
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
virtual void StackTrace()
Print a stack trace.
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
virtual TVirtualMutex * Factory(Bool_t=kFALSE)=0
TVirtualPad is an abstract base class for the Pad and Canvas classes.
static void SetFactory(TVirtualStreamerInfo *factory)
static function: Set the StreamerInfo factory
@ kNeedObjectForVirtualBaseClass
const std::string & GetPathSeparator()
const char & GetEnvPathSeparator()
bool CanConvertEnvValueToBool(const std::string &value)
bool ConvertEnvValueToBool(const std::string &value)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
R__EXTERN TVirtualRWMutex * gCoreMutex
bool IsStdPairBase(std::string_view name)
bool IsStdArray(std::string_view name)
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
bool IsStdPair(std::string_view name)
std::string InsertStd(const char *tname)
bool SplitFunction(std::string_view decl, FunctionSplitInfo &result)
Split a function declaration into its different parts.
std::string GetLong64_Name(const char *original)
Replace 'long long' and 'unsigned long long' by 'Long64_t' and 'ULong64_t'.
char * DemangleTypeIdName(const std::type_info &ti, int &errorCode)
Demangle in a portable way the type id name.
const char * GetUnqualifiedName(const char *name)
Return the start of the unqualified name include in 'original'.
void Init(TClassEdit::TInterpreterLookupHelper *helper)
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
char * DemangleName(const char *mangled_name, int &errorCode)
int GetSplit(const char *type, std::vector< std::string > &output, int &nestedLoc, EModType mode=TClassEdit::kNone)
Stores in output (after emptying it) the split type.
EComplexType GetComplexType(const char *)
RAII used to store Parser, Sema, Preprocessor state for recursive parsing.
Result of splitting a function declaration into fReturnType fScopeName::fFunctionName<fFunctionTempla...
std::string fScopeName
Name of the scope qualification of the function, possibly empty.
std::vector< std::string > fElements
void ShortType(std::string &answer, int mode)
Return the absolute type of typeDesc into the string answ.
std::unique_ptr< ROOT::TVirtualRWMutex::State > fState
State of gCoreMutex when the first interpreter-related function was invoked.
Int_t fRecurseCount
Interpreter-related functions will push the "entry" lock state to *this.
A read-only memory range which we do not control.
static void output(int code)