63#include "RConfigure.h"
64#include "compiledata.h"
65#include "TClingUtils.h"
81#include "clang/AST/ASTContext.h"
82#include "clang/AST/Decl.h"
83#include "clang/AST/DeclarationName.h"
84#include "clang/AST/GlobalDecl.h"
85#include "clang/AST/RecordLayout.h"
86#include "clang/AST/DeclVisitor.h"
87#include "clang/AST/RecursiveASTVisitor.h"
88#include "clang/AST/Type.h"
89#include "clang/Basic/SourceLocation.h"
90#include "clang/Basic/Specifiers.h"
91#include "clang/Basic/TargetInfo.h"
92#include "clang/CodeGen/ModuleBuilder.h"
93#include "clang/Frontend/CompilerInstance.h"
94#include "clang/Frontend/FrontendDiagnostic.h"
95#include "clang/Lex/HeaderSearch.h"
96#include "clang/Lex/Preprocessor.h"
97#include "clang/Lex/PreprocessorOptions.h"
98#include "clang/Sema/Lookup.h"
99#include "clang/Sema/Sema.h"
100#include "clang/Parse/Parser.h"
102#include "cling/Interpreter/ClangInternalState.h"
103#include "cling/Interpreter/DynamicLibraryManager.h"
104#include "cling/Interpreter/Interpreter.h"
105#include "cling/Interpreter/LookupHelper.h"
106#include "cling/Interpreter/Value.h"
107#include "cling/Interpreter/Transaction.h"
108#include "cling/MetaProcessor/MetaProcessor.h"
109#include "cling/Utils/AST.h"
110#include "cling/Utils/ParserStateRAII.h"
111#include "cling/Utils/SourceNormalization.h"
112#include "cling/Interpreter/Exception.h"
114#include "llvm/IR/GlobalValue.h"
115#include "llvm/IR/Module.h"
117#include "llvm/Support/DynamicLibrary.h"
118#include "llvm/Support/raw_ostream.h"
119#include "llvm/Support/Path.h"
120#include "llvm/Support/Process.h"
121#include "llvm/Object/ELFObjectFile.h"
122#include "llvm/Object/ObjectFile.h"
123#include "llvm/Object/SymbolicFile.h"
124#include "llvm/Support/FileSystem.h"
138#include <unordered_map>
145#define R__DLLEXPORT __attribute__ ((visibility ("default")))
153#include <mach-o/dyld.h>
154#include <mach-o/loader.h>
161#if defined(__CYGWIN__)
162#include <sys/cygwin.h>
163#define HMODULE void *
165 __declspec(dllimport)
void * __stdcall GetCurrentProcess();
166 __declspec(dllimport)
bool __stdcall EnumProcessModules(
void *,
void **,
unsigned long,
unsigned long *);
167 __declspec(dllimport)
unsigned long __stdcall GetModuleFileNameExW(
void *,
void *,
wchar_t *,
unsigned long);
174# define STDIN_FILENO 0
177# define STDOUT_FILENO 1
180# define STDERR_FILENO 2
189#undef GetModuleFileName
190#define RTLD_DEFAULT ((void *)::GetModuleHandle(NULL))
191#define dlsym(library, function_name) ::GetProcAddress((HMODULE)library, function_name)
192#define dlopen(library_name, flags) ::LoadLibraryA(library_name)
193#define dlclose(library) ::FreeLibrary((HMODULE)library)
194#define R__DLLEXPORT __declspec(dllexport)
202 class TCling_UnloadMarker {
204 ~TCling_UnloadMarker() {
210 static TCling_UnloadMarker gTClingUnloadMarker;
219 return D->getDeclContext();
222 return llvm::dyn_cast<clang::NamespaceDecl>(DC);
225 return llvm::dyn_cast<clang::RecordDecl>(DC);
228 return DC->dumpDeclContext();
237 return ((clang::Decl*)D)->dump();
240 if (clang::NamedDecl* ND = llvm::dyn_cast<clang::NamedDecl>(D)) {
243 llvm::raw_string_ostream OS(
name);
244 ND->getNameForDiagnostic(OS, D->getASTContext().getPrintingPolicy(),
247 printf(
"%s\n",
name.c_str());
255 return D->isInvalidDecl();
259 assert(info && info->
IsValid());
260 return info->
GetDecl()->isInvalidDecl();
264using namespace clang;
268 static const std::string gInterpreterClassDef = R
"ICF(
270#define ClassDef(name, id) \
271_ClassDefInterp_(name,id,virtual,) \
272static int DeclFileLine() { return __LINE__; }
274#define ClassDefNV(name, id) \
275_ClassDefInterp_(name,id,,) \
276static int DeclFileLine() { return __LINE__; }
277#undef ClassDefOverride
278#define ClassDefOverride(name, id) \
279_ClassDefInterp_(name,id,,override) \
280static int DeclFileLine() { return __LINE__; }
283 static const std::string gNonInterpreterClassDef = R
"ICF(
284#define __ROOTCLING__ 1
286#define ClassDef(name,id) \
287_ClassDefOutline_(name,id,virtual,) \
288static int DeclFileLine() { return __LINE__; }
290#define ClassDefNV(name, id)\
291_ClassDefOutline_(name,id,,)\
292static int DeclFileLine() { return __LINE__; }
293#undef ClassDefOverride
294#define ClassDefOverride(name, id)\
295_ClassDefOutline_(name,id,,override)\
296static int DeclFileLine() { return __LINE__; }
300 static const std::string gClassDefInterpMacro = R
"ICF(
303#define _ClassDefInterp_(name,id,virtual_keyword, overrd) \
306 static TClass *Class() { static TClass* sIsA = 0; if (!sIsA) sIsA = TClass::GetClass(#name); return sIsA; } \
307 static const char *Class_Name() { return #name; } \
308 virtual_keyword Bool_t CheckTObjectHashConsistency() const overrd { return true; } \
309 static Version_t Class_Version() { return id; } \
310 static TClass *Dictionary() { return 0; } \
311 virtual_keyword TClass *IsA() const overrd { return name::Class(); } \
312 virtual_keyword void ShowMembers(TMemberInspector&insp) const overrd { ::ROOT::Class_ShowMembers(name::Class(), this, insp); } \
313 virtual_keyword void Streamer(TBuffer&) overrd { ::Error("Streamer", "Cannot stream interpreted class."); } \
314 void StreamerNVirtual(TBuffer&ClassDef_StreamerNVirtual_b) { name::Streamer(ClassDef_StreamerNVirtual_b); } \
315 static const char *DeclFileName() { return __FILE__; } \
316 static int ImplFileLine() { return 0; } \
317 static const char *ImplFileName() { return __FILE__; }
348 return ((
TCling*)
gCling)->LibraryLoadingFailed(errmessage, libStem, permanent, resolved);
387 static vector<const NamedDecl*> updateList;
390 if (entered) topLevel =
kFALSE;
405 updateList.push_back(TD);
408 while (!updateList.empty()) {
410 updateList.pop_back();
417 const clang::Decl* D =
static_cast<const clang::Decl*
>(enumObj->
GetDeclId());
418 if(
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(D)) {
420 for (EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(),
421 EDE = ED->enumerator_end(); EDI != EDE; ++EDI) {
423 std::string constbuf;
424 if (
const NamedDecl* END = llvm::dyn_cast<NamedDecl>(*EDI)) {
425 PrintingPolicy Policy((*EDI)->getASTContext().getPrintingPolicy());
426 llvm::raw_string_ostream stream(constbuf);
428 Policy.AnonymousTagLocations =
false;
429 (END)->getNameForDiagnostic(stream, Policy,
false);
431 const char* constantName = constbuf.c_str();
435 const llvm::APSInt valAPSInt = (*EDI)->getInitVal();
436 if (valAPSInt.isSigned()) {
437 value = valAPSInt.getSExtValue();
439 value = valAPSInt.getZExtValue();
446 DataMemberInfo_t* dmInfo = (DataMemberInfo_t*) tcDmInfo;
450 enumConstant =
new TEnumConstant(dmInfo, constantName, value, enumObj);
457 globals->
Add(enumConstant);
470 const clang::Decl* D =
static_cast<const clang::Decl*
>(VD);
472 if (
const EnumDecl* ED = llvm::dyn_cast<EnumDecl>(D)) {
474 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
475 llvm::raw_string_ostream stream(buf);
477 Policy.AnonymousTagLocations =
false;
478 ED->getNameForDiagnostic(stream, Policy,
false);
484 const char*
name = buf.c_str();
495 const clang::Decl* D =
static_cast<const clang::Decl*
>(DV);
497 if (!D->isCanonicalDecl() && !isa<clang::NamespaceDecl>(D)
498 && !dyn_cast<clang::RecordDecl>(D))
return;
500 if (isa<clang::FunctionDecl>(D->getDeclContext())
501 || isa<clang::TagDecl>(D->getDeclContext()))
505 if (
const clang::CXXRecordDecl* RD = dyn_cast<clang::CXXRecordDecl>(D)) {
506 if (RD->getDescribedClassTemplate())
508 }
else if (
const clang::FunctionDecl* FD = dyn_cast<clang::FunctionDecl>(D)) {
509 if (FD->getDescribedFunctionTemplate())
513 if (
const RecordDecl *TD = dyn_cast<RecordDecl>(D)) {
514 if (TD->isCanonicalDecl() || TD->isThisDeclarationADefinition())
517 else if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
519 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
523 }
else if (
const NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(D)) {
528 if (!isa<TranslationUnitDecl>(ND->getDeclContext()))
532 if (isa<EnumDecl>(ND))
537 if (!(isa<VarDecl>(ND)))
541 if (
gROOT->GetListOfGlobals()->FindObject(ND->getNameAsString().c_str()))
545 gROOT->GetListOfGlobals()->Add(
new TGlobal((DataMemberInfo_t *)
547 cast<ValueDecl>(ND), 0)));
579 const char* canonicalName) {
580 ((
TCling*)
gCling)->LibraryLoaded(dyLibHandle, canonicalName);
585 ((
TCling *)
gCling)->RegisterRdictForLoadPCM(pcmFileNameFullPath, pcmContent);
589 const char* canonicalName) {
590 ((
TCling*)
gCling)->LibraryUnloaded(dyLibHandle, canonicalName);
606 cling::DynamicLibraryManager::ExposeHiddenSharedLibrarySymbols(interpLibHandle);
607 return new TCling(
"C++",
"cling C++ Interpreter", argv);
629 return ((
TCling*)
gCling)->GetClassSharedLibs(className);
635 return ((
TCling*)
gCling)->IsAutoLoadNamespaceCandidate(nsDecl);
640 string file(fileName);
646 string &args,
string &io,
string &fname)
648 string file(fileName);
649 TString f, amode, arguments, aclicio;
651 mode = amode.
Data(); args = arguments.
Data();
652 io = aclicio.
Data(); fname =
f.Data();
657 std::vector<std::string> &sPaths,
658 cling::Interpreter &interpreter,
bool searchSystem);
667 char *__unDName(
char *demangled,
const char *mangled,
int out_len,
668 void * (* pAlloc )(
size_t),
void (* pFree )(
void *),
669 unsigned short int flags);
681 using namespace clang;
682 if (NamespaceDecl* nsd = llvm::dyn_cast<NamespaceDecl>(decl)){
686 if (ClassTemplateDecl* ctd = llvm::dyn_cast<ClassTemplateDecl>(decl)){
698 return ((
TCling*)
gCling)->LazyFunctionCreatorAutoload(mangled_name);
707 const std::vector<std::string> &headers,
708 const std::vector<std::string> &fwdDecls,
709 const std::vector<std::string> &unknown)
715 if (classes.empty()) {
719 const std::string& className = classes[0];
721 TString fileName =
"AutoDict_";
722 std::string::const_iterator sIt;
723 for (sIt = className.begin(); sIt != className.end(); ++sIt) {
724 if (*sIt ==
'<' || *sIt ==
'>' ||
725 *sIt ==
' ' || *sIt ==
'*' ||
726 *sIt ==
',' || *sIt ==
'&' ||
734 if (classes.size() > 1) {
736 std::vector<std::string>::const_iterator it = classes.begin();
737 while ((++it) != classes.end()) {
738 for (
UInt_t cursor = 0; cursor != it->length(); ++cursor) {
739 chk = chk * 3 + it->at(cursor);
752 static const std::set<std::string> sSTLTypes {
753 "vector",
"list",
"forward_list",
"deque",
"map",
"unordered_map",
"multimap",
754 "unordered_multimap",
"set",
"unordered_set",
"multiset",
"unordered_multiset",
755 "queue",
"priority_queue",
"stack",
"iterator"};
756 std::vector<std::string>::const_iterator it;
757 std::string fileContent(
"");
758 for (it = headers.begin(); it != headers.end(); ++it) {
759 fileContent +=
"#include \"" + *it +
"\"\n";
761 for (it = unknown.begin(); it != unknown.end(); ++it) {
767 while (dirbase.
Length() && dirbase !=
"."
768 && dirbase !=
"include" && dirbase !=
"inc"
769 && dirbase !=
"prec_stl") {
773 fileContent +=
TString(
"#include \"") + header +
"\"\n";
776 for (it = fwdDecls.begin(); it != fwdDecls.end(); ++it) {
777 fileContent +=
"class " + *it +
";\n";
779 fileContent +=
"#ifdef __CINT__ \n";
780 fileContent +=
"#pragma link C++ nestedclasses;\n";
781 fileContent +=
"#pragma link C++ nestedtypedefs;\n";
782 for (it = classes.begin(); it != classes.end(); ++it) {
784 size_t posTemplate =
n.find(
'<');
785 std::set<std::string>::const_iterator iSTLType = sSTLTypes.end();
786 if (posTemplate != std::string::npos) {
787 n.erase(posTemplate, std::string::npos);
788 if (
n.compare(0, 5,
"std::") == 0) {
791 iSTLType = sSTLTypes.find(
n);
793 fileContent +=
"#pragma link C++ class ";
794 fileContent += *it +
"+;\n" ;
795 fileContent +=
"#pragma link C++ class ";
796 if (iSTLType != sSTLTypes.end()) {
800 fileContent += *it +
"::*;\n" ;
805 fileContent += *it +
"::*+;\n" ;
808 fileContent +=
"#endif\n";
812 filePointer = fopen(fileName,
"w");
813 if (filePointer == NULL) {
819 fprintf(filePointer,
"%s", fileContent.c_str());
835 const std::vector<std::string> &headers,
836 const std::vector<std::string> &fwdDecls,
837 const std::vector<std::string> &unknown)
843 std::vector<std::string> classes;
844 classes.push_back(className);
872 void exceptionErrorHandler(
void * ,
873 const std::string& reason,
875 throw std::runtime_error(std::string(
">>> Interpreter compilation error:\n") + reason);
889 class clangDiagSuppr {
891 clangDiagSuppr(clang::DiagnosticsEngine& diag): fDiagEngine(diag){
892 fOldDiagValue = fDiagEngine.getIgnoreAllWarnings();
893 fDiagEngine.setIgnoreAllWarnings(
true);
897 fDiagEngine.setIgnoreAllWarnings(fOldDiagValue);
900 clang::DiagnosticsEngine& fDiagEngine;
922 unsigned long offset = 0;
923 if (strncmp(tname.c_str(),
"const ", 6) == 0) {
926 unsigned long end = tname.length();
927 while( end && (tname[end-1]==
'&' || tname[end-1]==
'*' || tname[end-1]==
']') ) {
928 if ( tname[end-1]==
']' ) {
930 while ( end && tname[end-1]!=
'[' ) --end;
934 std::string innerbuf;
936 if (end != tname.length()) {
937 innerbuf = tname.substr(offset,end-offset);
938 inner = innerbuf.c_str();
940 inner = tname.c_str()+offset;
944 if (
gROOT->GetListOfClasses()->FindObject(inner)
954 const char *newname =
type->GetFullTypeName();
956 newname =
"Long64_t";
958 newname =
"ULong64_t";
960 if (strcmp(inner,newname) == 0) {
963 if (offset) result =
"const ";
965 if ( end != tname.length() ) {
966 result += tname.substr(end,tname.length()-end);
968 if (result == tname) result.clear();
974 if (lastPos != inner)
978 const auto enName = lastPos;
979 const auto scopeNameSize = ((
Long64_t)lastPos - (
Long64_t)inner) /
sizeof(
decltype(*lastPos)) - 2;
980 char *scopeName =
new char[scopeNameSize + 1];
981 strncpy(scopeName, inner, scopeNameSize);
982 scopeName[scopeNameSize] =
'\0';
984 if (
auto scope =
static_cast<TClass *
>(
gROOT->GetListOfClasses()->FindObject(scopeName))) {
985 auto enumTable =
dynamic_cast<const THashList *
>(scope->GetListOfEnums(
false));
986 if (enumTable && enumTable->THashList::FindObject(enName))
return true;
990 auto listOfEnums = scope->GetListOfEnums();
992 auto enumTable =
dynamic_cast<const THashList *
>(listOfEnums);
993 if (enumTable && enumTable->THashList::FindObject(enName))
return true;
1000 auto enumTable =
dynamic_cast<const THashList *
>(
gROOT->GetListOfEnums());
1001 if (enumTable && enumTable->THashList::FindObject(inner))
return true;
1024 return fContent.c_str();
1032 bool notPresent = fLinesHashSet.emplace(fHashFunc(str)).second;
1046static bool LoadModule(
const std::string &ModuleName, cling::Interpreter &interp)
1056 assert(!currentDir.empty());
1058 return interp.loadModule(ModuleName,
true);
1064static void LoadModules(
const std::vector<std::string> &modules, cling::Interpreter &interp)
1066 for (
const auto &modName : modules)
1072 const static bool foundSymbol = dlsym(RTLD_DEFAULT,
"usedToIdentifyRootClingByDlSym");
1078 const HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
1080 std::string ModuleFileName;
1081 if (!HSOpts.PrebuiltModulePaths.empty())
1083 ModuleFileName = PP.getHeaderSearchInfo().getModuleFileName(M->Name,
"",
true);
1084 if (ModuleFileName.empty())
return "";
1086 std::string ModuleName = llvm::sys::path::filename(ModuleFileName);
1088 return std::string(llvm::sys::path::stem(ModuleName));
1093 if (!clingInterp.getCI()->getLangOpts().Modules)
1105 LoadModule(
"_Builtin_intrinsics", clingInterp);
1109 std::vector<std::string> CoreModules = {
"ROOT_Foundation_C",
1112 "ROOT_Foundation_Stage1_NoRTTI",
1117 static constexpr std::array<const char *, 3> ExcludeModules = {
1118 {
"Rtools",
"RSQLite",
"RInterface"}};
1125 clang::CompilerInstance &CI = *clingInterp.getCI();
1126 clang::ModuleMap &moduleMap = CI.getPreprocessor().getHeaderSearchInfo().getModuleMap();
1127 clang::Preprocessor &PP = CI.getPreprocessor();
1128 std::vector<std::string> ModulesPreloaded;
1129 for (
auto I = moduleMap.module_begin(),
E = moduleMap.module_end();
I !=
E; ++
I) {
1130 clang::Module *M =
I->second;
1134 if (!ModuleName.empty() &&
1135 std::find(CoreModules.begin(), CoreModules.end(), ModuleName) == CoreModules.end() &&
1136 std::find(ExcludeModules.begin(), ExcludeModules.end(), ModuleName) ==
1137 ExcludeModules.end()) {
1138 if (M->IsSystem && !M->IsMissingRequirement)
1140 else if (!M->IsSystem && !M->IsMissingRequirement)
1141 ModulesPreloaded.push_back(ModuleName);
1148 assert(clingInterp.getMacro(
"gROOT") &&
"Couldn't load gROOT macro?");
1156 clingInterp.declare(
"#ifdef I\n #undef I\n #endif\n");
1160 clingInterp.declare(
"#ifdef complex\n #undef complex\n #endif\n");
1164 clingInterp.declare(
"#ifdef PI\n #undef PI\n #endif\n");
1165 clingInterp.declare(
"#ifdef ERROR\n #undef ERROR\n #endif\n");
1170 std::string PreIncludes;
1171 bool hasCxxModules = clingInterp.getCI()->getLangOpts().Modules;
1177 PreIncludes +=
"#include \"RtypesCore.h\"\n";
1180 PreIncludes +=
"#include \"Rtypes.h\"\n";
1182 PreIncludes += gClassDefInterpMacro +
"\n"
1183 + gInterpreterClassDef +
"\n"
1185 "#define ClassImp(X);\n";
1188 PreIncludes +=
"#include <string>\n";
1193 PreIncludes +=
"#include <cassert>\n";
1195 PreIncludes +=
"using namespace std;\n";
1196 clingInterp.declare(PreIncludes);
1214#ifdef R__USE_CXXMODULES
1218 llvm::install_fatal_error_handler(&exceptionErrorHandler);
1222 std::vector<std::string> clingArgsStorage;
1223 clingArgsStorage.push_back(
"cling4root");
1224 for (
const char*
const* arg = argv; *arg; ++arg)
1225 clingArgsStorage.push_back(*arg);
1228 if (!fromRootCling) {
1229 ROOT::TMetaUtils::SetPathsForRelocatability(clingArgsStorage);
1233 clingArgsStorage.push_back(
"-I" + interpInclude);
1236 clingArgsStorage.push_back(
"-I" + interpInclude +
"/cling");
1247 std::string pchFilename = interpInclude +
"/allDict.cxx.pch";
1252 clingArgsStorage.push_back(
"-include-pch");
1253 clingArgsStorage.push_back(pchFilename);
1256 clingArgsStorage.push_back(
"-Wno-undefined-inline");
1257 clingArgsStorage.push_back(
"-fsigned-char");
1261 llvm::Optional<std::string> EnvOpt = llvm::sys::Process::GetEnv(
"EXTRA_CLING_ARGS");
1262 if (EnvOpt.hasValue()) {
1263 StringRef Env(*EnvOpt);
1264 while (!Env.empty()) {
1266 std::tie(Arg, Env) = Env.split(
' ');
1267 clingArgsStorage.push_back(Arg.str());
1271 auto GetEnvVarPath = [](
const std::string &EnvVar,
1272 std::vector<std::string> &Paths) {
1273 llvm::Optional<std::string> EnvOpt = llvm::sys::Process::GetEnv(EnvVar);
1274 if (EnvOpt.hasValue()) {
1275 StringRef Env(*EnvOpt);
1276 while (!Env.empty()) {
1279 if (std::find(Paths.begin(), Paths.end(), Arg.str()) == Paths.end())
1280 Paths.push_back(Arg.str());
1286 std::vector<std::string> Paths;
1291 GetEnvVarPath(
"CLING_PREBUILT_MODULE_PATH", Paths);
1293 std::string EnvVarPath;
1294 for (
const std::string&
P : Paths)
1297 gSystem->
Setenv(
"CLING_PREBUILT_MODULE_PATH", EnvVarPath.c_str());
1301 EnvOpt = llvm::sys::Process::GetEnv(
"ROOT_CLING_TIMING");
1302 if (EnvOpt.hasValue())
1303 clingArgsStorage.push_back(
"-ftime-report");
1310 std::vector<std::string> Paths;
1312 GetEnvVarPath(
"CLING_MODULEMAP_PATH", Paths);
1317 for (
const std::string&
P : Paths) {
1319 +
"module.modulemap";
1320 if (!llvm::sys::fs::exists(ModuleMapLoc)) {
1322 ::Info(
"TCling::TCling",
"Modulemap %s does not exist \n",
1323 ModuleMapLoc.c_str());
1328 clingArgsStorage.push_back(
"-fmodule-map-file=" + ModuleMapLoc);
1332 std::vector<const char*> interpArgs;
1333 for (std::vector<std::string>::const_iterator iArg = clingArgsStorage.begin(),
1334 eArg = clingArgsStorage.end(); iArg != eArg; ++iArg)
1335 interpArgs.push_back(iArg->c_str());
1342 if (!fromRootCling) {
1344 interpArgs.push_back(
"-fmodules");
1345 interpArgs.push_back(
"-fno-implicit-module-maps");
1349 interpArgs.push_back(
"-Rmodule-build");
1355 interpArgs.push_back(
"-fno-autolink");
1360 interpArgs.push_back(
"-ffast-math");
1366 extraArgs && *extraArgs; ++extraArgs) {
1367 if (!strcmp(*extraArgs,
"-resource-dir")) {
1369 llvmResourceDir = *(++extraArgs);
1371 interpArgs.push_back(*extraArgs);
1376 interpArgs.push_back(arg.c_str());
1380 cling::Interpreter::ModuleFileExtensions extensions;
1381 EnvOpt = llvm::sys::Process::GetEnv(
"ROOTDEBUG_RDICT");
1382 if (!EnvOpt.hasValue())
1383 extensions.push_back(std::make_shared<TClingRdictModuleFileExtension>());
1385 fInterpreter = llvm::make_unique<cling::Interpreter>(interpArgs.size(),
1387 llvmResourceDir, extensions);
1389 if (!fromRootCling) {
1394 fInterpreter->getCI()->getPreprocessorOpts().DisablePCHValidation =
true;
1398 fInterpreter->getCI()->getLangOpts().SpellChecking =
false;
1403 static llvm::raw_fd_ostream fMPOuts (STDOUT_FILENO,
false);
1423 if (!fromRootCling) {
1433 std::unique_ptr<TClingCallbacks>
1439 if (!fromRootCling) {
1487#if defined(__CYGWIN__) && defined(__GNUC__)
1489#elif defined(G__WIN32)
1490 MEMORY_BASIC_INFORMATION mbi;
1491 if (!VirtualQuery (func, &mbi,
sizeof (mbi)))
1496 HMODULE hMod = (HMODULE) mbi.AllocationBase;
1497 char moduleName[MAX_PATH];
1499 if (!GetModuleFileNameA (hMod, moduleName,
sizeof (moduleName)))
1503 return ROOT::TMetaUtils::GetRealPath(moduleName);
1506 if (dladdr((
void*)func, &info) == 0) {
1510 if (strchr(info.dli_fname,
'/'))
1511 return ROOT::TMetaUtils::GetRealPath(info.dli_fname);
1515# if defined(R__MACOSX)
1516 char buf[PATH_MAX] = { 0 };
1517 uint32_t bufsize =
sizeof(buf);
1518 if (_NSGetExecutablePath(buf, &bufsize) >= 0)
1519 return ROOT::TMetaUtils::GetRealPath(buf);
1520 return ROOT::TMetaUtils::GetRealPath(info.dli_fname);
1521# elif defined(R__UNIX)
1522 char buf[PATH_MAX] = { 0 };
1524 if (readlink(
"/proc/self/exe", buf,
sizeof(buf)) > 0)
1525 return ROOT::TMetaUtils::GetRealPath(buf);
1526 std::string pipeCmd = std::string(
"which \"") + info.dli_fname +
"\"";
1527 FILE* pipe = popen(pipeCmd.c_str(),
"r");
1529 return ROOT::TMetaUtils::GetRealPath(info.dli_fname);
1531 while (fgets(buf,
sizeof(buf), pipe)) {
1535 return ROOT::TMetaUtils::GetRealPath(result);
1537# error "Unsupported platform."
1551 auto setFactory = []() {
1555 static bool doneFactory = setFactory();
1567 if (llvm::sys::fs::exists(pcmFileNameFullPath)) {
1568 ::Error(
"TCling::RegisterRdictForLoadPCM",
"Rdict '%s' is both in Module extension and in File system.", pcmFileNameFullPath.c_str());
1585 if (listOfKeys && ((listOfKeys->GetSize() == 0) ||
1586 ((listOfKeys->GetSize() == 1) &&
1587 !strcmp(((
TKey *)listOfKeys->At(0))->GetName(),
"EMPTY")
1594 ::Info(
"TCling::LoadPCMImpl",
"reading protoclasses for %s \n", pcmFile.
GetName());
1596 pcmFile.
GetObject(
"__ProtoClasses", protoClasses);
1599 for (
auto obj : *protoClasses) {
1609 for (
auto proto : *protoClasses) {
1617 ::Error(
"TCling::LoadPCM",
"Inconsistent TClassTable for %s",
proto->GetName());
1628 protoClasses->Clear();
1629 delete protoClasses;
1633 pcmFile.
GetObject(
"__Typedefs", dataTypes);
1635 for (
auto typedf : *dataTypes)
1636 gROOT->GetListOfTypes()->Add(typedf);
1645 auto listOfGlobals =
gROOT->GetListOfGlobals();
1646 auto listOfEnums =
dynamic_cast<THashList *
>(
gROOT->GetListOfEnums());
1648 for (
auto selEnum : *enums) {
1649 const char *enumScope = selEnum->
GetTitle();
1650 const char *enumName = selEnum->GetName();
1651 if (strcmp(enumScope,
"") == 0) {
1654 if (!listOfEnums->THashList::FindObject(enumName)) {
1655 ((
TEnum *)selEnum)->SetClass(
nullptr);
1656 listOfEnums->Add(selEnum);
1659 if (!listOfGlobals->FindObject(enumConstant)) {
1660 listOfGlobals->Add(enumConstant);
1667 if (!nsTClassEntry) {
1670 auto listOfEnums = nsTClassEntry->
fEnums.load();
1681 if (listOfEnums && !listOfEnums->THashList::FindObject(enumName)) {
1682 ((
TEnum *)selEnum)->SetClass(nsTClassEntry);
1683 listOfEnums->Add(selEnum);
1699 assert(!pcmFileNameFullPath.empty());
1700 assert(llvm::sys::path::is_absolute(pcmFileNameFullPath));
1703 TString pcmFileName = pcmFileNameFullPath;
1711 llvm::SaveAndRestore<Int_t> SaveGDebug(
gDebug);
1714 ::Info(
"TCling::LoadPCM",
"Loading ROOT PCM %s", pcmFileName.
Data());
1719 if (llvm::sys::fs::is_symlink_file(pcmFileNameFullPath))
1720 pcmFileNameFullPath = ROOT::TMetaUtils::GetRealPath(pcmFileNameFullPath);
1724 llvm::StringRef pcmContent = pendingRdict->second;
1726 std::string RDictFileOpts = pcmFileNameFullPath +
"?filetype=pcm";
1727 TMemFile pcmMemFile(RDictFileOpts.c_str(), range);
1736 if (!llvm::sys::fs::exists(pcmFileNameFullPath)) {
1737 ::Error(
"TCling::LoadPCM",
"ROOT PCM %s file does not exist",
1738 pcmFileNameFullPath.data());
1741 ::Info(
"TCling::LoadPCM",
"In-memory ROOT PCM candidate %s\n",
1742 rdict.first.c_str());
1746 if (!
gROOT->IsRootFile(pcmFileName)) {
1747 Fatal(
"LoadPCM",
"The file %s is not a ROOT as was expected\n", pcmFileName.
Data());
1750 TFile pcmFile(pcmFileName +
"?filetype=pcm",
"READ");
1757 using namespace clang;
1759 class ExtLexicalStorageAdder:
public RecursiveASTVisitor<ExtLexicalStorageAdder>{
1764 bool VisitRecordDecl(clang::RecordDecl* rcd){
1766 Info(
"ExtLexicalStorageAdder",
1767 "Adding external lexical storage to class %s",
1768 rcd->getNameAsString().c_str());
1769 auto reDeclPtr = rcd->getMostRecentDecl();
1771 reDeclPtr->setHasExternalLexicalStorage();
1772 }
while ((reDeclPtr = reDeclPtr->getPreviousDecl()));
1785 const std::string &ModuleMapName )
const
1787 assert(llvm::sys::path::is_absolute(FullPath));
1788 Preprocessor &PP =
fInterpreter->getCI()->getPreprocessor();
1789 FileManager &FM = PP.getFileManager();
1792 const DirectoryEntry *DE = FM.getDirectory(FullPath);
1794 HeaderSearch &HS = PP.getHeaderSearchInfo();
1795 HeaderSearchOptions &HSOpts = HS.getHeaderSearchOpts();
1796 const auto &ModPaths = HSOpts.PrebuiltModulePaths;
1797 bool pathExists = std::find(ModPaths.begin(), ModPaths.end(), FullPath) != ModPaths.end();
1799 HSOpts.AddPrebuiltModulePath(FullPath);
1804 llvm::SmallString<256> ModuleMapFileName(DE->getName());
1805 llvm::sys::path::append(ModuleMapFileName, ModuleMapName);
1806 const FileEntry *FE = FM.getFile(ModuleMapFileName,
false,
1811 if (FE && !this->
IsLoaded(FE->getName().data())) {
1812 if (!HS.loadModuleMapFile(FE,
false))
1814 Error(
"RegisterPrebuiltModulePath",
"Could not load modulemap in %s", ModuleMapFileName.c_str());
1830 "libforward_listDict",
1838 "libunordered_setDict",
1839 "libunordered_multisetDict",
1840 "libunordered_mapDict",
1841 "libunordered_multimapDict",
1849 char dyLibError[1000];
1850 FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
1851 dyLibError,
sizeof(dyLibError), NULL);
1853 const char *dyLibError = dlerror();
1855 ::Error(
"TCling::RegisterModule",
"Cannot open shared library %s for dictionary %s:\n %s", dyLibName, modulename,
1856 (dyLibError) ? dyLibError :
"");
1893 const char** headers,
1894 const char** includePaths,
1895 const char* payloadCode,
1896 const char* fwdDeclsCode,
1897 void (*triggerFunc)(),
1899 const char** classesHeaders,
1900 Bool_t lateRegistration ,
1907 if (fromRootCling)
return;
1916 bool isACLiC = strstr(modulename,
"_ACLiC_dict") !=
nullptr;
1917 if (hasHeaderParsingOnDemand && isACLiC) {
1919 Info(
"TCling::RegisterModule",
1920 "Header parsing on demand is active but this is an Aclic library. Disabling it for this library.");
1921 hasHeaderParsingOnDemand =
false;
1935 for (
const char** inclPath = includePaths; *inclPath; ++inclPath) {
1938 cling::Transaction*
T = 0;
1940 for (
auto& fwdDeclArgToSkipPair : fwdDeclsArgToSkip){
1941 const std::string& fwdDecl = fwdDeclArgToSkipPair.first;
1942 const int nArgsToSkip = fwdDeclArgToSkipPair.second;
1944 assert(cling::Interpreter::kSuccess == compRes &&
1945 "A fwd declaration could not be compiled");
1946 if (compRes!=cling::Interpreter::kSuccess){
1947 Warning(
"TCling::RegisterModule",
1948 "Problems in declaring string '%s' were encountered.",
1955 fNormalizedCtxt->AddTemplAndNargsToKeep(TD->getCanonicalDecl(), nArgsToSkip);
1963 TString code = gNonInterpreterClassDef;
1965 code += payloadCode;
1968 assert(!llvm::sys::fs::is_symlink_file(dyLibName));
1970 if (dyLibName.empty()) {
1971 ::Error(
"TCling::RegisterModule",
"Dictionary trigger function for %s not found", modulename);
1976 bool isSharedLib = cling::DynamicLibraryManager::isSharedLibrary(dyLibName);
1978 bool wasDlopened =
false;
1983 if (!lateRegistration) {
1990 void* dyLibHandle = dlopen(dyLibName.c_str(), RTLD_LAZY | RTLD_GLOBAL);
2000 if (hasHeaderParsingOnDemand && fwdDeclsCode){
2003 std::string fwdDeclsCodeLessEnums;
2007 std::string fwdDeclsLine;
2008 std::istringstream fwdDeclsCodeStr(fwdDeclsCode);
2009 std::vector<std::string> scopes;
2010 while (std::getline(fwdDeclsCodeStr, fwdDeclsLine)) {
2011 const auto enumPos = fwdDeclsLine.find(
"enum __attribute__((annotate(\"");
2013 if (enumPos != std::string::npos) {
2020 auto nsPos = fwdDeclsLine.find(
"namespace");
2021 R__ASSERT(nsPos < enumPos &&
"Inconsistent enum and enclosing scope parsing!");
2022 while (nsPos < enumPos && nsPos != std::string::npos) {
2024 const auto nsNameStart = nsPos + 10;
2025 const auto nsNameEnd = fwdDeclsLine.find(
'{', nsNameStart);
2026 const auto nsName = fwdDeclsLine.substr(nsNameStart, nsNameEnd - nsNameStart);
2027 scopes.push_back(nsName);
2028 nsPos = fwdDeclsLine.find(
"namespace", nsNameEnd);
2031 clang::DeclContext* DC = 0;
2032 for (
auto &&aScope: scopes) {
2033 DC = cling::utils::Lookup::Namespace(&
fInterpreter->getSema(), aScope.c_str(), DC);
2039 if (scopes.empty() || DC) {
2041 size_t posEnumName = fwdDeclsLine.find(
"\"))) ", 32);
2042 R__ASSERT(posEnumName != std::string::npos &&
"Inconsistent enum fwd decl!");
2044 while (isspace(fwdDeclsLine[posEnumName]))
2046 size_t posEnumNameEnd = fwdDeclsLine.find(
" : ", posEnumName);
2047 R__ASSERT(posEnumNameEnd != std::string::npos &&
"Inconsistent enum fwd decl (end)!");
2048 while (isspace(fwdDeclsLine[posEnumNameEnd]))
2052 std::string enumName = fwdDeclsLine.substr(posEnumName,
2053 posEnumNameEnd - posEnumName + 1);
2055 if (clang::NamedDecl* enumDecl
2056 = cling::utils::Lookup::Named(&
fInterpreter->getSema(),
2057 enumName.c_str(), DC)) {
2060 R__ASSERT(llvm::dyn_cast<clang::EnumDecl>(enumDecl) &&
"not an enum decl!");
2067 fwdDeclsCodeLessEnums += fwdDeclsLine +
"\n";
2071 if (fwdDeclsCodeLessEnums.size() != 0){
2072 auto compRes =
fInterpreter->declare(fwdDeclsCodeLessEnums, &
T);
2073 assert(cling::Interpreter::kSuccess == compRes &&
2074 "The forward declarations could not be compiled");
2075 if (compRes!=cling::Interpreter::kSuccess){
2076 Warning(
"TCling::RegisterModule",
2077 "Problems in compiling forward declarations for module %s: '%s'",
2078 modulename, fwdDeclsCodeLessEnums.c_str()) ;
2086 ExtLexicalStorageAdder elsa;
2087 for (
auto dciIt =
T->decls_begin();dciIt!=
T->decls_end();dciIt++){
2088 cling::Transaction::DelayCallInfo& dci = *dciIt;
2089 for(
auto dit = dci.m_DGR.begin(); dit != dci.m_DGR.end(); ++dit) {
2090 clang::Decl* declPtr = *dit;
2091 elsa.TraverseDecl(declPtr);
2105 for (
const char** classesHeader = classesHeaders; *classesHeader; ++classesHeader) {
2106 temp=*classesHeader;
2108 size_t theTemplateHash = 0;
2109 bool addTemplate =
false;
2110 size_t posTemplate = temp.find(
'<');
2111 if (posTemplate != std::string::npos) {
2113 std::string templateName = temp.substr(0, posTemplate);
2119 for (
const char** classesHeader_inner = classesHeader; 0!=strcmp(*classesHeader_inner,
"@"); ++classesHeader_inner,++classesHeader){
2121 if (payloadCode == *classesHeader_inner ){
2123 if (addTemplate)
fPayloads.insert(theTemplateHash);
2126 Info(
"TCling::RegisterModule",
2127 "Adding a header for %s", temp.c_str());
2133 addTemplate =
false;
2141 bool ModuleWasSuccessfullyLoaded =
false;
2143 std::string ModuleName = modulename;
2144 if (llvm::StringRef(modulename).startswith(
"lib"))
2145 ModuleName = llvm::StringRef(modulename).substr(3).str();
2150 clang::Preprocessor &PP = TheSema.getPreprocessor();
2151 std::string ModuleMapName;
2153 ModuleMapName = ModuleName +
".modulemap";
2155 ModuleMapName =
"module.modulemap";
2162 if (!ModuleWasSuccessfullyLoaded) {
2164 clang::HeaderSearch &headerSearch = PP.getHeaderSearchInfo();
2165 clang::ModuleMap &moduleMap = headerSearch.getModuleMap();
2166 if (moduleMap.findModule(ModuleName))
2167 Info(
"TCling::RegisterModule",
"Module %s in modulemap failed to load.", ModuleName.c_str());
2172 llvm::SmallString<256> pcmFileNameFullPath(dyLibName);
2175 llvm::sys::fs::make_absolute(pcmFileNameFullPath);
2176 llvm::sys::path::remove_filename(pcmFileNameFullPath);
2177 llvm::sys::path::append(pcmFileNameFullPath,
2178 ROOT::TMetaUtils::GetModuleFileName(modulename));
2179 LoadPCM(pcmFileNameFullPath.str().str());
2186 clangDiagSuppr diagSuppr(TheSema.getDiagnostics());
2188#if defined(R__MUST_REVISIT)
2189#if R__MUST_REVISIT(6,2)
2190 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
2194 if (!ModuleWasSuccessfullyLoaded && !hasHeaderParsingOnDemand){
2197 const cling::Transaction* watermark =
fInterpreter->getLastTransaction();
2198 cling::Interpreter::CompilationResult compRes =
fInterpreter->parseForModule(code.
Data());
2204 assert(cling::Interpreter::kSuccess == compRes &&
2205 "Payload code of a dictionary could not be parsed correctly.");
2206 if (compRes!=cling::Interpreter::kSuccess) {
2207 Warning(
"TCling::RegisterModule",
2208 "Problems declaring payload for module %s.", modulename) ;
2221 if (!ModuleWasSuccessfullyLoaded && !hasHeaderParsingOnDemand) {
2224 "#undef __ROOTCLING__\n"
2225 + gInterpreterClassDef +
2230 assert(isSharedLib);
2233 dlclose(dyLibHandle);
2253 typedef std::vector<std::pair<TClass*,DictFuncPtr_t> >::iterator iterator;
2259 if ( i->first == oldcl ) {
2282 const char* input_line,
2283 cling::Interpreter::CompilationResult& compRes,
2287 return metaProcessor->process(input_line, compRes, result);
2289 catch (cling::InterpreterException&
ex)
2291 Error(
"HandleInterpreterException",
"%s.\n%s",
ex.what(),
"Execution of your code was aborted.");
2293 compRes = cling::Interpreter::kFailure;
2302 if (
auto ie =
dynamic_cast<const cling::InterpreterException*
>(&
e)) {
2328 gROOT->SetLineIsProcessing();
2332 gROOT->SetLineHasBeenProcessed();
2345 gROOT->SetLineIsProcessing();
2347 struct InterpreterFlagsRAII {
2349 bool fWasDynamicLookupEnabled;
2351 InterpreterFlagsRAII(cling::Interpreter* interp):
2353 fWasDynamicLookupEnabled(interp->isDynamicLookupEnabled())
2357 ~InterpreterFlagsRAII() {
2358 fInterpreter->enableDynamicLookup(fWasDynamicLookupEnabled);
2359 gROOT->SetLineHasBeenProcessed();
2368 cling::Interpreter::CompilationResult compRes = cling::Interpreter::kSuccess;
2369 if (!strncmp(sLine.
Data(),
".L", 2) || !strncmp(sLine.
Data(),
".x", 2) ||
2370 !strncmp(sLine.
Data(),
".X", 2)) {
2378 aclicMode, arguments, io);
2379 if (aclicMode.
Length()) {
2381 R__ASSERT(aclicMode[0]==
'+' &&
"ACLiC mode must start with a +");
2383 if (aclicMode[1]==
'+') {
2389 compRes = cling::Interpreter::kFailure;
2391 if (strncmp(sLine.
Data(),
".L", 2) != 0) {
2394 if (arguments.
Length()==0) {
2403 mod_line =
function + arguments + io;
2409 size_t unnamedMacroOpenCurly;
2412 std::string codeline;
2413 std::ifstream in(fname);
2415 std::getline(in, codeline);
2416 code += codeline +
"\n";
2418 unnamedMacroOpenCurly
2419 = cling::utils::isUnnamedMacro(code,
fInterpreter->getCI()->getLangOpts());
2423 if (unnamedMacroOpenCurly != std::string::npos) {
2425 unnamedMacroOpenCurly);
2435 if (0!=strncmp(sLine.
Data(),
".autodict ",10) && sLine !=
".autodict") {
2440 bool isInclusionDirective = sLine.
Contains(
"\n#include") || sLine.
BeginsWith(
"#include");
2441 if (isInclusionDirective) {
2449 if (result.isValid())
2458 case cling::Interpreter::kSuccess: *error =
kNoError;
break;
2459 case cling::Interpreter::kFailure: *error =
kRecoverable;
break;
2460 case cling::Interpreter::kMoreInputExpected: *error =
kProcessing;
break;
2463 if (compRes == cling::Interpreter::kSuccess
2465 && !result.isVoid())
2467 return result.simplisticCastAs<
long>();
2489 if (path[0] ==
'-' && path[1] ==
'I')
2513 static const TClassRef clRefString(
"std::string");
2514 if (clRefString == cl) {
2524 const char* cobj = (
const char*) obj;
2531 auto inspInspect = [&] (ptrdiff_t offset){
2537 switch(complexType) {
2544 inspInspect(
sizeof(
float));
2549 inspInspect(
sizeof(
double));
2554 inspInspect(
sizeof(
int));
2559 inspInspect(
sizeof(
long));
2564 static clang::PrintingPolicy
2566 if (printPol.Indentation) {
2568 printPol.Indentation = 0;
2569 printPol.SuppressInitializers =
true;
2572 const char* clname = cl->
GetName();
2575 const clang::ASTContext& astContext =
fInterpreter->getCI()->getASTContext();
2576 const clang::Decl *scopeDecl = 0;
2581 scopeDecl = clingCI->
GetDecl();
2582 recordType = clingCI->
GetType();
2584 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
2586 scopeDecl = lh.findScope(clname, cling::LookupHelper::NoDiagnostics,
2590 Error(
"InspectMembers",
"Cannot find Decl for class %s", clname);
2593 const clang::CXXRecordDecl* recordDecl
2594 = llvm::dyn_cast<const clang::CXXRecordDecl>(scopeDecl);
2596 Error(
"InspectMembers",
"Cannot find Decl for class %s is not a CXXRecordDecl.", clname);
2605 astContext.getASTRecordLayout(recordDecl);
2607 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2608 eField = recordDecl->field_end(); iField != eField; ++iField) {}
2611 const clang::ASTRecordLayout& recLayout
2612 = astContext.getASTRecordLayout(recordDecl);
2619 if (cl->
Size() != recLayout.getSize().getQuantity()) {
2620 Error(
"InspectMembers",
"TClass and cling disagree on the size of the class %s, respectively %d %lld\n",
2624 unsigned iNField = 0;
2627 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2628 eField = recordDecl->field_end(); iField != eField;
2629 ++iField, ++iNField) {
2632 clang::QualType memberQT = iField->getType();
2635 memberQT = ROOT::TMetaUtils::ReSubstTemplateArg(memberQT, recordType);
2637 memberQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, memberQT,
fNormalizedCtxt->GetConfig(),
false );
2638 if (memberQT.isNull()) {
2639 std::string memberName;
2640 llvm::raw_string_ostream stream(memberName);
2642 printPol.AnonymousTagLocations =
false;
2643 iField->getNameForDiagnostic(stream, printPol,
true );
2645 Error(
"InspectMembers",
2646 "Cannot retrieve QualType for member %s while inspecting class %s",
2647 memberName.c_str(), clname);
2650 const clang::Type* memType = memberQT.getTypePtr();
2652 std::string memberName;
2653 llvm::raw_string_ostream stream(memberName);
2655 printPol.AnonymousTagLocations =
false;
2656 iField->getNameForDiagnostic(stream, printPol,
true );
2658 Error(
"InspectMembers",
2659 "Cannot retrieve Type for member %s while inspecting class %s",
2660 memberName.c_str(), clname);
2665 Bool_t ispointer =
false;
2666 if (memNonPtrType->isPointerType()) {
2668 clang::QualType ptrQT
2669 = memNonPtrType->getAs<clang::PointerType>()->getPointeeType();
2672 ptrQT = ROOT::TMetaUtils::ReSubstTemplateArg(ptrQT, recordType);
2674 ptrQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, ptrQT,
fNormalizedCtxt->GetConfig(),
false );
2675 if (ptrQT.isNull()) {
2676 std::string memberName;
2677 llvm::raw_string_ostream stream(memberName);
2679 printPol.AnonymousTagLocations =
false;
2680 iField->getNameForDiagnostic(stream, printPol,
true );
2682 Error(
"InspectMembers",
2683 "Cannot retrieve pointee Type for member %s while inspecting class %s",
2684 memberName.c_str(), clname);
2687 memNonPtrType = ptrQT.getTypePtr();
2691 llvm::SmallString<8> arraySize;
2692 const clang::ArrayType* arrType = memNonPtrType->getAsArrayTypeUnsafe();
2693 unsigned arrLevel = 0;
2694 bool haveErrorDueToArray =
false;
2698 const clang::ConstantArrayType* constArrType =
2699 clang::dyn_cast<clang::ConstantArrayType>(arrType);
2701 constArrType->getSize().toStringUnsigned(arraySize);
2704 clang::QualType subArrQT = arrType->getElementType();
2705 if (subArrQT.isNull()) {
2706 std::string memberName;
2707 llvm::raw_string_ostream stream(memberName);
2709 printPol.AnonymousTagLocations =
false;
2710 iField->getNameForDiagnostic(stream, printPol,
true );
2712 Error(
"InspectMembers",
2713 "Cannot retrieve QualType for array level %d (i.e. element type of %s) for member %s while inspecting class %s",
2714 arrLevel, subArrQT.getAsString(printPol).c_str(),
2715 memberName.c_str(), clname);
2716 haveErrorDueToArray =
true;
2719 arrType = subArrQT.getTypePtr()->getAsArrayTypeUnsafe();
2721 if (haveErrorDueToArray) {
2726 std::string fieldName;
2727 if (memType->isPointerType()) {
2732 std::string ioname(iField->getName());
2733 ROOT::TMetaUtils::ExtractAttrPropertyFromName(**iField,
"ioname",ioname);
2734 fieldName += ioname;
2735 fieldName += arraySize;
2740 clang::CharUnits offset(astContext.toCharUnitsFromBits(recLayout.getFieldOffset(iNField)));
2741 ptrdiff_t fieldOffset = offset.getQuantity();
2751 auto iFiledQtype = iField->getType();
2752 if (
auto tagDecl = iFiledQtype->getAsTagDecl()){
2753 auto declAccess = tagDecl->getAccess();
2754 if (declAccess == AS_private || declAccess == AS_protected) {
2760 insp.
Inspect(
const_cast<TClass*
>(cl), insp.
GetParent(), fieldName.c_str(), cobj + fieldOffset, isTransient);
2763 const clang::CXXRecordDecl* fieldRecDecl = memNonPtrType->getAsCXXRecordDecl();
2764 if (fieldRecDecl && !fieldRecDecl->isAnonymousStructOrUnion()) {
2767 std::string sFieldRecName;
2768 if (!ROOT::TMetaUtils::ExtractAttrPropertyFromName(*fieldRecDecl,
"iotype",sFieldRecName)){
2770 clang::QualType(memNonPtrType,0),
2780 insp.
InspectMember(sFieldRecName.c_str(), cobj + fieldOffset,
2781 (fieldName +
'.').c_str(), transient);
2789 unsigned iNBase = 0;
2790 for (clang::CXXRecordDecl::base_class_const_iterator iBase
2791 = recordDecl->bases_begin(), eBase = recordDecl->bases_end();
2792 iBase != eBase; ++iBase, ++iNBase) {
2793 clang::QualType baseQT = iBase->getType();
2794 if (baseQT.isNull()) {
2795 Error(
"InspectMembers",
2796 "Cannot find QualType for base number %d while inspecting class %s",
2800 const clang::CXXRecordDecl* baseDecl
2801 = baseQT->getAsCXXRecordDecl();
2803 Error(
"InspectMembers",
2804 "Cannot find CXXRecordDecl for base number %d while inspecting class %s",
2809 std::string sBaseName;
2811 std::vector<TClass*> foundClasses;
2813 if (foundClasses.size()==1){
2814 baseCl=foundClasses[0];
2827 std::string qualNameForDiag;
2828 ROOT::TMetaUtils::GetQualifiedName(qualNameForDiag, *baseDecl);
2829 Error(
"InspectMembers",
2830 "Cannot find TClass for base class %s", qualNameForDiag.c_str() );
2835 if (iBase->isVirtual()) {
2838 Error(
"InspectMembers",
2839 "Base %s of class %s is virtual but no object provided",
2840 sBaseName.c_str(), clname);
2848 baseOffset = ci->
GetBaseOffset(baseCi,
const_cast<void*
>(obj),
2850 if (baseOffset == -1) {
2851 Error(
"InspectMembers",
2852 "Error calculating offset of virtual base %s of class %s",
2853 sBaseName.c_str(), clname);
2856 Error(
"InspectMembers",
2857 "Cannot calculate offset of virtual base %s of class %s",
2858 sBaseName.c_str(), clname);
2863 baseOffset = recLayout.getBaseClassOffset(baseDecl).getQuantity();
2910 bool oldDynLookup =
fInterpreter->isDynamicLookupEnabled();
2937 assert(
GetRootMapFiles() == 0 &&
"Must be called before LoadLibraryMap!");
2961 return fInterpreter->getDynamicLibraryManager()->isLibraryLoaded(tLibName.
Data());
2976 llvm::StringRef ModuleName(libname);
2977 ModuleName = llvm::sys::path::stem(ModuleName);
2978 ModuleName.consume_front(
"lib");
2980 clang::ModuleMap &moduleMap =
fInterpreter->getCI()->getPreprocessor().getHeaderSearchInfo().getModuleMap();
2981 clang::Module *M = moduleMap.findModule(ModuleName);
2982 return M && !M->IsMissingRequirement && M->getASTFile();
3000 std::string file_name = filename;
3001 size_t at = std::string::npos;
3002 while ((at = file_name.find(
"/./")) != std::string::npos)
3003 file_name.replace(at, 3,
"/");
3005 std::string filesStr =
"";
3006 llvm::raw_string_ostream filesOS(filesStr);
3007 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
3008 cling::ClangInternalState::printIncludedFiles(filesOS, SM);
3011 llvm::SmallVector<llvm::StringRef, 100> files;
3012 llvm::StringRef(filesStr).split(files,
"\n");
3014 std::set<std::string> fileMap;
3016 for (llvm::SmallVector<llvm::StringRef, 100>::const_iterator
3017 iF = files.begin(), iE = files.end(); iF != iE; ++iF) {
3018 if ((*iF) == file_name.c_str())
return kTRUE;
3019 fileMap.insert(*iF);
3022 if (fileMap.empty())
return kFALSE;
3025 TString sFilename(file_name.c_str());
3027 && fileMap.count(sFilename.
Data())) {
3035 while (incPath.
Index(
" :") != -1) {
3039 sFilename = file_name.c_str();
3041 && fileMap.count(sFilename.
Data())) {
3050 const clang::DirectoryLookup *CurDir = 0;
3051 clang::Preprocessor &PP =
fInterpreter->getCI()->getPreprocessor();
3052 clang::HeaderSearch &HS = PP.getHeaderSearchInfo();
3053 const clang::FileEntry *FE = HS.LookupFile(file_name.c_str(),
3054 clang::SourceLocation(),
3057 clang::ArrayRef<std::pair<
const clang::FileEntry *,
3058 const clang::DirectoryEntry *>>(),
3068 if (FE && FE->isValid()) {
3070 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
3072 clang::FileID FID = SM.translateFile(FE);
3073 if (!FID.isInvalid() && FID.getHashValue() == 0)
3076 clang::SrcMgr::SLocEntry SLocE = SM.getSLocEntry(FID);
3077 if (SLocE.isFile() && SLocE.getFile().getContentCache()->getRawBuffer() == 0)
3079 if (!FID.isInvalid())
3083 sFilename = FE->getName();
3085 && fileMap.count(sFilename.
Data())) {
3093#if defined(R__MACOSX)
3101static bool R__UpdateLibFileForLinking(
TString &lib)
3103 const char *mapfile =
nullptr;
3105 mapfile =
"/System/Library/dyld/dyld_shared_cache_x86_64.map";
3107 mapfile =
"/System/Library/dyld/dyld_shared_cache_arm64e.map";
3109 #error unsupported architecture
3111 if (std::ifstream cacheMap{mapfile}) {
3113 while (getline(cacheMap,
line)) {
3114 if (
line.find(lib) != std::string::npos) {
3118 if (lib ==
"-loah" || lib ==
"-lRosetta")
3135#if defined(R__WIN32) || defined(__CYGWIN__)
3136 HMODULE hModules[1024];
3138 unsigned long cbModules;
3140 hProcess = (
void *)::GetCurrentProcess();
3141 ::EnumProcessModules(hProcess, hModules,
sizeof(hModules), &cbModules);
3143 for (i = 1; i < (cbModules /
sizeof(
void *)); i++) {
3144 static const int bufsize = 260;
3145 wchar_t winname[bufsize];
3146 char posixname[bufsize];
3147 ::GetModuleFileNameExW(hProcess, hModules[i], winname, bufsize);
3148#if defined(__CYGWIN__)
3149 cygwin_conv_path(CCP_WIN_W_TO_POSIX, winname, posixname, bufsize);
3151 std::wstring wpath = winname;
3152 std::replace(wpath.begin(), wpath.end(),
'\\',
'/');
3153 string path(wpath.begin(), wpath.end());
3154 strncpy(posixname, path.c_str(), bufsize);
3160#elif defined(R__MACOSX)
3164 while (
const mach_header* mh = _dyld_get_image_header(imageIndex)) {
3166 if (mh->filetype == MH_DYLIB) {
3167 if (
const char* imageName = _dyld_get_image_name(imageIndex)) {
3175#elif defined(R__LINUX)
3188 PointerNo4* procLinkMap = (PointerNo4*)dlopen(0, RTLD_LAZY | RTLD_GLOBAL);
3191 LinkMap* linkMap = (LinkMap*) ((PointerNo4*)procLinkMap->fPtr)->fPtr;
3195 dlclose(procLinkMap);
3199 while (iDyLib->fNext) {
3200 iDyLib = iDyLib->fNext;
3205 Error(
"TCling::UpdateListOfLoadedSharedLibraries",
3206 "Platform not supported!");
3217 if (!filename)
return;
3221 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
3222 if (!DLM->isLibraryLoaded(filename)) {
3223 DLM->loadLibrary(filename,
true );
3226#if defined(R__MACOSX)
3228 auto lenFilename = strlen(filename);
3229 if (!strncmp(filename,
"/usr/lib/system/", 16)
3230 || !strncmp(filename,
"/usr/lib/libc++", 15)
3231 || !strncmp(filename,
"/System/Library/Frameworks/", 27)
3232 || !strncmp(filename,
"/System/Library/PrivateFrameworks/", 34)
3233 || !strncmp(filename,
"/System/Library/CoreServices/", 29)
3234 || !strcmp(filename,
"cl_kernels")
3235 || strstr(filename,
"/usr/lib/libSystem")
3236 || strstr(filename,
"/usr/lib/libstdc++")
3237 || strstr(filename,
"/usr/lib/libicucore")
3238 || strstr(filename,
"/usr/lib/libbsm")
3239 || strstr(filename,
"/usr/lib/libobjc")
3240 || strstr(filename,
"/usr/lib/libresolv")
3241 || strstr(filename,
"/usr/lib/libauto")
3242 || strstr(filename,
"/usr/lib/libcups")
3243 || strstr(filename,
"/usr/lib/libDiagnosticMessagesClient")
3244 || strstr(filename,
"/usr/lib/liblangid")
3245 || strstr(filename,
"/usr/lib/libCRFSuite")
3246 || strstr(filename,
"/usr/lib/libpam")
3247 || strstr(filename,
"/usr/lib/libOpenScriptingUtil")
3248 || strstr(filename,
"/usr/lib/libextension")
3249 || strstr(filename,
"/usr/lib/libAudioToolboxUtility")
3253 || (lenFilename > 4 && !strcmp(filename + lenFilename - 4,
".tbd")))
3256 R__UpdateLibFileForLinking(sFileName);
3257 filename = sFileName.
Data();
3258#elif defined(__CYGWIN__)
3260 static const int bufsize = 260;
3261 char posixwindir[bufsize];
3262 char *windir = getenv(
"WINDIR");
3264 cygwin_conv_path(CCP_WIN_A_TO_POSIX, windir, posixwindir, bufsize);
3266 snprintf(posixwindir,
sizeof(posixwindir),
"/Windows/");
3267 if (strstr(filename, posixwindir) ||
3268 strstr(filename,
"/usr/bin/cyg"))
3270#elif defined(R__WIN32)
3271 if (strstr(filename,
"/Windows/"))
3273#elif defined (R__LINUX)
3274 if (strstr(filename,
"/ld-linux")
3275 || strstr(filename,
"linux-gnu/")
3276 || strstr(filename,
"/libstdc++.")
3277 || strstr(filename,
"/libgcc")
3278 || strstr(filename,
"/libc.")
3279 || strstr(filename,
"/libdl.")
3280 || strstr(filename,
"/libm."))
3297 assert(!
IsFromRootCling() &&
"Trying to load library from rootcling!");
3301 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
3302 std::string canonLib = DLM->lookupLibrary(filename);
3303 cling::DynamicLibraryManager::LoadLibResult res
3304 = cling::DynamicLibraryManager::kLoadLibNotFound;
3305 if (!canonLib.empty()) {
3307 res = DLM->loadLibrary(filename, system);
3311 cling::Interpreter::CompilationResult compRes;
3313 if (compRes == cling::Interpreter::kSuccess)
3314 res = cling::DynamicLibraryManager::kLoadLibSuccess;
3318 if (res == cling::DynamicLibraryManager::kLoadLibSuccess) {
3322 case cling::DynamicLibraryManager::kLoadLibSuccess:
return 0;
3323 case cling::DynamicLibraryManager::kLoadLibAlreadyLoaded:
return 1;
3373 Warning(
"Calc",
"waiting for cling thread to free");
3376 gROOT->SetLineIsProcessing();
3384 cling::Interpreter::CompilationResult cr =
fInterpreter->evaluate(
line, valRef);
3385 if (cr != cling::Interpreter::kSuccess) {
3393 if (!valRef.isValid()) {
3402 if (valRef.isVoid()) {
3409 gROOT->SetLineHasBeenProcessed();
3412 return valRef.simplisticCastAs<
long>();
3419 void (*histaddFunc)(
const char*
line))
3424#if defined(R__MUST_REVISIT)
3425#if R__MUST_REVISIT(6,2)
3426 Warning(
"SetGetline",
"Cling should support the equivalent of SetGetlineFunc(getlineFunc, histaddFunc)");
3439 if ((std::distance(
T.decls_begin(),
T.decls_end()) != 1)
3440 ||
T.deserialized_decls_begin() !=
T.deserialized_decls_end()
3441 ||
T.macros_begin() !=
T.macros_end()
3442 || ((!
T.getFirstDecl().isNull()) && ((*
T.getFirstDecl().begin()) !=
T.getWrapperFD()))) {
3465 std::set<TObject*>::iterator iSpecial = ((std::set<TObject*>*)
fgSetOfSpecials)->find(obj);
3483#if defined(R__MUST_REVISIT)
3484#if R__MUST_REVISIT(6,2)
3486 Warning(
"Reset",
"Cling should support the equivalent of scratch_upto(&fDictPos)");
3496#if defined(R__MUST_REVISIT)
3497#if R__MUST_REVISIT(6,2)
3499 Warning(
"ResetAll",
"Cling should support the equivalent of complete reset (unload everything but the startup decls.");
3526#if defined(R__MUST_REVISIT)
3527#if R__MUST_REVISIT(6,2)
3529 Warning(
"ResetGlobalVar",
"Cling should support the equivalent of resetglobalvar(obj)");
3541#if defined(R__MUST_REVISIT)
3542#if R__MUST_REVISIT(6,2)
3544 Warning(
"RewindDictionary",
"Cling should provide a way to revert transaction similar to rewinddictionary()");
3555#if defined(R__MUST_REVISIT)
3556#if R__MUST_REVISIT(6,2)
3558 Warning(
"DeleteGlobal",
"Cling should provide the equivalent of deleteglobal(obj), see also DeleteVariable.");
3570#if defined(R__MUST_REVISIT)
3571#if R__MUST_REVISIT(6,2)
3572 Warning(
"DeleteVariable",
"should do more that just reseting the value to zero");
3577 llvm::StringRef srName(
name);
3578 const char* unscopedName =
name;
3579 llvm::StringRef::size_type posScope = srName.rfind(
"::");
3580 const clang::DeclContext* declCtx = 0;
3581 if (posScope != llvm::StringRef::npos) {
3582 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
3583 const clang::Decl* scopeDecl
3584 = lh.findScope(srName.substr(0, posScope),
3585 cling::LookupHelper::WithDiagnostics);
3587 Error(
"DeleteVariable",
"Cannot find enclosing scope for variable %s",
3591 declCtx = llvm::dyn_cast<clang::DeclContext>(scopeDecl);
3593 Error(
"DeleteVariable",
3594 "Enclosing scope for variable %s is not a declaration context",
3598 unscopedName += posScope + 2;
3602 clang::NamedDecl* nVarDecl
3603 = cling::utils::Lookup::Named(&
fInterpreter->getSema(), unscopedName, declCtx);
3605 Error(
"DeleteVariable",
"Unknown variable %s",
name);
3608 clang::VarDecl* varDecl = llvm::dyn_cast<clang::VarDecl>(nVarDecl);
3610 Error(
"DeleteVariable",
"Entity %s is not a variable",
name);
3614 clang::QualType qType = varDecl->getType();
3618 if (
type->isPointerType()) {
3619 int** ppInt = (
int**)
fInterpreter->getAddressOfGlobal(GlobalDecl(varDecl));
3621 if (ppInt) *ppInt = 0;
3631#if defined(R__MUST_REVISIT)
3632#if R__MUST_REVISIT(6,2)
3634 Warning(
"SaveContext",
"Cling should provide a way to record a state watermark similar to store_dictposition(&fDictPos)");
3644#if defined(R__MUST_REVISIT)
3645#if R__MUST_REVISIT(6,2)
3647 Warning(
"SaveGlobalsContext",
"Cling should provide a way to record a watermark for the list of global variable similar to store_dictposition(&fDictPosGlobals)");
3681struct AlternateTupleIntDoubleAsc
3687struct AlternateTupleIntDoubleDes
3695 std::tuple<int,double> value;
3696 AlternateTupleIntDoubleAsc asc;
3697 AlternateTupleIntDoubleDes des;
3699 size_t offset0 = ((
char*)&(std::get<0>(value))) - ((
char*)&value);
3700 size_t offset1 = ((
char*)&(std::get<1>(value))) - ((
char*)&value);
3702 size_t ascOffset0 = ((
char*)&(asc._0)) - ((
char*)&asc);
3703 size_t ascOffset1 = ((
char*)&(asc._1)) - ((
char*)&asc);
3705 size_t desOffset0 = ((
char*)&(des._0)) - ((
char*)&des);
3706 size_t desOffset1 = ((
char*)&(des._1)) - ((
char*)&des);
3708 if (offset0 == ascOffset0 && offset1 == ascOffset1) {
3710 }
else if (offset0 == desOffset0 && offset1 == desOffset1) {
3717static std::string
AlternateTuple(
const char *classname,
const cling::LookupHelper& lh)
3720 std::string alternateName =
"TEmulatedTuple";
3721 alternateName.append( classname + 5 );
3723 std::string fullname =
"ROOT::Internal::" + alternateName;
3724 if (lh.findScope(fullname, cling::LookupHelper::NoDiagnostics,
3728 std::string guard_name;
3729 ROOT::TMetaUtils::GetCppName(guard_name,alternateName.c_str());
3730 std::ostringstream guard;
3731 guard <<
"ROOT_INTERNAL_TEmulated_";
3732 guard << guard_name;
3734 std::ostringstream alternateTuple;
3735 alternateTuple <<
"#ifndef " << guard.str() <<
"\n";
3736 alternateTuple <<
"#define " << guard.str() <<
"\n";
3737 alternateTuple <<
"namespace ROOT { namespace Internal {\n";
3738 alternateTuple <<
"template <class... Types> struct TEmulatedTuple;\n";
3739 alternateTuple <<
"template <> struct " << alternateName <<
" {\n";
3744 unsigned int nMember = 0;
3745 auto iter = tupleContent.
fElements.begin() + 1;
3746 auto theEnd = tupleContent.
fElements.end() - 1;
3747 while (iter != theEnd) {
3748 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
3755 unsigned int nMember = tupleContent.
fElements.size() - 3;
3756 auto iter = tupleContent.
fElements.rbegin() + 1;
3757 auto theEnd = tupleContent.
fElements.rend() - 1;
3758 while (iter != theEnd) {
3759 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
3766 Fatal(
"TCling::SetClassInfo::AlternateTuple",
3767 "Layout of std::tuple on this platform is unexpected.");
3772 alternateTuple <<
"};\n";
3773 alternateTuple <<
"}}\n";
3774 alternateTuple <<
"#endif\n";
3776 Error(
"Load",
"Could not declare %s",alternateName.c_str());
3779 alternateName =
"ROOT::Internal::" + alternateName;
3780 return alternateName;
3823 if (strncmp(cl->
GetName(),
"tuple<",strlen(
"tuple<"))==0) {
3855 zombieCandidate =
kTRUE;
3862 zombieCandidate =
kTRUE;
3916 static const char *anonEnum =
"anonymous enum ";
3917 static const int cmplen = strlen(anonEnum);
3944 const char *classname =
name;
3955 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
3957 const clang::Decl *decl
3958 = lh.findScope(classname,
3959 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
3960 : cling::LookupHelper::NoDiagnostics,
3964 decl = lh.findScope(buf,
3965 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
3966 : cling::LookupHelper::NoDiagnostics,
3983 clang::ClassTemplateSpecializationDecl *tmpltDecl =
3984 llvm::dyn_cast_or_null<clang::ClassTemplateSpecializationDecl>
3985 (
type->getAsCXXRecordDecl());
3986 if (tmpltDecl && !tmpltDecl->getPointOfInstantiation().isValid()) {
4005 if (tci.
Property() & propertiesMask) {
4006 bool hasClassDefInline =
false;
4007 if (isClassOrNamespaceOnly) {
4013 if (hasDictionary.IsValid() && implLineFunc.IsValid()) {
4015 bool success =
false;
4016 std::tie(success, lineNumber) =
4017 ROOT::TMetaUtils::GetTrivialIntegralReturnValue(implLineFunc.GetMethodDecl(), *
fInterpreter);
4018 hasClassDefInline = success && (lineNumber == -1);
4027 if (hasClassDefInline)
4070 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
4071 const clang::Decl *decl
4072 = lh.findClassTemplate(
name,
4073 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4074 : cling::LookupHelper::NoDiagnostics);
4076 std::string strname =
"std::";
4078 decl = lh.findClassTemplate(strname,
4079 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4080 : cling::LookupHelper::NoDiagnostics);
4106 cl->
fBase = listOfBase;
4122 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
4125 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
4128 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
4129 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
4130 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(), declEnd = allDeclContexts.end();
4131 declIter != declEnd; ++declIter) {
4133 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
4134 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
4135 if (
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(*DI)) {
4138 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
4139 llvm::raw_string_ostream stream(buf);
4141 Policy.AnonymousTagLocations =
false;
4142 ED->getNameForDiagnostic(stream, Policy,
false);
4146 const char*
name = buf.c_str();
4170 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
4174 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
4177 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
4178 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
4179 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(),
4180 declEnd = allDeclContexts.end(); declIter != declEnd; ++declIter) {
4182 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
4183 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
4184 if (
const clang::FunctionTemplateDecl* FTD = dyn_cast<clang::FunctionTemplateDecl>(*DI)) {
4185 funcTempList->
Get(FTD);
4243 if (
m->fMethodArgs) {
4254 m->fMethodArgs = arglist;
4293 if (llvm::isa<clang::NamespaceDecl>(cli->
GetDecl())) {
4302 Error(
"GenerateTClass",
4303 "Cannot find %s::Class_Version()! Class version might be wrong.",
4308 newvers = ROOT::TMetaUtils::GetClassVersion(llvm::dyn_cast<clang::RecordDecl>(cli->
GetDecl()),
4310 if (newvers == -1) {
4318 newvers = callfunc.
ExecInt(0);
4320 Error(
"GenerateTClass",
4321 "Cannot invoke %s::Class_Version()! Class version might be wrong.",
4325 if (newvers != oldvers) {
4342static void GenerateTClass_GatherInnerIncludes(cling::Interpreter *interp,
TString &includes,
TClingClassInfo *info)
4346 const clang::ClassTemplateSpecializationDecl *templateCl
4347 = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(info->
GetDecl());
4349 for(
unsigned int i=0; i < templateCl->getTemplateArgs().size(); ++i) {
4350 const clang::TemplateArgument &arg( templateCl->getTemplateArgs().get(i) );
4352 const clang::Type *uType = ROOT::TMetaUtils::GetUnderlyingType( arg.getAsType() );
4354 if (!uType->isFundamentalType() && !uType->isEnumeralType()) {
4356 const clang::CXXRecordDecl *argdecl = uType->getAsCXXRecordDecl();
4359 TClingClassInfo subinfo(interp,*(argdecl->getASTContext().getRecordType(argdecl).getTypePtr()));
4360 GenerateTClass_GatherInnerIncludes(interp, includes, &subinfo);
4363 llvm::raw_string_ostream OS(Result);
4364 arg.print(argdecl->getASTContext().getPrintingPolicy(),OS);
4365 Warning(
"TCling::GenerateTClass",
"Missing header file for %s",OS.str().c_str());
4380 if (!info || !info->
IsValid()) {
4381 Fatal(
"GenerateTClass",
"Requires a valid ClassInfo object");
4386 std::string classname;
4390 Info(
"GenerateTClass",
"Will (try to) generate the compiled TClass for %s.",classname.c_str());
4394 GenerateTClass_GatherInnerIncludes(
fInterpreter,includes,info);
4400 Error(
"GenerateTClass",
"Even though the dictionary generation for %s seemed successful we can't find the TClass bootstrap!",classname.c_str());
4406 cl =
new TClass(classinfo, version, 0, 0, -1, -1, silent);
4412 cl =
new TClass(classinfo, 1, 0, 0, -1, -1, silent);
4437 if (classes == 0 || classes[0] == 0) {
4438 Error(
"TCling::GenerateDictionary",
"Cannot generate dictionary without passing classes.");
4442 std::vector<std::string> listClasses;
4444 const char* current = classes, *prev = classes;
4448 if (*current ==
';') {
4449 listClasses.push_back(std::string(prev, current - prev));
4452 else if (*(current + 1) == 0) {
4453 listClasses.push_back(std::string(prev, current + 1 - prev));
4457 std::vector<std::string> listIncludes;
4461 const char* current = includes, *prev = includes;
4465 if (*current ==
';') {
4466 listIncludes.push_back(std::string(prev, current - prev));
4469 else if (*(current + 1) == 0) {
4470 listIncludes.push_back(std::string(prev, current + 1 - prev));
4476 std::vector<std::string>(), std::vector<std::string>());
4497 if (
const ValueDecl* decl = (
const ValueDecl*)
d){
4499 bool hasIoName = ROOT::TMetaUtils::ExtractAttrPropertyFromName(*decl,
"ioname",ioName);
4500 if (hasIoName && ioName !=
name)
return 0;
4512 using namespace clang;
4514 DeclarationName DName = &SemaR.Context.Idents.get(
name);
4516 LookupResult
R(SemaR, DName, SourceLocation(), Sema::LookupOrdinaryName,
4517 Sema::ForRedeclaration);
4521 cling::utils::Lookup::Named(&SemaR,
R);
4525 while (
F.hasNext()) {
4526 NamedDecl *D =
F.next();
4527 if (isa<VarDecl>(D) || isa<FieldDecl>(D) || isa<EnumConstantDecl>(D) ||
4528 isa<IndirectFieldDecl>(D))
4534 if (
R.isSingleResult())
4535 return R.getFoundDecl();
4547 const clang::Decl* possibleEnum = 0;
4552 const clang::DeclContext* dc = 0;
4553 if (
const clang::Decl* D = cci->
GetDecl()) {
4554 if (!(dc = dyn_cast<clang::NamespaceDecl>(D))) {
4555 dc = dyn_cast<clang::RecordDecl>(D);
4562 possibleEnum = cling::utils::Lookup::Tag(&
fInterpreter->getSema(),
name, dc);
4564 Error(
"TCling::GetEnum",
"DeclContext not found for %s .\n",
name);
4573 if (possibleEnum && (possibleEnum != (clang::Decl*)-1)
4574 && isa<clang::EnumDecl>(possibleEnum)) {
4575 return possibleEnum;
4587 llvm::StringRef mangled_name = gv->getName();
4602 std::string scopename(demangled_name_c);
4603 free(demangled_name_c);
4609 std::string dataname;
4611 if (!strncmp(scopename.c_str(),
"typeinfo for ",
sizeof(
"typeinfo for ")-1)) {
4612 scopename.erase(0,
sizeof(
"typeinfo for ")-1);
4613 }
else if (!strncmp(scopename.c_str(),
"vtable for ",
sizeof(
"vtable for ")-1)) {
4614 scopename.erase(0,
sizeof(
"vtable for ")-1);
4617 std::string::size_type pos = scopename.rfind(
'(');
4618 if (pos != std::string::npos) {
4622 pos = scopename.rfind(
':');
4623 if (pos != std::string::npos) {
4624 if ((pos != 0) && (scopename[pos-1] ==
':')) {
4625 dataname = scopename.substr(pos+1);
4626 scopename.erase(pos-1);
4630 dataname = scopename;
4638 if (scopename.size()) {
4654 Error(
"GetDataMemberWithValue()",
"not implemented");
4664 Error(
"GetDataMemberAtAddr()",
"not implemented");
4674 const char* params,
Bool_t objectIsConst )
4686 func.
SetFunc(&gcl, method, params, &offset);
4692 return mangled_name;
4707 GetMethod(method,
proto, objectIsConst, 0 , mode).GetMangledName();
4719 const char* params,
Bool_t objectIsConst )
4731 func.
SetFunc(&gcl, method, params, &offset);
4760 std::vector<DeclId_t>& res)
const
4763 clang::ASTContext& Ctx =
S.Context;
4764 const clang::Decl* CtxDecl
4766 Ctx.getTranslationUnitDecl();
4767 auto RecDecl = llvm::dyn_cast<const clang::RecordDecl>(CtxDecl);
4768 const clang::DeclContext* DeclCtx = RecDecl;
4771 DeclCtx = dyn_cast<clang::NamespaceDecl>(CtxDecl);
4772 if (!DeclCtx)
return;
4774 clang::DeclarationName DName;
4779 if (RecDecl->getNameAsString() == funcname) {
4780 clang::QualType QT = Ctx.getTypeDeclType(RecDecl);
4781 DName = Ctx.DeclarationNames.getCXXConstructorName(Ctx.getCanonicalType(QT));
4782 }
else if (funcname[0] ==
'~' && RecDecl->getNameAsString() == funcname + 1) {
4783 clang::QualType QT = Ctx.getTypeDeclType(RecDecl);
4784 DName = Ctx.DeclarationNames.getCXXDestructorName(Ctx.getCanonicalType(QT));
4786 DName = &Ctx.Idents.get(funcname);
4789 DName = &Ctx.Idents.get(funcname);
4792 clang::LookupResult
R(
S, DName, clang::SourceLocation(),
4793 Sema::LookupOrdinaryName, clang::Sema::ForRedeclaration);
4794 S.LookupQualifiedName(
R,
const_cast<DeclContext*
>(DeclCtx));
4795 if (
R.empty())
return;
4797 res.reserve(res.size() + (
R.end() -
R.begin()));
4798 for (clang::LookupResult::iterator IR =
R.begin(), ER =
R.end();
4800 if (
const clang::FunctionDecl* FD
4801 = llvm::dyn_cast<const clang::FunctionDecl>(*IR)) {
4802 if (!FD->getDescribedFunctionTemplate()) {
4962 const char* params,
Bool_t objectIsConst,
int* error)
4975 void* address = (
void*)((
Long_t)addr + offset);
4982 const char* params,
int* error)
4984 Execute(obj,cl,method,params,
false,error);
4999 Error(
"Execute",
"No method was defined");
5008 if (argc > nparms) {
5009 Error(
"Execute",
"Too many parameters to call %s, got %d but expected at most %d.",method->
GetName(),argc,nparms);
5012 if (nparms != argc) {
5022 Int_t firstDefault = -1;
5023 for (
Int_t i = 0; i < nparms; i ++) {
5030 if (firstDefault >= 0) {
5031 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);
5033 Error(
"Execute",
"Too few arguments to call %s, got only %d but expected %d.",method->
GetName(),argc,nparms);
5039 const char* listpar =
"";
5044 for (
Int_t i = 0; i < argc; i ++) {
5053 chpar += (nxtpar->
String()).ReplaceAll(
"\"",
"\\\"");
5060 complete += nxtpar->
String();
5063 listpar = complete.
Data();
5081 const CXXMethodDecl * mdecl = dyn_cast<CXXMethodDecl>(minfo->
GetMethodDecl());
5083 void* address = (
void*)((
Long_t)addr + offset);
5090 const void* args[] ,
5095 Error(
"ExecuteWithArgsAndReturn",
"No method was defined");
5122 Warning(
"GetTopLevelMacroName",
"Must change return type!");
5169#if defined(R__MUST_REVISIT)
5170#if R__MUST_REVISIT(6,0)
5171 Warning(
"GetCurrentMacroName",
"Must change return type!");
5184 TTHREAD_TLS(
char*) t = 0;
5185 TTHREAD_TLS(
unsigned int) tlen = 0;
5187 unsigned int dlen = strlen(typeDesc);
5190 t =
new char[dlen + 1];
5193 const char*
s, *template_start;
5194 if (!strstr(typeDesc,
"(*)(")) {
5195 s = strchr(typeDesc,
' ');
5196 template_start = strchr(typeDesc,
'<');
5197 if (!strcmp(typeDesc,
"long long")) {
5198 strlcpy(t, typeDesc, dlen + 1);
5200 else if (!strncmp(typeDesc,
"unsigned ",
s + 1 - typeDesc)) {
5201 strlcpy(t, typeDesc, dlen + 1);
5207 else if (
s && (template_start == 0 || (
s < template_start))) {
5208 strlcpy(t,
s + 1, dlen + 1);
5211 strlcpy(t, typeDesc, dlen + 1);
5215 strlcpy(t, typeDesc, dlen + 1);
5218 while (
l > 0 && (t[
l - 1] ==
'*' || t[
l - 1] ==
'&')) {
5226 assert(rootmapfile && *rootmapfile);
5228 llvm::StringRef libName = llvm::sys::path::filename(rootmapfile);
5229 libName.consume_back(
".rootmap");
5231 return !
gInterpreter->HasPCMForLibrary(libName.str().c_str());
5242 if (!(rootmapfile && *rootmapfile))
5249 const std::map<char, unsigned int> keyLenMap = {{
'c',6},{
'n',10},{
't',8},{
'h',7},{
'e',5},{
'v',4}};
5251 std::string rootmapfileNoBackslash(rootmapfile);
5253 std::replace(rootmapfileNoBackslash.begin(), rootmapfileNoBackslash.end(),
'\\',
'/');
5260 uniqueString->
Append(std::string(
"\n#line 1 \"Forward declarations from ") + rootmapfileNoBackslash +
"\"\n");
5262 std::ifstream
file(rootmapfileNoBackslash);
5265 std::string lib_name;
5267 bool newFormat =
false;
5268 while (getline(
file,
line,
'\n')) {
5269 if (!newFormat && (
line.compare(0, 8,
"Library.") == 0 ||
line.compare(0, 8,
"Declare.") == 0)) {
5275 if (
line.compare(0, 9,
"{ decls }") == 0) {
5278 while (getline(
file,
line,
'\n')) {
5281 if (!uniqueString) {
5282 Error(
"ReadRootmapFile",
"Cannot handle \"{ decls }\" sections in custom rootmap file %s",
5283 rootmapfileNoBackslash.c_str());
5289 const char firstChar =
line[0];
5290 if (firstChar ==
'[') {
5292 auto brpos =
line.find(
']');
5293 if (brpos == string::npos)
5295 lib_name =
line.substr(1, brpos - 1);
5297 while (lib_name[nspaces] ==
' ')
5300 lib_name.replace(0, nspaces,
"");
5302 TString lib_nameTstr(lib_name.c_str());
5307 Info(
"ReadRootmapFile",
"new section for %s", lib_nameTstr.
Data());
5309 Info(
"ReadRootmapFile",
"section for %s (library does not exist)", lib_nameTstr.
Data());
5315 auto keyLenIt = keyLenMap.find(firstChar);
5316 if (keyLenIt == keyLenMap.end())
5318 unsigned int keyLen = keyLenIt->second;
5320 const char *keyname =
line.c_str() + keyLen;
5322 Info(
"ReadRootmapFile",
"class %s in %s", keyname, lib_name.c_str());
5325 if (lib_name != isThere->
GetValue()) {
5326 if (firstChar ==
'n') {
5328 Info(
"ReadRootmapFile",
"namespace %s found in %s is already in %s", keyname, lib_name.c_str(),
5330 }
else if (firstChar ==
'h') {
5335 Warning(
"ReadRootmapFile",
"%s %s found in %s is already in %s",
line.substr(0, keyLen).c_str(),
5336 keyname, lib_name.c_str(), isThere->
GetValue());
5340 Info(
"ReadRootmapFile",
"Key %s was already defined for %s", keyname, lib_name.c_str());
5401 using namespace clang;
5403 class ExtVisibleStorageAdder:
public RecursiveASTVisitor<ExtVisibleStorageAdder>{
5409 ExtVisibleStorageAdder(std::unordered_set<const NamespaceDecl*>& nsSet): fNSSet(nsSet) {};
5410 bool VisitNamespaceDecl(NamespaceDecl* nsDecl) {
5415 nsDecl->setHasExternalVisibleStorage();
5416 fNSSet.insert(nsDecl);
5420 std::unordered_set<const NamespaceDecl*>& fNSSet;
5468 for (
Int_t j = 0; j < i; j++) {
5479 Info(
"LoadLibraryMap",
"%s",
d.Data());
5484 if (
f.EndsWith(
".rootmap")) {
5490 Info(
"LoadLibraryMap",
" rootmap file: %s", p.
Data());
5508 if (
f.BeginsWith(
"rootmap")) {
5513 Warning(
"LoadLibraryMap",
"please rename %s to end with \".rootmap\"", p.
Data());
5526 if (rootmapfile && *rootmapfile) {
5533 else if (res == -3) {
5543 while ((rec = (
TEnvRec*) next())) {
5545 if (!strncmp(cls.
Data(),
"Library.", 8) && cls.
Length() > 8) {
5564 Info(
"LoadLibraryMap",
"class %s in %s", cls.
Data(), wlib);
5567 Info(
"LoadLibraryMap",
"class %s in %s (library does not exist)", cls.
Data(), lib);
5573 else if (!strncmp(cls.
Data(),
"Declare.", 8) && cls.
Length() > 8) {
5583 cling::Transaction*
T =
nullptr;
5585 assert(cling::Interpreter::kSuccess == compRes &&
"A declaration in a rootmap could not be compiled");
5587 if (compRes!=cling::Interpreter::kSuccess){
5589 "Problems in %s declaring '%s' were encountered.", rootmapfile, uniqueString.
Data()) ;
5594 for (
auto declIt =
T->decls_begin(); declIt < T->decls_end(); ++declIt) {
5595 if (declIt->m_DGR.isSingleDecl()) {
5596 if (Decl* D = declIt->m_DGR.getSingleDecl()) {
5597 if (NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(D)) {
5598 evsAdder.TraverseDecl(NSD);
5633 for (
Int_t ilib = 0; ilib < nrSharedLibs; ilib++) {
5640 TString rootMapBaseStr = sharedLibBaseStr;
5641 if (sharedLibBaseStr.
EndsWith(
".dll")) {
5644 else if (sharedLibBaseStr.
EndsWith(
".DLL")) {
5647 else if (sharedLibBaseStr.
EndsWith(
".so")) {
5650 else if (sharedLibBaseStr.
EndsWith(
".sl")) {
5653 else if (sharedLibBaseStr.
EndsWith(
".dl")) {
5656 else if (sharedLibBaseStr.
EndsWith(
".a")) {
5660 Error(
"ReloadAllSharedLibraryMaps",
"Unknown library type %s", sharedLibBaseStr.
Data());
5664 rootMapBaseStr +=
".rootmap";
5667 Error(
"ReloadAllSharedLibraryMaps",
"Could not find rootmap %s in path", rootMapBaseStr.
Data());
5674 Error(
"ReloadAllSharedLibraryMaps",
"Error loading map %s", rootMap);
5709 if (!
fMapfile || !library || !*library) {
5717 size_t len = libname.
Length();
5722 while ((rec = (
TEnvRec *) next())) {
5733 if (!strncmp(cls.
Data(),
"Library.", 8) && cls.
Length() > 8) {
5742 if (!strncmp(lib, libname.
Data(), len)) {
5744 Error(
"UnloadLibraryMap",
"entry for <%s, %s> not found in library map table", cls.
Data(), lib);
5752 TString library_rootmap(library);
5753 if (!library_rootmap.
EndsWith(
".rootmap"))
5754 library_rootmap.
Append(
".rootmap");
5807 free(demangled_name);
5825 std::string demangled_name(demangled_name_c);
5826 free(demangled_name_c);
5839 result =
AutoLoad(demangled_name.c_str(), knowDictNotLoaded);
5858 if (
gROOT->LoadClass(cls, deplib) == 0) {
5861 "loaded dependent library %s for %s", deplib, cls);
5866 "failure loading dependent library %s for %s",
5871 if (lib && lib[0]) {
5872 if (
gROOT->LoadClass(cls, lib) == 0) {
5875 "loaded library %s for %s", lib, cls);
5881 "failure loading library %s for %s", lib, cls);
5904 static std::set<std::string> gClassOnStack;
5905 auto insertResult = gClassOnStack.insert(std::string(cls));
5906 if (insertResult.second) {
5910 for(
auto element :
proto->GetData()) {
5911 const char *subtypename = element->GetTypeName();
5924 if (classinfo &&
gInterpreter->ClassInfo_IsValid(classinfo)
5927 DataMemberInfo_t *memberinfo =
gInterpreter->DataMemberInfo_Factory(classinfo);
5928 while (
gInterpreter->DataMemberInfo_Next(memberinfo)) {
5944 gClassOnStack.erase(insertResult.first);
5963 Info(
"TCling::AutoLoad",
"Explicitly disabled (the class name is %s)", cls);
5983 Info(
"TCling::AutoLoad",
5984 "Trying to autoload for %s", cls);
5989 Info(
"TCling::AutoLoad",
5990 "Disabled due to gROOT or gInterpreter being invalid/not ready (the class name is %s)", cls);
6019 cling::Interpreter *interpreter)
6021 std::string code = gNonInterpreterClassDef ;
6028 code += (
"#include \"");
6032 code += (
"#ifdef __ROOTCLING__\n"
6033 "#undef __ROOTCLING__\n"
6034 + gInterpreterClassDef +
6037 cling::Interpreter::CompilationResult cr;
6043 Sema &SemaR = interpreter->getSema();
6045 clangDiagSuppr diagSuppr(SemaR.getDiagnostics());
6047 #if defined(R__MUST_REVISIT)
6048 #if R__MUST_REVISIT(6,2)
6049 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
6053 cr = interpreter->parseForModule(code);
6071 Int_t nHheadersParsed = 0;
6072 unsigned long offset = 0;
6073 if (strncmp(cls,
"const ", 6) == 0) {
6078 bool skipFirstEntry =
false;
6079 std::vector<std::string> autoparseKeys;
6080 if (strchr(cls,
'<')) {
6086 if (!autoparseKeys.empty() && !autoparseKeys[0].empty()) {
6091 TString templateName(autoparseKeys[0]);
6092 auto tokens = templateName.
Tokenize(
"::");
6093 clang::NamedDecl* previousScopeAsNamedDecl =
nullptr;
6094 clang::DeclContext* previousScopeAsContext =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
6096 previousScopeAsContext =
fInterpreter->getSema().getStdNamespace();
6097 auto nTokens = tokens->GetEntries();
6098 for (
Int_t tk = 0; tk < nTokens; ++tk) {
6099 auto scopeObj = tokens->UncheckedAt(tk);
6100 auto scopeName = ((
TObjString*) scopeObj)->String().Data();
6101 previousScopeAsNamedDecl = cling::utils::Lookup::Named(&
fInterpreter->getSema(), scopeName, previousScopeAsContext);
6103 if ((clang::NamedDecl*)-1 == previousScopeAsNamedDecl)
break;
6104 previousScopeAsContext = llvm::dyn_cast_or_null<clang::DeclContext>(previousScopeAsNamedDecl);
6105 if (!previousScopeAsContext)
break;
6109 if ((clang::NamedDecl*)-1 != previousScopeAsNamedDecl) {
6110 if (
auto templateDecl = llvm::dyn_cast_or_null<clang::ClassTemplateDecl>(previousScopeAsNamedDecl)) {
6111 if (
auto templatedDecl = templateDecl->getTemplatedDecl()) {
6112 skipFirstEntry = templatedDecl->hasDefinition();
6119 if (topLevel) autoparseKeys.emplace_back(cls);
6121 for (
const auto & apKeyStr : autoparseKeys) {
6122 if (skipFirstEntry) {
6123 skipFirstEntry=
false;
6126 if (apKeyStr.empty())
continue;
6127 const char *apKey = apKeyStr.c_str();
6131 Info(
"TCling::AutoParse",
6132 "Starting autoparse for %s\n", apKey);
6137 const cling::Transaction *
T =
fInterpreter->getCurrentTransaction();
6139 auto const &hNamesPtrs = iter->second;
6141 Info(
"TCling::AutoParse",
6142 "We can proceed for %s. We have %s headers.", apKey, std::to_string(hNamesPtrs.size()).c_str());
6144 for (
auto & hName : hNamesPtrs) {
6146 if (0 !=
fPayloads.count(normNameHash)) {
6147 float initRSSval=0.f, initVSIZEval=0.f;
6149 (
void) initVSIZEval;
6152 "Parsing full payload for %s", apKey);
6159 if (cRes != cling::Interpreter::kSuccess) {
6160 if (hName[0] ==
'\n')
6161 Error(
"AutoParse",
"Error parsing payload code for class %s with content:\n%s", apKey, hName);
6170 Info(
"Autoparse",
">>> RSS key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initRSSval, endRSSval, endRSSval-initRSSval);
6171 Info(
"Autoparse",
">>> VSIZE key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initVSIZEval, endVSIZEval, endVSIZEval-initVSIZEval);
6177 "Parsing single header %s", hName);
6180 if (cRes != cling::Interpreter::kSuccess) {
6181 Error(
"AutoParse",
"Error parsing headerfile %s for class %s.", hName, apKey);
6193 if (strchr(apKey,
'<')) {
6200 return nHheadersParsed;
6210 if (llvm::StringRef(cls).contains(
"(lambda)"))
6224 Info(
"TCling::AutoParse",
6225 "Trying to autoparse for %s", cls);
6247 return nHheadersParsed > 0 ? 1 : 0;
6255 StringRef errMsg(errmessage);
6256 if (errMsg.contains(
"undefined symbol: ")) {
6258 std::string mangled_name = std::string(errMsg.split(
"undefined symbol: ").second);
6259 void* res = ((
TCling*)
gCling)->LazyFunctionCreatorAutoload(mangled_name);
6260 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
6261 if (res && DLM && (DLM->loadLibrary(libStem, permanent, resolved) == cling::DynamicLibraryManager::kLoadLibSuccess))
6277 H = (
H << 5) +
H +
C;
6282 for (
auto S :
file->sections()) {
6285 if (
name ==
".gnu.hash") {
6287 S.getContents(content);
6303 if (!soFile->isELF())
6307 const int bits = 8 * soFile->getBytesInAddress();
6310 if (contents.size() < 16)
6313 const char* hashContent = contents.data();
6316 uint32_t maskWords = *
reinterpret_cast<const uint32_t *
>(hashContent + 8);
6317 uint32_t shift2 = *
reinterpret_cast<const uint32_t *
>(hashContent + 12);
6318 uint32_t hash2 = hash >> shift2;
6319 uint32_t
n = (hash / bits) % maskWords;
6321 const char *bloomfilter = hashContent + 16;
6322 const char *hash_pos = bloomfilter +
n*(bits/8);
6323 uint64_t word = *
reinterpret_cast<const uint64_t *
>(hash_pos);
6324 uint64_t bitmask = ( (1ULL << (hash % bits)) | (1ULL << (hash2 % bits)));
6325 return (bitmask & word) == bitmask;
6331 const std::string &mangled_name,
unsigned IgnoreSymbolFlags = 0)
6333 auto ObjF = llvm::object::ObjectFile::createObjectFile(ROOT::TMetaUtils::GetRealPath(library_filename));
6336 Warning(
"TCling__FindSymbol",
"Failed to read object file %s", library_filename.c_str());
6340 llvm::object::ObjectFile *BinObjFile = ObjF.get().getBinary();
6342 uint32_t hashedMangle =
GNUHash(mangled_name);
6347 for (
const auto &
S : BinObjFile->symbols()) {
6348 uint32_t Flags =
S.getFlags();
6350 if (Flags & IgnoreSymbolFlags)
6362 llvm::Expected<StringRef> SymNameErr =
S.getName();
6364 Warning(
"TCling__FindSymbol",
"Failed to read symbol %s", mangled_name.c_str());
6368 if (SymNameErr.get() == mangled_name) {
6370 Info(
"TCling__FindSymbol",
"Symbol %s found in %s\n",
6371 mangled_name.c_str(), library_filename.c_str());
6376 if (!BinObjFile->isELF())
6380 const auto *ElfObj = cast<llvm::object::ELFObjectFileBase>(BinObjFile);
6382 for (
const auto &
S : ElfObj->getDynamicSymbolIterators()) {
6383 uint32_t Flags =
S.getFlags();
6385 if (Flags & llvm::object::SymbolRef::SF_Undefined)
6397 llvm::Expected<StringRef> SymNameErr =
S.getName();
6399 Warning(
"TCling__FindSymbol",
"Failed to read symbol %s", mangled_name.c_str());
6403 if (SymNameErr.get() == mangled_name)
6411 cling::Interpreter *interp,
6412 bool searchSystem =
true) {
6413 assert(!mangled_name.empty());
6414 using namespace llvm::sys::path;
6415 using namespace llvm::sys::fs;
6419 static bool sFirstRun =
true;
6420 static bool sFirstSystemLibrary =
true;
6427 using LibraryPath = std::pair<uint32_t, std::string>;
6428 using LibraryPaths = std::vector<LibraryPath>;
6429 using BasePaths = std::vector<std::string>;
6430 static LibraryPaths sLibraries;
6431 static BasePaths sPaths;
6432 static LibraryPaths sQueriedLibraries;
6435 static LibraryPaths sSysLibraries;
6442 auto GetLibFileName = [](
const LibraryPath &
P,
const BasePaths &BaseP) {
6443 llvm::SmallString<512> Vec(BaseP[
P.first]);
6444 llvm::sys::path::append(Vec, StringRef(
P.second));
6445 return Vec.str().str();
6448 if (!sQueriedLibraries.empty()) {
6452 for (
const LibraryPath &
P : sQueriedLibraries) {
6453 const std::string LibName = GetLibFileName(
P, sPaths);
6457 sLibraries.erase(std::remove(sLibraries.begin(), sLibraries.end(),
P), sLibraries.end());
6458 if (!sSysLibraries.empty())
6459 sSysLibraries.erase(std::remove(sSysLibraries.begin(), sSysLibraries.end(),
P), sSysLibraries.end());
6469 for (
const LibraryPath &
P : sLibraries) {
6470 const std::string LibName = GetLibFileName(
P, sPaths);
6477 llvm::object::SymbolRef::SF_Undefined |
6478 llvm::object::SymbolRef::SF_Weak)) {
6479 sQueriedLibraries.push_back(
P);
6488 if (sFirstSystemLibrary) {
6490 sFirstSystemLibrary =
false;
6493 for (
const LibraryPath &
P : sSysLibraries) {
6494 const std::string LibName = GetLibFileName(
P, sPaths);
6497 llvm::object::SymbolRef::SF_Undefined |
6498 llvm::object::SymbolRef::SF_Weak)) {
6499 sQueriedLibraries.push_back(
P);
6508 cling::Interpreter *interp) {
6512 std::string maybe_prefixed_mangled_name = mangled_name;
6514 assert(!llvm::StringRef(mangled_name).startswith(
"__") &&
"Already added!");
6515 maybe_prefixed_mangled_name =
"_" + maybe_prefixed_mangled_name;
6518 std::string LibName =
ResolveSymbol(maybe_prefixed_mangled_name, interp);
6519 if (LibName.empty())
6522 if (
gSystem->
Load(LibName.c_str(),
"",
false) < 0)
6523 Error(
"TCling__LazyFunctionCreatorAutoloadForModule",
6524 "Failed to load library %s", LibName.c_str());
6526 void* addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(mangled_name.c_str());
6542 mangled_name.c_str())) {
6553 std::string
name(demangled_name_c);
6554 free(demangled_name_c);
6562 std::string::size_type pos =
name.find(
"__thiscall ");
6563 if (pos != std::string::npos) {
6564 name.erase(0, pos +
sizeof(
"__thiscall ")-1);
6566 pos =
name.find(
"__cdecl ");
6567 if (pos != std::string::npos) {
6568 name.erase(0, pos +
sizeof(
"__cdecl ")-1);
6570 if (!strncmp(
name.c_str(),
"typeinfo for ",
sizeof(
"typeinfo for ")-1)) {
6571 name.erase(0,
sizeof(
"typeinfo for ")-1);
6572 }
else if (!strncmp(
name.c_str(),
"vtable for ",
sizeof(
"vtable for ")-1)) {
6573 name.erase(0,
sizeof(
"vtable for ")-1);
6574 }
else if (!strncmp(
name.c_str(),
"operator",
sizeof(
"operator")-1)
6575 && !isalnum(
name[
sizeof(
"operator")])) {
6577 name.erase(0,
sizeof(
"operator")-1);
6578 pos =
name.rfind(
'(');
6579 if (pos != std::string::npos) {
6580 name.erase(0, pos + 1);
6581 pos =
name.find(
",");
6582 if (pos != std::string::npos) {
6586 pos =
name.rfind(
" const");
6587 if (pos != std::string::npos) {
6588 name.erase(pos, strlen(
" const"));
6590 while (!
name.empty() && strchr(
"&*",
name.back()))
6610 while (libs.
Tokenize(lib, posLib)) {
6620 void* addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(mangled_name.c_str());
6642 const NamedDecl *oldDef = llvm::dyn_cast_or_null<NamedDecl>(cci->
GetDecl());
6643 if (!oldDef || (def && def != oldDef)) {
6657 if (!alias && def !=
nullptr)
6680 const TagDecl *td = dyn_cast<TagDecl>(ND);
6681 const NamespaceDecl *
ns = dyn_cast<NamespaceDecl>(ND);
6682 const NamedDecl *canon =
nullptr;
6687 canon = tdDef = td->getDefinition();
6691 if (!tdDef->isCompleteDefinition() || llvm::isa<clang::FunctionDecl>(tdDef->getDeclContext())) {
6697 auto declName = tdDef->getNameAsString();
6708 clang::QualType
type(tdDef->getTypeForDecl(), 0);
6711 canon =
ns->getCanonicalDecl();
6712 name = ND->getQualifiedNameAsString();
6714 name = ND->getQualifiedNameAsString();
6763 std::set<TClass*> modifiedTClasses;
6768 bool isTUTransaction =
false;
6769 if (!
T.empty() &&
T.decls_begin() + 1 ==
T.decls_end() && !
T.hasNestedTransactions()) {
6770 clang::Decl* FirstDecl = *(
T.decls_begin()->m_DGR.begin());
6771 if (llvm::isa<clang::TranslationUnitDecl>(FirstDecl)) {
6774 isTUTransaction =
true;
6778 std::set<const void*> TransactionDeclSet;
6779 if (!isTUTransaction &&
T.decls_end() -
T.decls_begin()) {
6780 const clang::Decl* WrapperFD =
T.getWrapperFD();
6781 for (cling::Transaction::const_iterator
I =
T.decls_begin(),
E =
T.decls_end();
6783 if (
I->m_Call != cling::Transaction::kCCIHandleTopLevelDecl
6784 &&
I->m_Call != cling::Transaction::kCCIHandleTagDeclDefinition)
6787 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
6788 DE =
I->m_DGR.end(); DI != DE; ++DI) {
6789 if (*DI == WrapperFD)
6791 TransactionDeclSet.insert(*DI);
6792 ((
TCling*)
gCling)->HandleNewDecl(*DI,
false, modifiedTClasses);
6799 for (cling::Transaction::const_iterator
I =
T.deserialized_decls_begin(),
6800 E =
T.deserialized_decls_end();
I !=
E; ++
I) {
6801 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
6802 DE =
I->m_DGR.end(); DI != DE; ++DI)
6803 if (TransactionDeclSet.find(*DI) == TransactionDeclSet.end()) {
6819 std::vector<TClass*> modifiedTClassesDiff(modifiedTClasses.size());
6820 std::vector<TClass*>::iterator it;
6821 it = set_difference(modifiedTClasses.begin(), modifiedTClasses.end(),
6824 modifiedTClassesDiff.begin());
6825 modifiedTClassesDiff.resize(it - modifiedTClassesDiff.begin());
6828 ((
TCling*)
gCling)->GetModTClasses().insert(modifiedTClassesDiff.begin(),
6829 modifiedTClassesDiff.end());
6830 for (std::vector<TClass*>::const_iterator
I = modifiedTClassesDiff.begin(),
6831 E = modifiedTClassesDiff.end();
I !=
E; ++
I) {
6833 if (!
gROOT->GetListOfClasses()->FindObject(*
I)) {
6855 cling::Transaction::const_nested_iterator iNested =
T.nested_begin();
6856 for (cling::Transaction::const_iterator
I =
T.decls_begin(),
E =
T.decls_end();
6858 if (
I->m_Call == cling::Transaction::kCCIHandleVTable)
6860 if (
I->m_Call == cling::Transaction::kCCINone) {
6866 for (
auto &D :
I->m_DGR)
6892 if (D->isFromASTFile())
6900 if (isa<VarDecl>(D) || isa<FieldDecl>(D) || isa<EnumConstantDecl>(D)) {
6906 }
else if (isa<FunctionDecl>(D)) {
6908 }
else if (isa<FunctionTemplateDecl>(D)) {
6910 }
else if (isa<EnumDecl>(D)) {
6921 }
else if (isa<RecordDecl>(D) || isa<NamespaceDecl>(D)) {
6922 if (isa<RecordDecl>(D) && !cast<RecordDecl>(D)->isCompleteDefinition())
6925 std::vector<TClass *> Classes;
6928 for (
auto &
C : Classes) {
6933 for (
auto &
I : cast<DeclContext>(D)->decls())
6937 if (D->getKind() != Decl::Namespace
6938 || cast<NamespaceDecl>(D)->isOriginalNamespace())
6939 C->ResetClassInfo();
6951 std::size_t normNameHash = triter->second;
6957 auto const &hNamesPtrs = iter->second;
6958 for (
auto &hName : hNamesPtrs) {
6960 Info(
"TransactionRollback",
6961 "Restoring ability to autoaparse: %s", hName);
6996 using namespace clang;
6997 if (
const Decl *D = LH.findScope(cls, cling::LookupHelper::NoDiagnostics,
6999 if (!D->isFromASTFile()) {
7001 Warning(
"GetClassSharedLibsForModule",
"Decl found for %s is not part of a module", cls);
7004 class ModuleCollector :
public ConstDeclVisitor<ModuleCollector> {
7005 llvm::DenseSet<Module *> &m_TopLevelModules;
7008 ModuleCollector(llvm::DenseSet<Module *> &TopLevelModules) : m_TopLevelModules(TopLevelModules) {}
7009 void Collect(
const Decl *D) { Visit(D); }
7011 void VisitDecl(
const Decl *D)
7021 if (!D->hasOwningModule())
7023 if (Module *M = D->getOwningModule()->getTopLevelModule())
7024 m_TopLevelModules.insert(M);
7027 void VisitTemplateArgument(
const TemplateArgument &TA)
7029 switch (TA.getKind()) {
7031 case TemplateArgument::Integral:
7032 case TemplateArgument::Pack:
7033 case TemplateArgument::NullPtr:
7034 case TemplateArgument::Expression:
7035 case TemplateArgument::Template:
7036 case TemplateArgument::TemplateExpansion:
return;
7038 if (
const TagType *TagTy = dyn_cast<TagType>(TA.getAsType()))
7039 return Visit(TagTy->getDecl());
7041 case TemplateArgument::Declaration:
return Visit(TA.getAsDecl());
7043 llvm_unreachable(
"Invalid TemplateArgument::Kind!");
7046 void VisitClassTemplateSpecializationDecl(
const ClassTemplateSpecializationDecl *CTSD)
7048 if (CTSD->getOwningModule())
7051 VisitDecl(CTSD->getSpecializedTemplate());
7052 const TemplateArgumentList &ArgList = CTSD->getTemplateArgs();
7053 for (
const TemplateArgument *Arg = ArgList.data(), *ArgEnd = Arg + ArgList.size(); Arg != ArgEnd; ++Arg) {
7054 VisitTemplateArgument(*Arg);
7059 llvm::DenseSet<Module *> TopLevelModules;
7060 ModuleCollector
m(TopLevelModules);
7063 for (
auto M : TopLevelModules) {
7066 if (!M->LinkLibraries.size())
7069 if (M->Name ==
"Core")
7071 assert(M->LinkLibraries.size() == 1);
7072 if (!result.empty())
7074 result += M->LinkLibraries[0].Library;
7090 llvm::StringRef className = cls;
7096 if (className.contains(
"(lambda)"))
7100 cling::LookupHelper &LH =
fInterpreter->getLookupHelper();
7102 if (!libs.empty()) {
7108 if (!cls || !*cls) {
7116 const char* libs = libs_record->
GetValue();
7117 return (*libs) ? libs : 0;
7124 c.ReplaceAll(
"::",
"@@");
7127 c.ReplaceAll(
" ",
"-");
7134 const char* libs = libs_record->
GetValue();
7135 return (*libs) ? libs : 0;
7149 cling::Interpreter *interp,
7150 bool skipLoadedLibs =
true)
7153 if (!llvm::sys::path::is_absolute(lib)) {
7155 Error(
"TCling__GetSharedLibImmediateDepsSlow",
"Cannot find library '%s'", lib.c_str());
7159 lib = llvm::sys::path::filename(lib);
7162 auto ObjF = llvm::object::ObjectFile::createObjectFile(LibFullPath.
Data());
7164 Warning(
"TCling__GetSharedLibImmediateDepsSlow",
"Failed to read object file %s", lib.c_str());
7168 llvm::object::ObjectFile *BinObjFile = ObjF.get().getBinary();
7170 std::set<string> DedupSet;
7171 std::string Result = lib +
' ';
7172 for (
const auto &
S : BinObjFile->symbols()) {
7173 uint32_t Flags =
S.getFlags();
7174 if (Flags & llvm::object::SymbolRef::SF_Undefined) {
7175 llvm::Expected<StringRef> SymNameErr =
S.getName();
7177 Warning(
"GetSharedLibDepsForModule",
"Failed to read symbol");
7180 llvm::StringRef SymName = SymNameErr.get();
7181 if (SymName.empty())
7184 if (BinObjFile->isELF()) {
7188 if (SymName.contains(
"@@GLIBCXX") || SymName.contains(
"@@CXXABI") ||
7189 SymName.contains(
"@@GLIBC") || SymName.contains(
"@@GCC"))
7197 if (SymName ==
"_Jv_RegisterClasses" ||
7198 SymName ==
"_ITM_deregisterTMCloneTable" ||
7199 SymName ==
"_ITM_registerTMCloneTable")
7204 if (skipLoadedLibs && llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(SymName))
7213 if (!found.empty()) {
7214 std::string cand = llvm::sys::path::filename(found).str();
7215 if (!DedupSet.insert(cand).second)
7218 Result += cand +
' ';
7239 if (!libs.empty()) {
7245 if (!
fMapfile || !lib || !lib[0]) {
7255 size_t len = libname.
Length();
7256 while ((rec = (
TEnvRec*) next())) {
7257 const char* libs = rec->
GetValue();
7258 if (!strncmp(libs, libname.
Data(), len) && strlen(libs) >= len
7259 && (!libs[len] || libs[len] ==
' ' || libs[len] ==
'.')) {
7272#if defined(R__MUST_REVISIT)
7273#if R__MUST_REVISIT(6,2)
7274 Warning(
"IsErrorMessagesEnabled",
"Interface not available yet.");
7286#if defined(R__MUST_REVISIT)
7287#if R__MUST_REVISIT(6,2)
7288 Warning(
"SetErrorMessages",
"Interface not available yet.");
7304 llvm::SmallVector<std::string, 10> includePaths;
7306 fInterpreter->GetIncludePaths(includePaths,
false,
true);
7307 if (
const size_t nPaths = includePaths.size()) {
7308 assert(!(nPaths & 1) &&
"GetIncludePath, number of paths and options is not equal");
7310 for (
size_t i = 0; i < nPaths; i += 2) {
7315 if (includePaths[i] !=
"-I")
7349 assert(fout != 0 &&
"DisplayIncludePath, 'fout' parameter is null");
7351 llvm::SmallVector<std::string, 10> includePaths;
7353 fInterpreter->GetIncludePaths(includePaths,
false,
true);
7354 if (
const size_t nPaths = includePaths.size()) {
7355 assert(!(nPaths & 1) &&
"DisplayIncludePath, number of paths and options is not equal");
7357 std::string allIncludes(
"include path:");
7358 for (
size_t i = 0; i < nPaths; i += 2) {
7360 allIncludes += includePaths[i];
7362 if (includePaths[i] !=
"-I")
7364 allIncludes += includePaths[i + 1];
7367 fprintf(fout,
"%s\n", allIncludes.c_str());
7386#if defined(R__MUST_REVISIT)
7387#if R__MUST_REVISIT(6,2)
7388 Warning(
"GenericError",
"Interface not available yet.");
7416#if defined(R__MUST_REVISIT)
7417#if R__MUST_REVISIT(6,2)
7418 Warning(
"GetSecurityError",
"Interface not available yet.");
7429 cling::Interpreter::CompilationResult compRes;
7431 return compRes == cling::Interpreter::kFailure;
7450 TTHREAD_TLS_DECL(std::string,buffer);
7451 ROOT::TMetaUtils::GetCppName(buffer,
name);
7452 return buffer.c_str();
7533#if defined(R__MUST_REVISIT)
7534#if R__MUST_REVISIT(6,2)
7535 Warning(
"SetErrmsgcallback",
"Interface not available yet.");
7553 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
7554 std::string canonical = DLM->lookupLibrary(path);
7555 if (canonical.empty()) {
7559 cling::Interpreter::CompilationResult compRes;
7561 return compRes == cling::Interpreter::kFailure;
7565 return std::unique_ptr<TInterpreterValue>(
new TClingValue);
7572 std::vector<std::string>& completions)
7583 return compRes!=cling::Interpreter::kSuccess ? 0 : 1 ;
7590 using namespace cling;
7604 if (value.isValid() && value.needsManagedAllocation()) {
7625 auto iSpecObj = iSpecObjMap->second.find(
Name);
7626 if (iSpecObj != iSpecObjMap->second.end()) {
7628 return iSpecObj->second;
7635 ASTContext&
C = SemaR.getASTContext();
7636 Preprocessor &PP = SemaR.getPreprocessor();
7638 Preprocessor::CleanupAndRestoreCacheRAII cleanupRAII(PP);
7639 Parser::ParserCurTokRestoreRAII savedCurToken(
P);
7642 Token& Tok =
const_cast<Token&
>(
P.getCurToken());
7643 Tok.setKind(tok::semi);
7649 Sema::ContextAndScopeRAII pushedDCAndS(SemaR,
C.getTranslationUnitDecl(),
7655 Error(
"GetObjectAddress",
"Got a special object without LookupCtx!");
7669 clang::CXXRecordDecl* klass)
const
7671 using namespace clang;
7672 ASTContext& Ctx = klass->getASTContext();
7673 FriendDecl::FriendUnion friendUnion(
function);
7676 FriendDecl* friendDecl = FriendDecl::Create(Ctx, klass, sl, friendUnion, sl);
7677 klass->pushFriendDecl(friendDecl);
7691 if (func)
return ((
TClingCallFunc*)func)->GetDecl()->getCanonicalDecl();
7762 f->Exec(address, &val);
7770 f->ExecWithReturn(address, ret);
7776 const void* args[] ,
7781 f->ExecWithArgsAndReturn(address, args, nargs, ret);
7789 return f->ExecInt(address);
7797 return f->ExecInt64(address);
7805 return f->ExecDouble(address);
7828 return (MethodInfo_t*)
f->FactoryMethod();
7836 f->IgnoreExtraArgs(ignore);
7853 return f->IsValid();
7862 return f->IFacePtr();
7926 f->SetArgArray(paramArr, nparam);
7943 f->SetFunc(ci, method, params, offset);
7952 f->SetFunc(ci, method, params, objectIsConst, offset);
7970 f->SetFuncProto(ci, method,
proto, offset, mode);
7980 f->SetFuncProto(ci, method,
proto, objectIsConst, offset, mode);
7990 llvm::SmallVector<clang::QualType, 4> funcProto;
7991 for (std::vector<TypeInfo_t*>::const_iterator iter =
proto.begin(), end =
proto.end();
7992 iter != end; ++iter) {
7993 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
7995 f->SetFuncProto(ci, method, funcProto, offset, mode);
8005 llvm::SmallVector<clang::QualType, 4> funcProto;
8006 for (std::vector<TypeInfo_t*>::const_iterator iter =
proto.begin(), end =
proto.end();
8007 iter != end; ++iter) {
8008 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
8010 f->SetFuncProto(ci, method, funcProto, objectIsConst, offset, mode);
8016 std::string wrapper_name;
8017 std::string wrapper;
8018 f->get_wrapper_code(wrapper_name, wrapper);
8034 if (!declid)
return kFALSE;
8036 const clang::Decl *scope;
8038 else scope =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
8040 const clang::Decl *decl =
reinterpret_cast<const clang::Decl*
>(declid);
8041 const clang::DeclContext *ctxt = clang::Decl::castToDeclContext(scope);
8042 if (!decl || !ctxt)
return kFALSE;
8043 if (decl->getDeclContext()->Equals(ctxt))
8045 else if ((decl->getDeclContext()->isTransparentContext()
8046 || decl->getDeclContext()->isInlineNamespace())
8047 && decl->getDeclContext()->getParent()->Equals(ctxt))
8160 TClinginfo->
Init(tagnum);
8233 return TClinginfo->
Next();
8281 return TClinginfo->
Size();
8289 return TClinginfo->
Tagnum();
8305 TTHREAD_TLS_DECL(std::string,
output);
8315 return TClinginfo->
Name();
8323 return TClinginfo->
Title();
8360 ClassInfo_t* base)
const
8373 return TClinginfo->
Next();
8381 return TClinginfo->
Next(onlyDirect);
8389 return TClinginfo->
Offset(address, isDerivedObject);
8402 return TClinginfo->
GetBaseOffset(TClinginfoBase, address, isDerivedObject);
8418 return (ClassInfo_t *)TClinginfo->
GetBase();
8426 return TClinginfo->
Tagnum();
8434 TTHREAD_TLS_DECL(std::string,
output);
8444 return TClinginfo->
Name();
8489 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
8490 const clang::ValueDecl* vd = llvm::dyn_cast_or_null<clang::ValueDecl>(decl);
8523 return TClinginfo->
Next();
8531 return TClinginfo->
Offset();
8579 return TClinginfo->
Name();
8587 return TClinginfo->
Title();
8594 TTHREAD_TLS_DECL(std::string,result);
8598 return result.c_str();
8605 Decl* decl =
static_cast<Decl*
>(
const_cast<void*
>(declId));
8606 ASTContext &
C = decl->getASTContext();
8607 SourceRange commentRange;
8608 decl->addAttr(
new (
C) AnnotateAttr( commentRange,
C, attribute, 0 ) );
8619 cling::Interpreter &interp,
8620 const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt)
8622 const clang::TypeDecl* td = llvm::dyn_cast<clang::TypeDecl>(decl->getDeclContext());
8625 clang::QualType qualType(td->getTypeForDecl(),0);
8627 unsigned int level = 0;
8628 for(
size_t cursor =
name.length()-1; cursor != 0; --cursor) {
8629 if (
name[cursor] ==
'>') ++level;
8630 else if (
name[cursor] ==
'<' && level) --level;
8631 else if (level == 0 &&
name[cursor] ==
':') {
8632 name.erase(0,cursor+1);
8643 if (llvm::isa<clang::CXXConstructorDecl>(decl))
8647 }
else if (llvm::isa<clang::CXXDestructorDecl>(decl))
8652 llvm::raw_string_ostream stream(
output);
8653 auto printPolicy = decl->getASTContext().getPrintingPolicy();
8655 printPolicy.AnonymousTagLocations =
false;
8656 decl->getNameForDiagnostic(stream, printPolicy,
false);
8686 return (FuncTempInfo_t*)
const_cast<void*
>(declid);
8697 return (FuncTempInfo_t*)ft_info;
8717 if (!ft_info)
return 0;
8718 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
8719 return ft->getTemplateParameters()->size();
8728 if (!ft_info)
return 0;
8729 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
8730 return ft->getTemplateParameters()->getMinRequiredArguments();
8738 if (!ft_info)
return 0;
8743 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
8745 switch (ft->getAccess()) {
8746 case clang::AS_public:
8749 case clang::AS_protected:
8752 case clang::AS_private:
8755 case clang::AS_none:
8756 if (ft->getDeclContext()->isNamespace())
8764 const clang::FunctionDecl *fd = ft->getTemplatedDecl();
8765 if (
const clang::CXXMethodDecl *md =
8766 llvm::dyn_cast<clang::CXXMethodDecl>(fd)) {
8767 if (md->getTypeQualifiers() & clang::Qualifiers::Const) {
8770 if (md->isVirtual()) {
8776 if (
const clang::CXXConstructorDecl *cd =
8777 llvm::dyn_cast<clang::CXXConstructorDecl>(md)) {
8778 if (cd->isExplicit()) {
8782 else if (
const clang::CXXConversionDecl *cd =
8783 llvm::dyn_cast<clang::CXXConversionDecl>(md)) {
8784 if (cd->isExplicit()) {
8798 if (!ft_info)
return 0;
8803 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
8804 const clang::FunctionDecl *fd = ft->getTemplatedDecl();
8806 if (fd->isOverloadedOperator())
8808 if (llvm::isa<clang::CXXConversionDecl>(fd))
8810 if (llvm::isa<clang::CXXConstructorDecl>(fd))
8812 if (llvm::isa<clang::CXXDestructorDecl>(fd))
8814 if (fd->isInlined())
8825 if (!ft_info)
return;
8826 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
8838 if (!ft_info)
return;
8839 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
8843 if (
const RedeclarableTemplateDecl *AnnotFD
8844 = ROOT::TMetaUtils::GetAnnotatedRedeclarable((
const RedeclarableTemplateDecl*)ft)) {
8845 if (AnnotateAttr *
A = AnnotFD->getAttr<AnnotateAttr>()) {
8846 output =
A->getAnnotation().str();
8850 if (!ft->isFromASTFile()) {
8854 output = ROOT::TMetaUtils::GetComment(*ft).str();
8900 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
8902 const clang::FunctionDecl* fd = llvm::dyn_cast_or_null<clang::FunctionDecl>(decl);
8934 return info->
NArg();
8950 return info->
Next();
8974 return (TypeInfo_t*)info->
Type();
8982 TTHREAD_TLS_DECL(
TString, mangled_name);
8984 return mangled_name;
9000 return info->
Name();
9027 return info->
Title();
9035 return MethodInfo_MethodCallReturnType(func->fInfo);
9037 return EReturnType::kOther;
9046 if (info && info->
IsValid()) {
9048 clang::QualType QT( typeinfo->
GetQualType().getCanonicalType() );
9049 if (QT->isEnumeralType()) {
9050 return EReturnType::kLong;
9051 }
else if (QT->isPointerType()) {
9053 QT = llvm::cast<clang::PointerType>(QT)->getPointeeType();
9054 if ( QT->isCharType() ) {
9055 return EReturnType::kString;
9057 return EReturnType::kOther;
9059 }
else if ( QT->isFloatingType() ) {
9060 int sz = typeinfo->
Size();
9061 if (sz == 4 || sz == 8) {
9063 return EReturnType::kDouble;
9065 return EReturnType::kOther;
9067 }
else if ( QT->isIntegerType() ) {
9068 int sz = typeinfo->
Size();
9077 return EReturnType::kLong;
9079 return EReturnType::kOther;
9082 return EReturnType::kOther;
9085 return EReturnType::kOther;
9121 return (MethodArgInfo_t*)
9138 return info->
Next();
9162 return info->
Name();
9238 return TClinginfo->
Name();
9262 return TClinginfo->
Size();
9312 const char*
name)
const
9332 return TClinginfo->
Next();
9348 return TClinginfo->
Size();
9364 return TClinginfo->
Name();
9372 return TClinginfo->
Title();
9381 Error(
"SnapshotMutexState",
"fRecurseCount != 0 even though initial mutex state is unset!");
9397 Error(
"ForgetMutexState",
"mutex state's recurse count already 0!");
9414 std::unique_ptr<TVirtualRWMutex::StateDelta> uniqueP{typedDelta};
9431 return uniqueP.release();
The file contains utilities which are foundational and could be used across the core component of ROO...
#define R(a, b, c, d, e, f, g, h, i)
unsigned long long ULong64_t
TClass *(* DictFuncPtr_t)()
R__EXTERN TApplication * gApplication
R__EXTERN TClassTable * gClassTable
static void indent(ostringstream &buf, int indent_level)
The file contains facilities to work with C++ module files extensions used to store rdict files.
static bool requiresRootMap(const char *rootmapfile, cling::Interpreter *interp)
static void * LazyFunctionCreatorAutoloadForModule(const std::string &mangled_name, cling::Interpreter *interp)
static std::string ResolveSymbol(const std::string &mangled_name, cling::Interpreter *interp, bool searchSystem=true)
void TCling__RestoreInterpreterMutex(void *delta)
Re-apply the lock count delta that TCling__ResetInterpreterMutex() caused.
void TCling__FindLoadedLibraries(std::vector< std::pair< uint32_t, std::string > > &sLibraries, std::vector< std::string > &sPaths, cling::Interpreter &interpreter, bool searchSystem)
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 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)
static std::string GetModuleNameAsString(clang::Module *M, const clang::Preprocessor &PP)
ETupleOrdering
Check in what order the member of a tuple are layout.
bool TCling__LibraryLoadingFailed(const std::string &errmessage, const std::string &libStem, bool permanent, bool resolved)
Lookup libraries in LD_LIBRARY_PATH and DYLD_LIBRARY_PATH with mangled_name, which is extracted by er...
static const std::unordered_set< std::string > gIgnoredPCMNames
List of dicts that have the PCM information already in the PCH.
static Bool_t s_IsLibraryLoaded(const char *libname, cling::Interpreter *fInterpreter)
static std::string AlternateTuple(const char *classname, const cling::LookupHelper &lh)
R__DLLEXPORT void TCling__DEBUG__printName(clang::Decl *D)
R__DLLEXPORT void TCling__DEBUG__decl_dump(void *D)
bool TClingLookupHelper__ExistingTypeCheck(const std::string &tname, std::string &result)
Try hard to avoid looking up in the Cling database as this could enduce an unwanted autoparsing.
R__DLLEXPORT clang::NamespaceDecl * TCling__DEBUG__DCtoNamespace(clang::DeclContext *DC)
void TCling__UnlockCompilationDuringUserCodeExecution(void *)
Unlock the interpreter.
const char * TCling__GetClassSharedLibs(const char *className)
static uint32_t GNUHash(StringRef S)
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)
static void ConstructorName(std::string &name, const clang::NamedDecl *decl, cling::Interpreter &interp, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt)
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)
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 std::string FindLibraryName(void(*func)())
Wrapper around dladdr (and friends)
int TCling__AutoLoadCallback(const char *className)
static bool LoadModule(const std::string &ModuleName, cling::Interpreter &interp)
static void RegisterCxxModules(cling::Interpreter &clingInterp)
static bool IsFromRootCling()
void TCling__PrintStackTrace()
Print a StackTrace!
static bool FindSymbol(const std::string &library_filename, const std::string &mangled_name, unsigned IgnoreSymbolFlags=0)
Looks up symbols from a an object file, representing the library.
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 bool MayExistInObjectFile(llvm::object::ObjectFile *soFile, uint32_t hash)
Bloom filter in a stohastic data structure which can tell us if a symbol name does not exist in a lib...
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 StringRef GetGnuHashSection(llvm::object::ObjectFile *file)
TObject * TCling__GetObjectAddress(const char *Name, void *&LookupCtx)
static void LoadModules(const std::vector< std::string > &modules, cling::Interpreter &interp)
Loads the C++ modules that we require to run any ROOT program.
int TCling__IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *nsDecl)
void TCling__SplitAclicMode(const char *fileName, string &mode, string &args, string &io, string &fname)
void Info(const char *location, const char *msgfmt,...)
void Error(const char *location, const char *msgfmt,...)
R__EXTERN Int_t gErrorIgnoreLevel
void Warning(const char *location, const char *msgfmt,...)
void Fatal(const char *location, const char *msgfmt,...)
R__EXTERN TVirtualMutex * gInterpreterMutex
#define R__LOCKGUARD_CLING(mutex)
R__EXTERN TInterpreter * gCling
char * Form(const char *fmt,...)
typedef void((*Func_t)())
Bool_t R_ISREG(Int_t mode)
R__EXTERN TSystem * gSystem
R__EXTERN TVirtualMutex * gGlobalMutex
#define R__LOCKGUARD(mutex)
#define R__WRITE_LOCKGUARD(mutex)
#define R__READ_LOCKGUARD(mutex)
virtual std::unique_ptr< StateDelta > Rewind(const State &earlierState)=0
virtual void Apply(std::unique_ptr< StateDelta > &&delta)=0
virtual std::unique_ptr< State > GetStateBefore()=0
static Long_t ExecuteFile(const char *file, Int_t *error=0, Bool_t keep=kFALSE)
Execute a file containing a C++ macro (static method).
virtual TApplicationImp * GetApplicationImp()
virtual Bool_t IsCmdThread()
Each class (see TClass) has a linked list of its base class(es).
TClassRef is used to implement a permanent reference to a TClass object.
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
static TProtoClass * GetProtoNorm(const char *cname)
Given the class normalized name returns the TClassProto object for the class.
static DictFuncPtr_t GetDictNorm(const char *cname)
Given the normalized class name returns the Dictionary() function of a class (uses hash of name).
static TProtoClass * GetProto(const char *cname)
Given the class name returns the TClassProto object for the class.
static Bool_t Check(const char *cname, std::string &normname)
static void Add(const char *cname, Version_t id, const std::type_info &info, DictFuncPtr_t dict, Int_t pragmabits)
Add a class to the class table (this is a static function).
TClass instances represent classes, structs and namespaces in the ROOT type system.
TDataMember * GetDataMember(const char *datamember) const
Return pointer to datamember object with name "datamember".
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
EState fState
cached of the streaming method to use
std::atomic< TList * > fBase
static void AddClassToDeclIdMap(TDictionary::DeclId_t id, TClass *cl)
static: Add a TClass* to the map of classes.
TList * GetListOfFunctionTemplates(Bool_t load=kTRUE)
Return list containing the TEnums of a class.
void * DynamicCast(const TClass *base, void *obj, Bool_t up=kTRUE)
Cast obj of this class type up to baseclass cl if up is true.
static void RemoveClassDeclId(TDictionary::DeclId_t id)
Bool_t CallShowMembers(const void *obj, TMemberInspector &insp, Bool_t isTransient=kFALSE) const
Call ShowMembers() on the obj of this class type, passing insp and parent.
std::atomic< TListOfEnums * > fEnums
static Bool_t HasNoInfoOrEmuOrFwdDeclaredDecl(const char *)
virtual void PostLoadCheck()
Do the initialization that can only be done after the CINT dictionary has been fully populated and ca...
static TClass * LoadClass(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
Int_t Size() const
Return size of object of this class.
TObjArray * fStreamerInfo
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
ClassInfo_t * GetClassInfo() const
Long_t Property() const
Set TObject::fBits and fStreamerType to cache information about the class.
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
void ResetCaches()
To clean out all caches.
static Int_t ReadRules()
Read the class.rules files from the default location:.
Version_t GetClassVersion() const
std::atomic< Bool_t > fHasRootPcmInfo
C++ Property of the class (is abstract, has virtual table, etc.)
const char * GetDeclFileName() const
Return name of the file containing the declaration of this class.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Emulation of the CINT BaseClassInfo class.
const char * TmpltName() const
const char * Name() const
ptrdiff_t Offset(void *address=0, bool isDerivedObject=true) const
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
TClingClassInfo * GetBase() const
Emulation of the CINT CallFunc class.
long ExecInt(void *address)
void SetArgs(const char *args)
void SetFunc(const TClingClassInfo *info, const char *method, const char *arglist, long *poffset)
void ExecWithArgsAndReturn(void *address, const void *args[]=0, int nargs=0, void *ret=0)
void Exec(void *address, TInterpreterValue *interpVal=0)
TClingMethodInfo * FactoryMethod() const
void SetAutoloadingEnabled(bool val=true)
bool IsAutoloadingEnabled()
void SetAutoParsingSuspended(bool val=true)
Emulation of the CINT ClassInfo class.
bool HasDefaultConstructor() const
static bool IsEnum(cling::Interpreter *interp, const char *name)
long ClassProperty() const
void Init(const char *name)
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
EDataType GetUnderlyingType() const
TClingMethodInfo GetMethodWithArgs(const char *fname, const char *arglist, long *poffset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch, EInheritanceMode imode=kWithInheritance) const
const char * TmpltName() const
const clang::Type * GetType() const
ptrdiff_t GetBaseOffset(TClingClassInfo *toBase, void *address, bool isDerivedObject)
bool IsScopedEnum() const
const clang::FunctionTemplateDecl * GetFunctionTemplate(const char *fname) const
int GetMethodNArg(const char *method, const char *proto, Bool_t objectIsConst, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
bool HasMethod(const char *name) const
TDictionary::DeclId_t GetDeclId() const
void DeleteArray(void *arena, bool dtorOnly, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
void * New(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
bool IsValidMethod(const char *method, const char *proto, Bool_t objectIsConst, long *offset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
TClingMethodInfo GetMethod(const char *fname) const
const clang::ValueDecl * GetDataMember(const char *name) const
void Destruct(void *arena, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
std::vector< std::string > GetUsingNamespaces()
bool IsBase(const char *name) const
void Delete(void *arena, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Emulation of the CINT DataMemberInfo class.
const char * TypeName() const
const char * TypeTrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
const char * Name() override
int MaxIndex(int dim) const
llvm::StringRef ValidArrayIndex() const
long TypeProperty() const
virtual const char * Name()
virtual bool IsValid() const
virtual const clang::Decl * GetDecl() const
Emulation of the CINT MethodInfo class.
bool IsValid() const override
const char * DefaultValue() const
const TClingTypeInfo * Type() const
const char * TypeName() const
Emulation of the CINT MethodInfo class.
const char * Name() override
std::string GetMangledName() const
const char * TypeName() const
void * InterfaceMethod(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
const char * GetPrototype()
const clang::FunctionDecl * GetMethodDecl() const
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
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 * Name() override
Get the name of the current typedef.
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.
void Init(const char *name)
Lookup named typedef and reset the iterator to point to it.
int Next()
Increment the iterator.
int Size() const
Return the size in bytes of the underlying type of the current typedef.
Bridge between cling::Value and ROOT.
bool Append(const std::string &str)
Append string to the storage if not added already.
This class defines an interface to the cling C++ interpreter.
virtual const char * MethodArgInfo_DefaultValue(MethodArgInfo_t *marginfo) const
virtual std::string CallFunc_GetWrapperCode(CallFunc_t *func) const
virtual void FuncTempInfo_Name(FuncTempInfo_t *, TString &name) const
Return the name of this function template.
virtual void FuncTempInfo_Title(FuncTempInfo_t *, TString &name) const
Return the comments associates with this function template.
virtual int TypedefInfo_Next(TypedefInfo_t *tinfo) const
virtual bool DiagnoseIfInterpreterException(const std::exception &e) const
virtual bool ClassInfo_IsValid(ClassInfo_t *info) const
virtual bool ClassInfo_IsScopedEnum(ClassInfo_t *info) const
Long_t Calc(const char *line, EErrorCode *error=0)
Directly execute an executable statement (e.g.
Bool_t HasPCMForLibrary(const char *libname) const
Return true if ROOT has cxxmodules pcm for a given library name.
virtual MethodInfo_t * MethodInfo_FactoryCopy(MethodInfo_t *minfo) const
virtual const char * TypeInfo_Name(TypeInfo_t *) const
DeclId_t GetFunction(ClassInfo_t *cl, const char *funcname)
Return pointer to cling interface function for a method of a class with a certain name.
bool LibraryLoadingFailed(const std::string &, const std::string &, bool, bool)
virtual bool ClassInfo_HasMethod(ClassInfo_t *info, const char *name) const
std::vector< void * > fRegisterModuleDyLibs
virtual MethodInfo_t * CallFunc_FactoryMethod(CallFunc_t *func) const
virtual bool MethodInfo_IsValid(MethodInfo_t *minfo) const
std::vector< std::string > fAutoLoadLibStorage
virtual const char * DataMemberInfo_TypeTrueName(DataMemberInfo_t *dminfo) const
void CreateListOfDataMembers(TClass *cl) const
Create list of pointers to data members for TClass cl.
void UnRegisterTClassUpdate(const TClass *oldcl)
If the dictionary is loaded, we can remove the class from the list (otherwise the class might be load...
void HandleNewDecl(const void *DV, bool isDeserialized, std::set< TClass * > &modifiedClasses)
void InvalidateCachedDecl(const std::tuple< TListOfDataMembers *, TListOfFunctions *, TListOfFunctionTemplates *, TListOfEnums * > &Lists, const clang::Decl *D)
Invalidate cached TCling information for the given declaration, and removed it from the appropriate o...
virtual const char * MethodInfo_TypeName(MethodInfo_t *minfo) const
bool RegisterPrebuiltModulePath(const std::string &FullPath, const std::string &ModuleMapName="module.modulemap") const
virtual Long_t TypedefInfo_Property(TypedefInfo_t *tinfo) const
virtual void MethodArgInfo_Delete(MethodArgInfo_t *marginfo) const
virtual void LoadFunctionTemplates(TClass *cl) const
Create list of pointers to function templates for TClass cl.
virtual CallFunc_t * CallFunc_Factory() const
virtual TypedefInfo_t * TypedefInfo_FactoryCopy(TypedefInfo_t *tinfo) const
std::vector< const char * > fCurExecutingMacros
void UpdateListsOnCommitted(const cling::Transaction &T)
virtual void SetAllocunlockfunc(void(*)()) const
[Place holder for Mutex Unlock] Provide the interpreter with a way to release a lock used to protect ...
virtual Long_t ClassInfo_Tagnum(ClassInfo_t *info) const
void UpdateListOfTypes()
No op: see TClingCallbacks (used to update the list of types)
const char * GetSharedLibDeps(const char *lib, bool tryDyld=false)
Get the list a libraries on which the specified lib depends.
virtual DeclId_t GetDataMemberAtAddr(const void *addr) const
Return pointer to cling DeclId for a data member with a given name.
virtual int DataMemberInfo_ArrayDim(DataMemberInfo_t *dminfo) const
virtual bool ClassInfo_IsBase(ClassInfo_t *info, const char *name) const
virtual int BaseClassInfo_Next(BaseClassInfo_t *bcinfo) const
virtual void GenericError(const char *error) const
Let the interpreter issue a generic error, and set its error state.
virtual std::string MethodArgInfo_TypeNormalizedName(MethodArgInfo_t *marginfo) const
virtual const char * ClassInfo_TmpltName(ClassInfo_t *info) const
virtual TEnum * CreateEnum(void *VD, TClass *cl) const
virtual EReturnType MethodCallReturnType(TFunction *func) const
virtual int UnloadFile(const char *path) const
virtual int Evaluate(const char *, TInterpreterValue &)
Get the interpreter value corresponding to the statement.
TObject * GetObjectAddress(const char *Name, void *&LookupCtx)
If the interpreter encounters Name, check whether that is an object ROOT could retrieve.
virtual Long_t TypeInfo_Property(TypeInfo_t *tinfo) const
DeclId_t GetFunctionWithPrototype(ClassInfo_t *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Return pointer to cling interface function for a method of a class with a certain prototype,...
void InvalidateGlobal(const clang::Decl *D)
Invalidate cached TCling information for the given global declaration.
void EndOfLineAction()
It calls a "fantom" method to synchronize user keyboard input and ROOT prompt line.
DeclId_t GetFunctionWithValues(ClassInfo_t *cl, const char *method, const char *params, Bool_t objectIsConst=kFALSE)
Return pointer to cling DeclId for a method of a class with a certain prototype, i....
void UpdateListOfLoadedSharedLibraries()
void RegisterModule(const char *modulename, const char **headers, const char **includePaths, const char *payloadCode, const char *fwdDeclsCode, void(*triggerFunc)(), const FwdDeclArgsToKeepCollection_t &fwdDeclsArgToSkip, const char **classesHeaders, Bool_t lateRegistration=false, Bool_t hasCxxModule=false)
Inject the module named "modulename" into cling; load all headers.
virtual const char * DataMemberInfo_ValidArrayIndex(DataMemberInfo_t *dminfo) const
void InitRootmapFile(const char *name)
Create a resource table and read the (possibly) three resource files, i.e $ROOTSYS/etc/system<name> (...
void CreateListOfMethodArgs(TFunction *m) const
Create list of pointers to method arguments for TMethod m.
virtual void TypedefInfo_Init(TypedefInfo_t *tinfo, const char *name) const
virtual Long_t MethodInfo_ExtraProperty(MethodInfo_t *minfo) const
void LoadPCM(std::string pcmFileNameFullPath)
Tries to load a rdict PCM, issues diagnostics if it fails.
virtual ~TCling()
Destroy the interpreter interface.
void AddFriendToClass(clang::FunctionDecl *, clang::CXXRecordDecl *) const
Inject function as a friend into klass.
std::vector< MutexStateAndRecurseCount > fInitialMutex
Bool_t fCxxModulesEnabled
void RefreshClassInfo(TClass *cl, const clang::NamedDecl *def, bool alias)
Internal function. Actually do the update of the ClassInfo when seeing.
void ExecuteWithArgsAndReturn(TMethod *method, void *address, const void *args[]=0, int nargs=0, void *ret=0) const
virtual void FuncTempInfo_Delete(FuncTempInfo_t *) const
Delete the FuncTempInfo_t.
Bool_t SetSuspendAutoParsing(Bool_t value)
Suspend the Autoparsing of headers.
virtual DataMemberInfo_t * DataMemberInfo_FactoryCopy(DataMemberInfo_t *dminfo) const
virtual CallFuncIFacePtr_t CallFunc_IFacePtr(CallFunc_t *func) const
virtual void CallFunc_ExecWithReturn(CallFunc_t *func, void *address, void *ret) const
virtual MethodArgInfo_t * MethodArgInfo_Factory() const
virtual void DataMemberInfo_Delete(DataMemberInfo_t *dminfo) const
void ApplyToInterpreterMutex(void *delta)
Re-apply the lock count delta that TCling__ResetInterpreterMutex() caused.
void * LazyFunctionCreatorAutoload(const std::string &mangled_name)
Autoload a library based on a missing symbol.
virtual int LoadFile(const char *path) const
Load a source file or library called path into the interpreter.
void CodeComplete(const std::string &, size_t &, std::vector< std::string > &)
The call to Cling's tab complition.
virtual int SetClassAutoloading(int) const
Enable/Disable the Autoloading of libraries.
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 DataMemberInfo_IsValid(DataMemberInfo_t *dminfo) const
int ReadRootmapFile(const char *rootmapfile, TUniqueString *uniqueString=nullptr)
Read and parse a rootmapfile in its new format, and return 0 in case of success, -1 if the file has a...
Bool_t IsLoaded(const char *filename) const
Return true if the file has already been loaded by cint.
const char * GetSharedLibs()
Return the list of shared libraries loaded into the process.
virtual const char * GetTopLevelMacroName() const
Return the file name of the current un-included interpreted file.
std::map< SpecialObjectLookupCtx_t, SpecialObjectMap_t > fSpecialObjectMaps
virtual DeclId_t GetDataMemberWithValue(const void *ptrvalue) const
NOT IMPLEMENTED.
virtual bool MethodArgInfo_IsValid(MethodArgInfo_t *marginfo) const
Int_t ReloadAllSharedLibraryMaps()
Reload the library map entries coming from all the loaded shared libraries, after first unloading the...
virtual void SetErrmsgcallback(void *p) const
Set a callback to receive error messages.
virtual std::string ToString(const char *type, void *obj)
virtual const char * MethodInfo_Title(MethodInfo_t *minfo) const
virtual Long_t ClassInfo_GetBaseOffset(ClassInfo_t *fromDerived, ClassInfo_t *toBase, void *address, bool isDerivedObject) const
virtual int DataMemberInfo_TypeSize(DataMemberInfo_t *dminfo) const
virtual ClassInfo_t * ClassInfo_Factory(Bool_t all=kTRUE) const
virtual const char * MethodInfo_GetMangledName(MethodInfo_t *minfo) const
virtual bool CallFunc_IsValid(CallFunc_t *func) const
virtual const char * BaseClassInfo_TmpltName(BaseClassInfo_t *bcinfo) const
virtual void SetAlloclockfunc(void(*)()) const
[Place holder for Mutex Lock] Provide the interpreter with a way to acquire a lock used to protect cr...
virtual void MethodInfo_CreateSignature(MethodInfo_t *minfo, TString &signature) const
void SnapshotMutexState(ROOT::TVirtualRWMutex *mtx)
virtual Bool_t ClassInfo_Contains(ClassInfo_t *info, DeclId_t declid) const
Return true if the entity pointed to by 'declid' is declared in the context described by 'info'.
std::set< size_t > fPayloads
virtual const char * ClassInfo_Name(ClassInfo_t *info) const
Int_t UnloadLibraryMap(const char *library)
Unload library map entries coming from the specified library.
virtual ClassInfo_t * BaseClassInfo_ClassInfo(BaseClassInfo_t *) const
TObjArray * fRootmapFiles
virtual void CallFunc_Delete(CallFunc_t *func) const
virtual Long_t ClassInfo_ClassProperty(ClassInfo_t *info) const
cling::Interpreter * GetInterpreterImpl() const
virtual bool ClassInfo_IsLoaded(ClassInfo_t *info) const
std::vector< std::pair< TClass *, DictFuncPtr_t > > fClassesToUpdate
virtual int ClassInfo_GetMethodNArg(ClassInfo_t *info, const char *method, const char *proto, Bool_t objectIsConst=false, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
Int_t DeleteGlobal(void *obj)
Delete obj from Cling symbol table so it cannot be accessed anymore.
virtual const char * GetCurrentMacroName() const
Return the file name of the currently interpreted file, included or not.
virtual void TypeInfo_Delete(TypeInfo_t *tinfo) const
virtual Bool_t LoadText(const char *text) const
Load the declarations from text into the interpreter.
void GetInterpreterTypeName(const char *name, std::string &output, Bool_t full=kFALSE)
The 'name' is known to the interpreter, this function returns the internal version of this name (usua...
void * RewindInterpreterMutex()
Reset the interpreter lock to the state it had before interpreter-related calls happened.
virtual Long_t BaseClassInfo_Offset(BaseClassInfo_t *toBaseClassInfo, void *address, bool isDerivedObject) const
static Int_t DeepAutoLoadImpl(const char *cls)
virtual int GetSecurityError() const
Interface to cling function.
virtual UInt_t FuncTempInfo_TemplateMinReqArgs(FuncTempInfo_t *) const
Return the number of required template arguments of the function template described by ft_info.
void ResetGlobals()
Reset in Cling the list of global variables to the state saved by the last call to TCling::SaveGlobal...
virtual const char * ClassInfo_Title(ClassInfo_t *info) const
bool IsClassAutoloadingEnabled() const
Returns if class autoloading is currently enabled.
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
Long_t ProcessLine(const char *line, EErrorCode *error=0)
virtual void GetFunctionName(const clang::FunctionDecl *decl, std::string &name) 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.
void RewindDictionary()
Rewind Cling dictionary to the point where it was before executing the current macro.
std::map< std::string, llvm::StringRef > fPendingRdicts
virtual const char * MapCppName(const char *) const
Interface to cling function.
static void UpdateClassInfoWork(const char *name)
virtual Long_t FuncTempInfo_ExtraProperty(FuncTempInfo_t *) const
Return the property not already defined in Property See TDictionary's EFunctionProperty.
void PrintIntro()
No-op; see TRint instead.
virtual CallFunc_t * CallFunc_FactoryCopy(CallFunc_t *func) const
virtual const char * DataMemberInfo_Name(DataMemberInfo_t *dminfo) const
Bool_t Declare(const char *code)
Declare code to the interpreter, without any of the interpreter actions that could trigger a re-inter...
Int_t DeleteVariable(const char *name)
Undeclare obj called name.
virtual int ClassInfo_Next(ClassInfo_t *info) const
static void * fgSetOfSpecials
void AddIncludePath(const char *path)
Add the given path to the list of directories in which the interpreter looks for include files.
virtual void CallFunc_SetArgArray(CallFunc_t *func, Long_t *paramArr, Int_t nparam) const
virtual const char * MethodInfo_Name(MethodInfo_t *minfo) const
void ClearFileBusy()
Reset the interpreter internal state in case a previous action was not correctly terminated.
virtual const char * MethodArgInfo_Name(MethodArgInfo_t *marginfo) const
virtual Long_t ClassInfo_Property(ClassInfo_t *info) const
ROOT::TMetaUtils::TNormalizedCtxt * fNormalizedCtxt
virtual int MethodInfo_Next(MethodInfo_t *minfo) const
const char * TypeName(const char *typeDesc)
Return the absolute type of typeDesc.
void SaveContext()
Save the current Cling state.
std::set< TClass * > & GetModTClasses()
virtual bool TypeInfo_IsValid(TypeInfo_t *tinfo) const
Int_t AutoLoad(const char *classname, Bool_t knowDictNotLoaded=kFALSE)
Load library containing the specified class.
TClingCallbacks * fClingCallbacks
TString GetMangledNameWithPrototype(TClass *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Return the cling mangled name for a method of a class with a certain prototype, i....
void RegisterTClassUpdate(TClass *oldcl, DictFuncPtr_t dict)
Register classes that already existed prior to their dictionary loading and that already had a ClassI...
virtual Long_t DataMemberInfo_Property(DataMemberInfo_t *dminfo) const
void UpdateListOfGlobalFunctions()
No op: see TClingCallbacks (used to update the list of global functions)
virtual const char * MethodInfo_GetPrototype(MethodInfo_t *minfo) const
virtual bool ClassInfo_IsValidMethod(ClassInfo_t *info, const char *method, const char *proto, Long_t *offset, ROOT::EFunctionMatchMode=ROOT::kConversionMatch) const
virtual void * ClassInfo_New(ClassInfo_t *info) const
virtual void TypeInfo_Init(TypeInfo_t *tinfo, const char *funcname) const
Bool_t SetErrorMessages(Bool_t enable=kTRUE)
If error messages are disabled, the interpreter should suppress its failures and warning messages fro...
virtual const char * DataMemberInfo_Title(DataMemberInfo_t *dminfo) const
void TransactionRollback(const cling::Transaction &T)
virtual EDataType ClassInfo_GetUnderlyingType(ClassInfo_t *info) const
virtual void CallFunc_Init(CallFunc_t *func) const
virtual UInt_t FuncTempInfo_TemplateNargs(FuncTempInfo_t *) const
Return the maximum number of template arguments of the function template described by ft_info.
TString GetMangledName(TClass *cl, const char *method, const char *params, Bool_t objectIsConst=kFALSE)
Return the cling mangled name for a method of a class with parameters params (params is a string of a...
virtual void SetTempLevel(int val) const
Create / close a scope for temporaries.
virtual DeclId_t GetDataMember(ClassInfo_t *cl, const char *name) const
Return pointer to cling Decl of global/static variable that is located at the address given by addr.
void RegisterTemporary(const TInterpreterValue &value)
virtual void LoadEnums(TListOfEnums &cl) const
Create list of pointers to enums for TClass cl.
virtual void CallFunc_SetArg(CallFunc_t *func, Long_t param) const
virtual Long_t GetExecByteCode() const
This routines used to return the address of the internal wrapper function (of the interpreter) that w...
virtual void * MethodInfo_InterfaceMethod(MethodInfo_t *minfo) const
Int_t UnloadAllSharedLibraryMaps()
Unload the library map entries coming from all the loaded shared libraries.
virtual void CallFunc_IgnoreExtraArgs(CallFunc_t *func, bool ignore) const
std::vector< cling::Value > * fTemporaries
virtual Long_t MethodInfo_Property(MethodInfo_t *minfo) const
virtual std::unique_ptr< TInterpreterValue > MakeInterpreterValue() const
virtual Long_t DataMemberInfo_Offset(DataMemberInfo_t *dminfo) const
static Int_t ShallowAutoLoadImpl(const char *cls)
void LibraryLoaded(const void *dyLibHandle, const char *canonicalName)
virtual TypedefInfo_t * TypedefInfo_Factory() const
void UpdateListOfGlobals()
No op: see TClingCallbacks (used to update the list of globals)
void ClearStack()
Delete existing temporary values.
std::map< const cling::Transaction *, size_t > fTransactionHeadersMap
virtual int SetClassAutoparsing(int)
Enable/Disable the Autoparsing of headers.
Bool_t fHeaderParsingOnDemand
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
Long_t ExecuteMacro(const char *filename, EErrorCode *error=0)
Execute a cling macro.
virtual DeclId_t GetEnum(TClass *cl, const char *name) const
Return pointer to cling Decl of global/static variable that is located at the address given by addr.
void GetFunctionOverloads(ClassInfo_t *cl, const char *funcname, std::vector< DeclId_t > &res) const
Insert overloads of name in cl to res.
virtual void CallFunc_Exec(CallFunc_t *func, void *address) const
virtual int DisplayIncludePath(FILE *fout) const
Interface to cling function.
void RegisterLoadedSharedLibrary(const char *name)
Register a new shared library name with the interpreter; add it to fSharedLibs.
virtual void UpdateEnumConstants(TEnum *enumObj, TClass *cl) const
void SaveGlobalsContext()
Save the current Cling state of global objects.
std::unordered_set< const clang::NamespaceDecl * > fNSFromRootmaps
void ProcessClassesToUpdate()
virtual Long_t MethodArgInfo_Property(MethodArgInfo_t *marginfo) const
virtual const char * GetSTLIncludePath() const
Return the directory containing CINT's stl cintdlls.
Int_t LoadLibraryMap(const char *rootmapfile=0)
Load map between class and library.
virtual std::string MethodInfo_TypeNormalizedName(MethodInfo_t *minfo) const
void Execute(const char *function, const char *params, int *error=0)
Execute a global function with arguments params.
virtual const char * ClassInfo_FullName(ClassInfo_t *info) const
TClass * GenerateTClass(const char *classname, Bool_t emulation, Bool_t silent=kFALSE)
Generate a TClass for the given class.
virtual int TypeInfo_Size(TypeInfo_t *tinfo) const
virtual int MethodArgInfo_Next(MethodArgInfo_t *marginfo) const
ROOT::TMetaUtils::TClingLookupHelper * fLookupHelper
virtual bool ClassInfo_HasDefaultConstructor(ClassInfo_t *info) const
virtual const char * TypedefInfo_TrueName(TypedefInfo_t *tinfo) const
Bool_t fIsAutoParsingSuspended
TClass * GetClass(const std::type_info &typeinfo, Bool_t load) const
Demangle the name (from the typeinfo) and then request the class via the usual name based interface (...
DeclId_t GetDeclId(const llvm::GlobalValue *gv) const
Return pointer to cling DeclId for a global value.
Long_t ProcessLineAsynch(const char *line, EErrorCode *error=0)
Let cling process a command line asynch.
virtual std::vector< std::string > GetUsingNamespaces(ClassInfo_t *cl) const
Get the scopes representing using declarations of namespace.
Int_t SetClassSharedLibs(const char *cls, const char *libs)
Register the autoloading information for a class.
virtual void ClassInfo_Init(ClassInfo_t *info, const char *funcname) const
virtual TypeInfo_t * TypeInfo_FactoryCopy(TypeInfo_t *) const
Bool_t CheckClassTemplate(const char *name)
Return true if there is a class template by the given name ...
void LoadPCMImpl(TFile &pcmFile)
Tries to load a PCM from TFile; returns true on success.
Bool_t IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *nsDecl)
TObjArray * GetRootMapFiles() const
void * fPrevLoadedDynLibInfo
void UpdateListOfDataMembers(TClass *cl) const
Update the list of pointers to data members for TClass cl This is now a nop.
virtual void SetDeclAttr(DeclId_t, const char *)
virtual Long_t DataMemberInfo_TypeProperty(DataMemberInfo_t *dminfo) const
virtual const char * DataMemberInfo_TypeName(DataMemberInfo_t *dminfo) const
virtual void CallFunc_SetArgs(CallFunc_t *func, const char *param) const
virtual const char * BaseClassInfo_Name(BaseClassInfo_t *bcinfo) const
virtual void MethodInfo_Delete(MethodInfo_t *minfo) const
Interface to cling function.
virtual const char * TypeInfo_TrueName(TypeInfo_t *tinfo) const
std::set< const char * > fParsedPayloadsAddresses
ECheckClassInfo CheckClassInfo(const char *name, Bool_t autoload, Bool_t isClassOrNamespaceOnly=kFALSE)
Checks if an entity with the specified name is defined in Cling.
void EnableAutoLoading()
Enable the automatic loading of shared libraries when a class is used that is stored in a not yet loa...
static void UpdateClassInfo(char *name, Long_t tagnum)
No op: see TClingCallbacks.
virtual void BaseClassInfo_Delete(BaseClassInfo_t *bcinfo) const
void ResetGlobalVar(void *obj)
Reset the Cling 'user' global objects/variables state to the state saved by the last call to TCling::...
std::unique_ptr< cling::Interpreter > fInterpreter
Bool_t IsLibraryLoaded(const char *libname) const
virtual void Initialize()
Initialize the interpreter, once TROOT::fInterpreter is set.
virtual void * FindSym(const char *entry) const
Interface to cling function.
virtual Long_t CallFunc_ExecInt(CallFunc_t *func, void *address) const
virtual int DataMemberInfo_MaxIndex(DataMemberInfo_t *dminfo, Int_t dim) const
void SetClassInfo(TClass *cl, Bool_t reload=kFALSE)
Set pointer to the TClingClassInfo in TClass.
Long_t ProcessLineSynch(const char *line, EErrorCode *error=0)
Let cling process a command line synchronously, i.e we are waiting it will be finished.
virtual int TypeInfo_RefType(TypeInfo_t *) const
cling::MetaProcessor * GetMetaProcessorImpl() const
void LoadMacro(const char *filename, EErrorCode *error=0)
Load a macro file in cling's memory.
std::set< size_t > fLookedUpClasses
virtual void CallFunc_ResetArg(CallFunc_t *func) const
virtual Long64_t CallFunc_ExecInt64(CallFunc_t *func, void *address) const
virtual Long_t BaseClassInfo_Tagnum(BaseClassInfo_t *bcinfo) const
void ResetAll()
Reset the Cling state to its initial state.
virtual void ClassInfo_Delete(ClassInfo_t *info) const
virtual DataMemberInfo_t * DataMemberInfo_Factory(ClassInfo_t *clinfo=0) const
virtual Double_t CallFunc_ExecDouble(CallFunc_t *func, void *address) const
UInt_t AutoParseImplRecurse(const char *cls, bool topLevel)
Helper routine for TCling::AutoParse implementing the actual call to the parser and looping over temp...
virtual const char * TypedefInfo_Title(TypedefInfo_t *tinfo) const
void CreateListOfBaseClasses(TClass *cl) const
Create list of pointers to base class(es) for TClass cl.
void RecursiveRemove(TObject *obj)
Delete object from cling symbol table so it can not be used anymore.
virtual MethodArgInfo_t * MethodArgInfo_FactoryCopy(MethodArgInfo_t *marginfo) const
void UpdateListsOnUnloaded(const cling::Transaction &T)
Invalidate stored TCling state for declarations included in transaction ‘T’.
void UpdateClassInfoWithDecl(const clang::NamedDecl *ND)
Internal function. Inform a TClass about its new TagDecl or NamespaceDecl.
virtual const char * ClassInfo_FileName(ClassInfo_t *info) const
virtual void CallFunc_ExecWithArgsAndReturn(CallFunc_t *func, void *address, const void *args[]=0, int nargs=0, void *ret=0) const
DeclId_t GetFunctionTemplate(ClassInfo_t *cl, const char *funcname)
Return pointer to cling interface function for a method of a class with a certain name.
virtual int MethodInfo_NArg(MethodInfo_t *minfo) const
virtual FuncTempInfo_t * FuncTempInfo_FactoryCopy(FuncTempInfo_t *) const
Construct a FuncTempInfo_t.
virtual int TypedefInfo_Size(TypedefInfo_t *tinfo) const
std::unique_ptr< cling::MetaProcessor > fMetaProcessor
virtual const char * TypedefInfo_Name(TypedefInfo_t *tinfo) const
virtual void CallFunc_SetFuncProto(CallFunc_t *func, ClassInfo_t *info, const char *method, const char *proto, Long_t *Offset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
Interface to cling function.
virtual int DisplayClass(FILE *fout, const char *name, int base, int start) const
const char * GetClassSharedLibs(const char *cls)
Get the list of shared libraries containing the code for class cls.
Bool_t IsErrorMessagesEnabled() const
If error messages are disabled, the interpreter should suppress its failures and warning messages fro...
ULong64_t fTransactionCount
virtual Bool_t FuncTempInfo_IsValid(FuncTempInfo_t *) const
Check validity of a FuncTempInfo_t.
virtual BaseClassInfo_t * BaseClassInfo_Factory(ClassInfo_t *info) const
virtual bool TypedefInfo_IsValid(TypedefInfo_t *tinfo) const
virtual MethodInfo_t * MethodInfo_Factory() const
Int_t AutoParse(const char *cls)
Parse the headers relative to the class Returns 1 in case of success, 0 in case of failure.
virtual EReturnType MethodInfo_MethodCallReturnType(MethodInfo_t *minfo) const
void * GetInterfaceMethodWithPrototype(TClass *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Return pointer to cling interface function for a method of a class with a certain prototype,...
virtual TypeInfo_t * TypeInfo_Factory() const
std::map< size_t, std::vector< const char * > > fClassesHeadersMap
virtual int MethodInfo_NDefaultArg(MethodInfo_t *minfo) const
Int_t GenerateDictionary(const char *classes, const char *includes="", const char *options=0)
Generate the dictionary for the C++ classes listed in the first argument (in a semi-colon separated l...
virtual void CallFunc_SetFunc(CallFunc_t *func, ClassInfo_t *info, const char *method, const char *params, Long_t *Offset) const
void CreateListOfMethods(TClass *cl) const
Create list of pointers to methods for TClass cl.
void UpdateListOfMethods(TClass *cl) const
Update the list of pointers to method for TClass cl This is now a nop.
void RegisterRdictForLoadPCM(const std::string &pcmFileNameFullPath, llvm::StringRef *pcmContent)
Register Rdict data for future loading by LoadPCM;.
virtual int ClassInfo_Size(ClassInfo_t *info) const
static void UpdateAllCanvases()
Update all canvases at end the terminal input command.
void LibraryUnloaded(const void *dyLibHandle, const char *canonicalName)
Collection abstract base class.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
virtual Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void Add(TObject *obj)=0
All ROOT classes may have RTTI (run time type identification) support added.
Bool_t IsPersistent() const
Basic data type descriptor (datatype information is obtained from CINT).
TList * GetListOfKeys() const override
Small helper to keep current directory context.
void GetObject(const char *namecycle, T *&ptr)
The TEnumConstant class implements the constants of the enum type.
The TEnum class implements the enum type.
const TSeqCollection * GetConstants() const
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
DeclId_t GetDeclId() const
const char * GetValue() const
const char * GetName() const
Returns name of object.
The TEnv class reads config files, by default named .rootrc.
THashList * GetTable() const
Bool_t IgnoreDuplicates(Bool_t ignore)
If set to true, no warnings in case of duplicates are issued.
virtual void SetRcName(const char *name)
virtual Int_t ReadFile(const char *fname, EEnvLevel level)
Read and parse the resource file for a certain level.
virtual TEnvRec * Lookup(const char *n) const
Loop over all resource records and return the one with name.
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=0)
Set the value of a resource or create a new resource.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Global functions class (global functions are obtained from CINT).
Global variables class (global variables are obtained from CINT).
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
TObject * Remove(TObject *obj)
Remove object from the list.
THashTable implements a hash table to store TObject's.
virtual const void * GetValAddr() const =0
This class defines an abstract interface to a generic command line interpreter.
virtual bool RegisterPrebuiltModulePath(const std::string &FullPath, const std::string &ModuleMapName="module.modulemap") const =0
virtual 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
virtual Bool_t IsLibraryLoaded(const char *libname) const =0
std::vector< std::pair< std::string, int > > FwdDeclArgsToKeepCollection_t
TDictionary::DeclId_t DeclId_t
Book space in a file, create I/O buffers, to fill them, (un)compress them.
A collection of TDataMember objects designed for fast access given a DeclId_t and for keep track of T...
TDictionary * Find(DeclId_t id) const
Return (after creating it if necessary) the TDataMember describing the data member corresponding to t...
TClass * GetClass() const
virtual TObject * FindObject(const char *name) const
Specialize FindObject to do search for the a data member just by name or create it if its not already...
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
TEnum * Find(DeclId_t id) const
Return the TEnum corresponding to the Decl 'id' or NULL if it does not exist.
TEnum * Get(DeclId_t id, const char *name)
Return (after creating it if necessary) the TEnum describing the enum corresponding to the Decl 'id'.
TClass * GetClass() const
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TFunctionTemplate * Get(DeclId_t id)
Return (after creating it if necessary) the TMethod or TFunction describing the function correspondin...
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TFunction * Find(DeclId_t id) const
Return the TMethod or TFunction describing the function corresponding to the Decl 'id'.
virtual void Add(TObject *obj)
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
A TMemFile is like a normal TFile except that it reads and writes only from memory.
Abstract base class for accessing the data-members of a class.
const char * GetParent() const
virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr)
EObjectPointerState GetObjectValidity() const
virtual Bool_t IsTreatingNonAccessibleTypes()
void SetObjectValidity(EObjectPointerState val)
void InspectMember(const T &obj, const char *name, Bool_t isTransient)
Each ROOT method (see TMethod) has a linked list of its arguments.
const char * GetFullTypeName() const
Get full type description of method argument, e.g.: "class TDirectory*".
const char * GetDefault() const
Get default value of method argument.
Each ROOT class (see TClass) has a linked list of methods.
virtual TList * GetListOfMethodArgs()
Returns methodarg list and additionally updates fDataMember in TMethod by calling FindDataMember();.
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetName() const
Returns name of object.
Int_t GetEntriesFast() const
virtual void Expand(Int_t newSize)
Expand or shrink the array to newSize elements.
virtual void Compress()
Remove empty slots from array.
Int_t GetEntries() const
Return the number of objects in array (i.e.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
virtual TObject * Remove(TObject *obj)
Remove object from array.
TObject * At(Int_t idx) const
Collectable string class.
Mother of all ROOT objects.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
R__ALWAYS_INLINE Bool_t IsOnHeap() const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual const char * GetTitle() const
Returns title of object.
@ kInvalidObject
if object ctor succeeded but object should not be used
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Persistent version of a TClass.
static const TString & GetIncludeDir()
Get the include directory in the installation. Static utility function.
static const char * GetMacroPath()
Get macro search path. Static utility function.
virtual ~TROOT()
Clean up and free resources used by ROOT (files, network sockets, shared memory segments,...
static const std::vector< std::string > & AddExtraInterpreterArgs(const std::vector< std::string > &args)
Provide command line arguments to the interpreter construction.
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
static const char **& GetExtraInterpreterArgs()
INTERNAL function! Used by rootcling to inject interpreter arguments through a C-interface layer.
static const TString & GetLibDir()
Get the library directory in the installation. Static utility function.
Describe Streamer information for one class version.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Ssiz_t Last(char c) const
Find last occurrence of a character c.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Prepend(const char *cs)
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
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 const char * HomeDirectory(const char *userName=0)
Return the user's home directory.
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 void StackTrace()
Print a stack trace.
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
virtual TVirtualMutex * Factory(Bool_t=kFALSE)=0
TVirtualPad is an abstract base class for the Pad and Canvas classes.
static void SetFactory(TVirtualStreamerInfo *factory)
static function: Set the StreamerInfo factory
@ kNeedObjectForVirtualBaseClass
Type
enumeration specifying the integration types.
TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
const std::string & GetPathSeparator()
const char & GetEnvPathSeparator()
R__EXTERN TROOT * gROOTLocal
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
RVec< T > Filter(const RVec< T > &v, F &&f)
Create a new collection with the elements passing the filter expressed by the predicate.
R__EXTERN TVirtualRWMutex * gCoreMutex
V GetOffset(E val1, E val2, V iso)
RooArgSet S(const RooAbsArg &v1)
bool IsStdArray(std::string_view name)
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
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.
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
EComplexType GetComplexType(const char *)
static constexpr double s
static constexpr double ns
static constexpr double L
constexpr Double_t E()
Base of natural log:
RAII used to store Parser, Sema, Preprocessor state for recursive parsing.
State as returned by GetStateDelta() that can be passed to Restore()
Result of splitting a function declaration into fReturnType fScopeName::fFunctionName<fFunctionTempla...
std::string fScopeName
Name of the scope qualification of the function, possibly empty.
std::vector< std::string > fElements
void ShortType(std::string &answer, int mode)
Return the absolute type of typeDesc into the string answ.
A read-only memory range which we do not control.
static void output(int code)