59 #include "RConfigure.h"
60 #include "compiledata.h"
76 #include "clang/AST/ASTContext.h"
77 #include "clang/AST/Decl.h"
78 #include "clang/AST/DeclarationName.h"
79 #include "clang/AST/GlobalDecl.h"
80 #include "clang/AST/RecordLayout.h"
81 #include "clang/AST/RecursiveASTVisitor.h"
82 #include "clang/AST/Type.h"
83 #include "clang/Basic/SourceLocation.h"
84 #include "clang/Basic/Specifiers.h"
85 #include "clang/Basic/TargetInfo.h"
86 #include "clang/CodeGen/ModuleBuilder.h"
87 #include "clang/Frontend/CompilerInstance.h"
88 #include "clang/Frontend/FrontendDiagnostic.h"
89 #include "clang/Lex/HeaderSearch.h"
90 #include "clang/Lex/Preprocessor.h"
91 #include "clang/Sema/Lookup.h"
92 #include "clang/Sema/Sema.h"
93 #include "clang/Parse/Parser.h"
95 #include "cling/Interpreter/ClangInternalState.h"
96 #include "cling/Interpreter/DynamicLibraryManager.h"
97 #include "cling/Interpreter/Interpreter.h"
98 #include "cling/Interpreter/LookupHelper.h"
99 #include "cling/Interpreter/Value.h"
100 #include "cling/Interpreter/Transaction.h"
101 #include "cling/MetaProcessor/MetaProcessor.h"
102 #include "cling/Utils/AST.h"
103 #include "cling/Utils/ParserStateRAII.h"
104 #include "cling/Utils/SourceNormalization.h"
105 #include "cling/Interpreter/Exception.h"
107 #include "llvm/IR/GlobalValue.h"
108 #include "llvm/IR/Module.h"
110 #include "llvm/Support/DynamicLibrary.h"
111 #include "llvm/Support/raw_ostream.h"
112 #include "llvm/Support/Path.h"
125 #include <unordered_map>
138 #include <mach-o/dyld.h>
145 #if defined(__CYGWIN__)
146 #include <sys/cygwin.h>
147 #define HMODULE void *
149 __declspec(dllimport)
void * __stdcall GetCurrentProcess();
150 __declspec(dllimport)
bool __stdcall EnumProcessModules(
void *,
void **,
unsigned long,
unsigned long *);
151 __declspec(dllimport)
unsigned long __stdcall GetModuleFileNameExW(
void *,
void *,
wchar_t *,
unsigned long);
156 #if defined(_MSC_VER)
158 # define STDIN_FILENO 0
160 #ifndef STDOUT_FILENO
161 # define STDOUT_FILENO 1
163 #ifndef STDERR_FILENO
164 # define STDERR_FILENO 2
173 #undef GetModuleFileName
174 #define RTLD_DEFAULT ((void *)::GetModuleHandle(NULL))
175 #define dlsym(library, function_name) ::GetProcAddress((HMODULE)library, function_name)
176 #define dlopen(library_name, flags) ::LoadLibrary(library_name)
177 #define dlclose(library) ::FreeLibrary((HMODULE)library)
178 #define R__DLLEXPORT __declspec(dllexport)
186 class TCling_UnloadMarker {
188 ~TCling_UnloadMarker() {
194 static TCling_UnloadMarker gTClingUnloadMarker;
203 return D->getDeclContext();
206 return llvm::dyn_cast<clang::NamespaceDecl>(DC);
209 return llvm::dyn_cast<clang::RecordDecl>(DC);
212 return DC->dumpDeclContext();
221 return ((clang::Decl*)D)->dump();
224 if (clang::NamedDecl* ND = llvm::dyn_cast<clang::NamedDecl>(D)) {
227 llvm::raw_string_ostream OS(name);
228 ND->getNameForDiagnostic(OS, D->getASTContext().getPrintingPolicy(),
231 printf(
"%s\n", name.c_str());
239 return D->isInvalidDecl();
243 assert(info && info->
IsValid());
244 return info->
GetDecl()->isInvalidDecl();
248 using namespace clang;
249 using namespace ROOT;
252 static const std::string gInterpreterClassDef = R
"ICF(
#undef ClassDef
#define ClassDef(name, id) \
_ClassDefInterp_(name,id,virtual,) \
static int DeclFileLine() { return __LINE__; }
#undef ClassDefNV
#define ClassDefNV(name, id) \
_ClassDefInterp_(name,id,,) \
static int DeclFileLine() { return __LINE__; }
#undef ClassDefOverride
#define ClassDefOverride(name, id) \
_ClassDefInterp_(name,id,,override) \
static int DeclFileLine() { return __LINE__; }
)ICF";
254 static const std::string gNonInterpreterClassDef = R
"ICF(
#define __ROOTCLING__ 1
#undef ClassDef
#define ClassDef(name,id) \
_ClassDef_(name,id,virtual,) \
static int DeclFileLine() { return __LINE__; }
#undef ClassDefNV
#define ClassDefNV(name, id)\
_ClassDef_(name,id,,)\
static int DeclFileLine() { return __LINE__; }
#undef ClassDefOverride
#define ClassDefOverride(name, id)\
_ClassDef_(name,id,,override)\
static int DeclFileLine() { return __LINE__; }
)ICF";
257 static const std::string gClassDefInterpMacro = R
"ICF(
#ifndef ROOT_TError
#include "TError.h"
#endif
#define _ClassDefInterp_(name,id,virtual_keyword, overrd) \
private: \
public: \
static TClass *Class() { static TClass* sIsA = 0; if (!sIsA) sIsA = TClass::GetClass(#name); return sIsA; } \
static const char *Class_Name() { return #name; } \
static Version_t Class_Version() { return id; } \
static TClass *Dictionary() { return 0; } \
virtual_keyword TClass *IsA() const overrd { return name::Class(); } \
virtual_keyword void ShowMembers(TMemberInspector&insp) const overrd { ::ROOT::Class_ShowMembers(name::Class(), this, insp); } \
virtual_keyword void Streamer(TBuffer&) overrd { ::Error("Streamer", "Cannot stream interpreted class."); } \
void StreamerNVirtual(TBuffer&ClassDef_StreamerNVirtual_b) { name::Streamer(ClassDef_StreamerNVirtual_b); } \
static const char *DeclFileName() { return __FILE__; } \
static int ImplFileLine() { return 0; } \
static const char *ImplFileName() { return __FILE__; }
)ICF";
267 class EnumVisitor :
public RecursiveASTVisitor<EnumVisitor> {
269 llvm::SmallVector<EnumDecl*,128> &fClassEnums;
271 EnumVisitor(llvm::SmallVector<EnumDecl*,128> &enums) : fClassEnums(enums)
274 bool TraverseStmt(Stmt*) {
279 bool shouldVisitTemplateInstantiations()
const {
return true; }
281 bool TraverseClassTemplateDecl(ClassTemplateDecl*) {
286 bool TraverseClassTemplatePartialSpecializationDecl(ClassTemplatePartialSpecializationDecl*) {
291 bool VisitEnumDecl(EnumDecl *TEnumD) {
292 if (!TEnumD->getDeclContext()->isDependentContext())
293 fClassEnums.push_back(TEnumD);
312 static vector<const NamedDecl*> updateList;
315 if (entered) topLevel =
kFALSE;
330 updateList.push_back(TD);
333 while (!updateList.empty()) {
335 updateList.pop_back();
342 const clang::Decl* D =
static_cast<const clang::Decl*
>(enumObj->
GetDeclId());
343 if(
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(D)) {
345 for (EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(),
346 EDE = ED->enumerator_end(); EDI != EDE; ++EDI) {
348 std::string constbuf;
349 if (
const NamedDecl* END = llvm::dyn_cast<NamedDecl>(*EDI)) {
350 PrintingPolicy Policy((*EDI)->getASTContext().getPrintingPolicy());
351 llvm::raw_string_ostream stream(constbuf);
353 Policy.AnonymousTagLocations =
false;
354 (END)->getNameForDiagnostic(stream, Policy,
false);
356 const char* constantName = constbuf.c_str();
360 const llvm::APSInt valAPSInt = (*EDI)->getInitVal();
361 if (valAPSInt.isSigned()) {
362 value = valAPSInt.getSExtValue();
364 value = valAPSInt.getZExtValue();
371 DataMemberInfo_t* dmInfo = (DataMemberInfo_t*) tcDmInfo;
375 enumConstant =
new TEnumConstant(dmInfo, constantName, value, enumObj);
382 globals->
Add(enumConstant);
395 const clang::Decl* D =
static_cast<const clang::Decl*
>(VD);
397 if (
const EnumDecl* ED = llvm::dyn_cast<EnumDecl>(D)) {
399 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
400 llvm::raw_string_ostream stream(buf);
402 Policy.AnonymousTagLocations =
false;
403 ED->getNameForDiagnostic(stream, Policy,
false);
409 const char*
name = buf.c_str();
410 enumType =
new TEnum(name, VD, cl);
411 UpdateEnumConstants(enumType, cl);
416 void TCling::HandleNewDecl(
const void* DV,
bool isDeserialized, std::set<TClass*> &modifiedTClasses) {
420 const clang::Decl* D =
static_cast<const clang::Decl*
>(DV);
422 if (!D->isCanonicalDecl() && !isa<clang::NamespaceDecl>(D)
423 && !dyn_cast<clang::RecordDecl>(D))
return;
425 if (isa<clang::FunctionDecl>(D->getDeclContext())
426 || isa<clang::TagDecl>(D->getDeclContext()))
430 if (
const clang::CXXRecordDecl* RD = dyn_cast<clang::CXXRecordDecl>(D)) {
431 if (RD->getDescribedClassTemplate())
433 }
else if (
const clang::FunctionDecl* FD = dyn_cast<clang::FunctionDecl>(D)) {
434 if (FD->getDescribedFunctionTemplate())
438 if (
const RecordDecl *TD = dyn_cast<RecordDecl>(D)) {
439 if (TD->isCanonicalDecl() || TD->isThisDeclarationADefinition())
442 else if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
444 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
448 }
else if (
const NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(D)) {
456 if (
const NamespaceDecl* NCtx = dyn_cast<NamespaceDecl>(ND->getDeclContext())) {
457 if (NCtx->getIdentifier()) {
460 std::string NCtxName;
461 PrintingPolicy Policy(NCtx->getASTContext().getPrintingPolicy());
462 llvm::raw_string_ostream stream(NCtxName);
464 Policy.AnonymousTagLocations =
false;
465 NCtx->getNameForDiagnostic(stream, Policy,
true);
469 modifiedTClasses.insert(cl);
476 if (!isa<TranslationUnitDecl>(ND->getDeclContext()))
480 if (isa<EnumDecl>(ND))
485 if (!(isa<VarDecl>(ND)))
489 if (
gROOT->GetListOfGlobals()->FindObject(ND->getNameAsString().c_str()))
493 gROOT->GetListOfGlobals()->Add(
new TGlobal((DataMemberInfo_t *)
495 cast<ValueDecl>(ND), 0)));
522 const char* canonicalName) {
524 ((
TCling*)
gCling)->LibraryLoaded(dyLibHandle, canonicalName);
528 const char* canonicalName) {
530 ((
TCling*)
gCling)->LibraryUnloaded(dyLibHandle, canonicalName);
536 return ((
TCling*)
gCling)->GetObjectAddress(Name, LookupCtx);
545 cling::DynamicLibraryManager::ExposeHiddenSharedLibrarySymbols(interpLibHandle);
546 return new TCling(
"C++",
"cling C++ Interpreter");
568 return ((
TCling*)
gCling)->GetClassSharedLibs(className);
580 return ((
TCling*)
gCling)->IsAutoLoadNamespaceCandidate(nsDecl);
585 string file(fileName);
591 string &args,
string &io,
string &fname)
593 string file(fileName);
594 TString
f, amode, arguments, aclicio;
596 mode = amode.Data(); args = arguments.Data();
597 io = aclicio.Data(); fname = f.Data();
607 char *__unDName(
char *demangled,
const char *mangled,
int out_len,
608 void * (* pAlloc )(
size_t),
void (* pFree )(
void *),
609 unsigned short int flags);
621 using namespace clang;
622 if (NamespaceDecl* nsd = llvm::dyn_cast<NamespaceDecl>(decl)){
626 if (ClassTemplateDecl* ctd = llvm::dyn_cast<ClassTemplateDecl>(decl)){
638 return ((
TCling*)
gCling)->LazyFunctionCreatorAutoload(mangled_name);
647 const std::vector<std::string> &headers,
648 const std::vector<std::string> &fwdDecls,
649 const std::vector<std::string> &unknown)
655 if (classes.empty()) {
659 const std::string& className = classes[0];
661 TString fileName =
"AutoDict_";
662 std::string::const_iterator sIt;
663 for (sIt = className.begin(); sIt != className.end(); sIt++) {
664 if (*sIt ==
'<' || *sIt ==
'>' ||
665 *sIt ==
' ' || *sIt ==
'*' ||
666 *sIt ==
',' || *sIt ==
'&' ||
674 if (classes.size() > 1) {
676 std::vector<std::string>::const_iterator it = classes.begin();
677 while ((++it) != classes.end()) {
678 for (
UInt_t cursor = 0; cursor != it->length(); ++cursor) {
679 chk = chk * 3 + it->at(cursor);
692 static const std::set<std::string> sSTLTypes {
693 "vector",
"list",
"forward_list",
"deque",
"map",
"unordered_map",
"multimap",
694 "unordered_multimap",
"set",
"unordered_set",
"multiset",
"unordered_multiset",
695 "queue",
"priority_queue",
"stack",
"iterator"};
696 std::vector<std::string>::const_iterator it;
697 std::string fileContent(
"");
698 for (it = headers.begin(); it != headers.end(); ++it) {
699 fileContent +=
"#include \"" + *it +
"\"\n";
701 for (it = unknown.begin(); it != unknown.end(); ++it) {
707 while (dirbase.Length() && dirbase !=
"."
708 && dirbase !=
"include" && dirbase !=
"inc"
709 && dirbase !=
"prec_stl") {
713 fileContent += TString(
"#include \"") + header +
"\"\n";
716 for (it = fwdDecls.begin(); it != fwdDecls.end(); ++it) {
717 fileContent +=
"class " + *it +
";\n";
719 fileContent +=
"#ifdef __CINT__ \n";
720 fileContent +=
"#pragma link C++ nestedclasses;\n";
721 fileContent +=
"#pragma link C++ nestedtypedefs;\n";
722 for (it = classes.begin(); it != classes.end(); ++it) {
724 size_t posTemplate =
n.find(
'<');
725 std::set<std::string>::const_iterator iSTLType = sSTLTypes.end();
726 if (posTemplate != std::string::npos) {
727 n.erase(posTemplate, std::string::npos);
728 if (
n.compare(0, 5,
"std::") == 0) {
731 iSTLType = sSTLTypes.find(
n);
733 fileContent +=
"#pragma link C++ class ";
734 fileContent += *it +
"+;\n" ;
735 fileContent +=
"#pragma link C++ class ";
736 if (iSTLType != sSTLTypes.end()) {
740 fileContent += *it +
"::*;\n" ;
745 fileContent += *it +
"::*+;\n" ;
747 std::string oprLink(
"#pragma link C++ operators ");
751 if (iSTLType != sSTLTypes.end()) {
753 fileContent +=
"#ifdef G__VECTOR_HAS_CLASS_ITERATOR\n";
755 fileContent += oprLink +
"::iterator;\n";
756 fileContent += oprLink +
"::const_iterator;\n";
757 fileContent += oprLink +
"::reverse_iterator;\n";
759 fileContent +=
"#endif\n";
763 fileContent +=
"#endif\n";
767 filePointer = fopen(fileName,
"w");
768 if (filePointer ==
NULL) {
774 fprintf(filePointer,
"%s", fileContent.c_str());
790 const std::vector<std::string> &headers,
791 const std::vector<std::string> &fwdDecls,
792 const std::vector<std::string> &unknown)
798 std::vector<std::string> classes;
799 classes.push_back(className);
810 const char*
fantomline =
"TRint::EndOfLineAction();";
827 void exceptionErrorHandler(
void * ,
828 const std::string& reason,
830 throw std::runtime_error(std::string(
">>> Interpreter compilation error:\n") + reason);
844 class clangDiagSuppr {
846 clangDiagSuppr(clang::DiagnosticsEngine& diag): fDiagEngine(diag){
847 fOldDiagValue = fDiagEngine.getIgnoreAllWarnings();
848 fDiagEngine.setIgnoreAllWarnings(
true);
852 fDiagEngine.setIgnoreAllWarnings(fOldDiagValue);
855 clang::DiagnosticsEngine& fDiagEngine;
877 unsigned long offset = 0;
878 if (strncmp(tname.c_str(),
"const ", 6) == 0) {
881 unsigned long end = tname.length();
882 while( end && (tname[end-1]==
'&' || tname[end-1]==
'*' || tname[end-1]==
']') ) {
883 if ( tname[end-1]==
']' ) {
885 while ( end && tname[end-1]!=
'[' ) --end;
889 std::string innerbuf;
891 if (end != tname.length()) {
892 innerbuf = tname.substr(offset,end-offset);
893 inner = innerbuf.c_str();
895 inner = tname.c_str()+offset;
899 if (
gROOT->GetListOfClasses()->FindObject(inner)
911 newname =
"Long64_t";
913 newname =
"ULong64_t";
915 if (strcmp(inner,newname) == 0) {
918 if (offset) result =
"const ";
920 if ( end != tname.length() ) {
921 result += tname.substr(end,tname.length()-end);
923 if (result == tname) result.clear();
929 if (lastPos != inner)
933 const auto enName = lastPos;
934 const auto scopeNameSize = ((
Long64_t)lastPos - (
Long64_t)inner) /
sizeof(decltype(*lastPos)) - 2;
935 char *scopeName =
new char[scopeNameSize + 1];
936 strncpy(scopeName, inner, scopeNameSize);
937 scopeName[scopeNameSize] =
'\0';
939 if (
auto scope = static_cast<TClass *>(
gROOT->GetListOfClasses()->FindObject(scopeName))) {
940 auto enumTable =
dynamic_cast<const THashList *
>(scope->GetListOfEnums(
false));
941 if (enumTable && enumTable->THashList::FindObject(enName))
return true;
945 auto listOfEnums = scope->GetListOfEnums();
947 auto enumTable =
dynamic_cast<const THashList *
>(listOfEnums);
948 if (enumTable && enumTable->THashList::FindObject(enName))
return true;
955 auto enumTable =
dynamic_cast<const THashList *
>(
gROOT->GetListOfEnums());
956 if (enumTable && enumTable->THashList::FindObject(inner))
return true;
972 fContent.reserve(size);
979 return fContent.c_str();
987 bool notPresent = fLinesHashSet.emplace(fHashFunc(str)).second;
998 :
TInterpreter(name, title), fGlobalsListSerial(-1), fInterpreter(0),
999 fMetaProcessor(0), fNormalizedCtxt(0), fPrevLoadedDynLibInfo(0),
1000 fClingCallbacks(0), fAutoLoadCallBack(0),
1001 fTransactionCount(0), fHeaderParsingOnDemand(true), fIsAutoParsingSuspended(
kFALSE)
1004 bool fromRootCling = dlsym(RTLD_DEFAULT,
"usedToIdentifyRootClingByDlSym");
1006 llvm::install_fatal_error_handler(&exceptionErrorHandler);
1008 fTemporaries =
new std::vector<cling::Value>();
1010 std::vector<std::string> clingArgsStorage;
1011 clingArgsStorage.push_back(
"cling4root");
1014 if (!fromRootCling) {
1019 clingArgsStorage.push_back(
"-I" + interpInclude);
1024 clingArgsStorage.push_back(
"-I" + interpInclude +
"/cling");
1032 std::string pchFilename = interpInclude +
"/allDict.cxx.pch";
1036 clingArgsStorage.push_back(
"-include-pch");
1037 clingArgsStorage.push_back(pchFilename);
1042 clingArgsStorage.push_back(
"-Wno-undefined-inline");
1043 clingArgsStorage.push_back(
"-fsigned-char");
1046 std::vector<const char*> interpArgs;
1047 for (std::vector<std::string>::const_iterator iArg = clingArgsStorage.begin(),
1048 eArg = clingArgsStorage.end(); iArg != eArg; ++iArg)
1049 interpArgs.push_back(iArg->c_str());
1051 #ifdef R__EXTERN_LLVMDIR
1052 TString llvmResourceDir = R__EXTERN_LLVMDIR;
1058 extraArgs && *extraArgs; ++extraArgs) {
1059 if (!strcmp(*extraArgs,
"-resource-dir")) {
1061 llvmResourceDir = *(++extraArgs);
1063 interpArgs.push_back(*extraArgs);
1067 fInterpreter =
new cling::Interpreter(interpArgs.size(),
1071 if (!fromRootCling) {
1076 fInterpreter->getCI()->getPreprocessorOpts().DisablePCHValidation =
true;
1080 fInterpreter->getCI()->getLangOpts().SpellChecking =
false;
1086 static llvm::raw_fd_ostream fMPOuts (STDOUT_FILENO,
false);
1087 fMetaProcessor =
new cling::MetaProcessor(*fInterpreter, fMPOuts);
1092 if (fromRootCling) {
1093 fInterpreter->declare(
"#include \"RtypesCore.h\"\n"
1094 "#include <string>\n"
1095 "using std::string;");
1097 fInterpreter->declare(
"#include \"Rtypes.h\"\n"
1098 + gClassDefInterpMacro +
"\n"
1099 + gInterpreterClassDef +
"\n"
1100 +
"#undef ClassImp\n"
1101 "#define ClassImp(X)\n"
1102 "#include <string>\n"
1103 "using namespace std;");
1117 fLockProcessLine =
kTRUE;
1119 fAllowLibLoad = !fromRootCling;
1121 fIsAutoParsingSuspended = fromRootCling;
1123 SetClassAutoloading(
false);
1131 if (!fromRootCling) {
1132 fInterpreter->enableDynamicLookup();
1138 std::unique_ptr<TClingCallbacks>
1140 fClingCallbacks = clingCallbacks.get();
1141 fClingCallbacks->SetAutoParsingSuspended(fIsAutoParsingSuspended);
1142 fInterpreter->setCallbacks(std::move(clingCallbacks));
1161 #if defined(R__MUST_REVISIT)
1162 #if R__MUST_REVISIT(6,2)
1163 Warning(
"~TCling",
"Interface not available yet.");
1164 #ifdef R__COMPLETE_MEM_TERMINATION
1185 #if defined(__CYGWIN__) && defined(__GNUC__)
1187 #elif defined(G__WIN32)
1188 MEMORY_BASIC_INFORMATION mbi;
1189 if (!VirtualQuery (
func, &mbi,
sizeof (mbi)))
1194 HMODULE hMod = (HMODULE) mbi.AllocationBase;
1195 TTHREAD_TLS_ARRAY(
char, MAX_PATH, moduleName);
1197 if (!GetModuleFileNameA (hMod, moduleName,
sizeof (moduleName)))
1204 if (dladdr((
void*)
func,&info)==0) {
1209 return info.dli_fname;
1221 auto setFactory = []() {
1225 static bool doneFactory = setFactory();
1234 const char** headers,
1235 void (*triggerFunc)())
const {
1243 searchPath = llvm::sys::path::parent_path(libraryName);
1263 if (
gROOT->IsRootFile(pcmFileName)) {
1267 ::Info(
"TCling::LoadPCM",
"Loading ROOT PCM %s", pcmFileName.Data());
1274 TFile *pcmFile =
new TFile(pcmFileName+
"?filetype=pcm",
"READ");
1276 auto listOfKeys = pcmFile->GetListOfKeys();
1282 (listOfKeys->GetSize() == 0) ||
1284 (listOfKeys->GetSize() == 1) &&
1285 !strcmp(((
TKey*)listOfKeys->At(0))->
GetName(),
"EMPTY")
1296 ::Info(
"TCling::LoadPCM",
"reading protoclasses for %s \n",pcmFileName.Data());
1298 pcmFile->GetObject(
"__ProtoClasses", protoClasses);
1301 for (
auto obj : *protoClasses) {
1311 for (
auto proto : *protoClasses) {
1320 ::Error(
"TCling::LoadPCM",
"Inconsistent TClassTable for %s",
1332 protoClasses->Clear();
1333 delete protoClasses;
1337 pcmFile->GetObject(
"__Typedefs", dataTypes);
1339 for (
auto typedf: *dataTypes)
1340 gROOT->GetListOfTypes()->Add(typedf);
1346 pcmFile->GetObject(
"__Enums", enums);
1349 auto listOfGlobals =
gROOT->GetListOfGlobals();
1350 auto listOfEnums =
dynamic_cast<THashList*
>(
gROOT->GetListOfEnums());
1352 for (
auto selEnum: *enums){
1353 const char* enumScope = selEnum->
GetTitle();
1354 const char* enumName = selEnum->GetName();
1355 if (strcmp(enumScope,
"") == 0){
1358 if (!listOfEnums->THashList::FindObject(enumName)){
1359 ((
TEnum*) selEnum)->SetClass(
nullptr);
1360 listOfEnums->Add(selEnum);
1362 for (
auto enumConstant: *static_cast<TEnum*>(selEnum)->GetConstants()){
1363 if (!listOfGlobals->FindObject(enumConstant)){
1364 listOfGlobals->Add(enumConstant);
1372 if (!nsTClassEntry){
1375 auto listOfEnums = nsTClassEntry->
fEnums.load();
1386 if (listOfEnums && !listOfEnums->THashList::FindObject(enumName)){
1387 ((
TEnum*) selEnum)->SetClass(nsTClassEntry);
1388 listOfEnums->Add(selEnum);
1401 ::Info(
"TCling::LoadPCM",
"Loading clang PCM %s", pcmFileName.Data());
1415 using namespace clang;
1417 class ExtLexicalStorageAdder:
public RecursiveASTVisitor<ExtLexicalStorageAdder>{
1422 bool VisitRecordDecl(clang::RecordDecl* rcd){
1424 Info(
"ExtLexicalStorageAdder",
1425 "Adding external lexical storage to class %s",
1426 rcd->getNameAsString().c_str());
1427 auto reDeclPtr = rcd->getMostRecentDecl();
1429 reDeclPtr->setHasExternalLexicalStorage();
1430 }
while ((reDeclPtr = reDeclPtr->getPreviousDecl()));
1450 const char** headers,
1451 const char** includePaths,
1452 const char* payloadCode,
1453 const char* fwdDeclsCode,
1454 void (*triggerFunc)(),
1455 const FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
1456 const char** classesHeaders,
1457 Bool_t lateRegistration )
1460 static const bool fromRootCling = dlsym(RTLD_DEFAULT,
"usedToIdentifyRootClingByDlSym");
1464 if (fromRootCling)
return;
1468 bool isACLiC =
false;
1469 if (hasHeaderParsingOnDemand &&
1470 strstr(modulename,
"_ACLiC_dict") !=
nullptr){
1472 Info(
"TCling::RegisterModule",
1473 "Header parsing on demand is active but this is an Aclic library. Disabling it for this library.");
1474 hasHeaderParsingOnDemand =
false;
1491 for (
const char** inclPath = includePaths; *inclPath; ++inclPath) {
1494 cling::Transaction* T = 0;
1496 for (
auto& fwdDeclArgToSkipPair : fwdDeclsArgToSkip){
1497 const std::string& fwdDecl = fwdDeclArgToSkipPair.first;
1498 const int nArgsToSkip = fwdDeclArgToSkipPair.second;
1500 assert(cling::Interpreter::kSuccess == compRes &&
1501 "A fwd declaration could not be compiled");
1502 if (compRes!=cling::Interpreter::kSuccess){
1503 Warning(
"TCling::RegisterModule",
1504 "Problems in declaring string '%s' were encountered.",
1519 TString code = gNonInterpreterClassDef;
1520 code += payloadCode;
1522 const char* dyLibName =
nullptr;
1526 if (!lateRegistration) {
1534 void* dyLibHandle = dlopen(dyLibName, RTLD_LAZY | RTLD_GLOBAL);
1537 char dyLibError[1000];
1538 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL, GetLastError(),
1539 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), dyLibError,
1540 sizeof(dyLibError),
NULL);
1542 const char* dyLibError = dlerror();
1547 ::Info(
"TCling::RegisterModule",
1548 "Cannot open shared library %s for dictionary %s:\n %s",
1549 dyLibName, modulename, dyLibError);
1559 if (hasHeaderParsingOnDemand && fwdDeclsCode){
1562 std::string fwdDeclsCodeLessEnums;
1566 std::string fwdDeclsLine;
1567 std::istringstream fwdDeclsCodeStr(fwdDeclsCode);
1568 std::vector<std::string> scope;
1569 while (std::getline(fwdDeclsCodeStr, fwdDeclsLine)) {
1570 if (fwdDeclsLine.find(
"namespace ") == 0
1571 || fwdDeclsLine.find(
"inline namespace ") == 0) {
1573 scope.push_back(fwdDeclsLine.substr(10,
1574 fwdDeclsLine.length() - 10 - 2));
1575 }
else if (fwdDeclsLine ==
"}") {
1577 }
else if (fwdDeclsLine.find(
"enum __attribute__((annotate(\"") == 0) {
1578 clang::DeclContext* DC = 0;
1579 for (
auto &&aScope: scope) {
1580 DC = cling::utils::Lookup::Namespace(&
fInterpreter->getSema(), aScope.c_str(), DC);
1586 if (scope.empty() || DC) {
1588 size_t posEnumName = fwdDeclsLine.find(
"\"))) ", 32);
1589 R__ASSERT(posEnumName != std::string::npos &&
"Inconsistent enum fwd decl!");
1591 while (isspace(fwdDeclsLine[posEnumName]))
1593 size_t posEnumNameEnd = fwdDeclsLine.find(
" : ", posEnumName);
1594 R__ASSERT(posEnumNameEnd != std::string::npos &&
"Inconsistent enum fwd decl (end)!");
1595 while (isspace(fwdDeclsLine[posEnumNameEnd]))
1599 std::string enumName = fwdDeclsLine.substr(posEnumName,
1600 posEnumNameEnd - posEnumName + 1);
1602 if (clang::NamedDecl* enumDecl
1603 = cling::utils::Lookup::Named(&
fInterpreter->getSema(),
1604 enumName.c_str(), DC)) {
1607 R__ASSERT(llvm::dyn_cast<clang::EnumDecl>(enumDecl) &&
"not an enum decl!");
1613 fwdDeclsCodeLessEnums += fwdDeclsLine +
"\n";
1617 if (fwdDeclsCodeLessEnums.size() != 0){
1618 auto compRes =
fInterpreter->declare(fwdDeclsCodeLessEnums, &T);
1619 assert(cling::Interpreter::kSuccess == compRes &&
1620 "The forward declarations could not be compiled");
1621 if (compRes!=cling::Interpreter::kSuccess){
1622 Warning(
"TCling::RegisterModule",
1623 "Problems in compiling forward declarations for module %s: '%s'",
1624 modulename, fwdDeclsCodeLessEnums.c_str()) ;
1632 ExtLexicalStorageAdder elsa;
1633 for (
auto dciIt = T->decls_begin();dciIt!=T->decls_end();dciIt++){
1634 cling::Transaction::DelayCallInfo& dci = *dciIt;
1635 for(
auto dit = dci.m_DGR.begin(); dit != dci.m_DGR.end(); ++dit) {
1636 clang::Decl* declPtr = *dit;
1637 elsa.TraverseDecl(declPtr);
1651 for (
const char** classesHeader = classesHeaders; *classesHeader; ++classesHeader) {
1652 temp=*classesHeader;
1654 size_t theTemplateHash = 0;
1655 bool addTemplate =
false;
1656 size_t posTemplate = temp.find(
'<');
1657 if (posTemplate != std::string::npos) {
1659 std::string templateName = temp.substr(0, posTemplate);
1665 for (
const char** classesHeader_inner = classesHeader; 0!=strcmp(*classesHeader_inner,
"@"); ++classesHeader_inner,++classesHeader){
1667 if (payloadCode == *classesHeader_inner ){
1669 if (addTemplate)
fPayloads.insert(theTemplateHash);
1672 Info(
"TCling::RegisterModule",
1673 "Adding a header for %s", temp.c_str());
1679 addTemplate =
false;
1686 if (strcmp(modulename,
"libCore")!=0 && strcmp(modulename,
"libRint")!=0
1687 && strcmp(modulename,
"libThread")!=0 && strcmp(modulename,
"libRIO")!=0
1688 && strcmp(modulename,
"libcomplexDict")!=0 && strcmp(modulename,
"libdequeDict")!=0
1689 && strcmp(modulename,
"liblistDict")!=0 && strcmp(modulename,
"libforward_listDict")!=0
1690 && strcmp(modulename,
"libvectorDict")!=0
1691 && strcmp(modulename,
"libmapDict")!=0 && strcmp(modulename,
"libmultimap2Dict")!=0
1692 && strcmp(modulename,
"libmap2Dict")!=0 && strcmp(modulename,
"libmultimapDict")!=0
1693 && strcmp(modulename,
"libsetDict")!=0 && strcmp(modulename,
"libmultisetDict")!=0
1694 && strcmp(modulename,
"libunordered_setDict")!=0 && strcmp(modulename,
"libunordered_multisetDict")!=0
1695 && strcmp(modulename,
"libunordered_mapDict")!=0 && strcmp(modulename,
"libunordered_multimapDict")!=0
1696 && strcmp(modulename,
"libvalarrayDict")!=0
1697 && strcmp(modulename,
"G__GenVector32")!=0 && strcmp(modulename,
"G__Smatrix32")!=0
1701 if (!
LoadPCM(pcmFileName, headers, triggerFunc)) {
1702 ::Error(
"TCling::RegisterModule",
"cannot find dictionary module %s",
1707 bool oldValue =
false;
1715 clangDiagSuppr diagSuppr(
fInterpreter->getSema().getDiagnostics());
1717 #if defined(R__MUST_REVISIT)
1718 #if R__MUST_REVISIT(6,2)
1719 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
1723 if (!hasHeaderParsingOnDemand){
1726 const cling::Transaction* watermark =
fInterpreter->getLastTransaction();
1727 cling::Interpreter::CompilationResult compRes =
fInterpreter->parseForModule(code.Data());
1733 assert(cling::Interpreter::kSuccess == compRes &&
1734 "Payload code of a dictionary could not be parsed correctly.");
1735 if (compRes!=cling::Interpreter::kSuccess) {
1736 Warning(
"TCling::RegisterModule",
1737 "Problems declaring payload for module %s.", modulename) ;
1746 if (!hasHeaderParsingOnDemand) {
1773 if (!hasHeaderParsingOnDemand) {
1776 "#undef __ROOTCLING__\n"
1777 + gInterpreterClassDef +
1784 dlclose(dyLibHandle);
1806 typedef std::vector<std::pair<TClass*,DictFuncPtr_t> >::iterator iterator;
1812 if ( i->first == oldcl ) {
1834 const char* input_line,
1835 cling::Interpreter::CompilationResult& compRes,
1839 return metaProcessor->process(input_line, compRes, result);
1841 catch (cling::InvalidDerefException&
ex)
1843 Error(
"HandleInterpreterException",
"%s.\n%s", ex.what(),
"Execution of your code was aborted.");
1853 if (
auto ie = dynamic_cast<const cling::InterpreterException*>(&e)) {
1869 TString sLine(line);
1870 if (strstr(line,fantomline)) {
1885 gROOT->SetLineIsProcessing();
1889 gROOT->SetLineHasBeenProcessed();
1902 gROOT->SetLineIsProcessing();
1904 struct InterpreterFlagsRAII {
1906 bool fWasDynamicLookupEnabled;
1908 InterpreterFlagsRAII(cling::Interpreter* interp):
1910 fWasDynamicLookupEnabled(interp->isDynamicLookupEnabled())
1914 ~InterpreterFlagsRAII() {
1915 fInterpreter->enableDynamicLookup(fWasDynamicLookupEnabled);
1916 gROOT->SetLineHasBeenProcessed();
1925 cling::Interpreter::CompilationResult compRes = cling::Interpreter::kSuccess;
1926 if (!strncmp(sLine.Data(),
".L", 2) || !strncmp(sLine.Data(),
".x", 2) ||
1927 !strncmp(sLine.Data(),
".X", 2)) {
1930 TString mod_line(sLine);
1935 aclicMode, arguments, io);
1936 if (aclicMode.Length()) {
1938 R__ASSERT(aclicMode[0]==
'+' &&
"ACLiC mode must start with a +");
1940 if (aclicMode[1]==
'+') {
1946 compRes = cling::Interpreter::kFailure;
1948 if (strncmp(sLine.Data(),
".L", 2) != 0) {
1951 if (arguments.Length()==0) {
1955 Ssiz_t ext = fname.Last(
'.');
1960 mod_line =
function + arguments + io;
1961 cling::MetaProcessor::MaybeRedirectOutputRAII RAII(
fMetaProcessor);
1967 size_t unnamedMacroOpenCurly;
1970 std::string codeline;
1971 std::ifstream in(fname);
1973 std::getline(in, codeline);
1974 code += codeline +
"\n";
1976 unnamedMacroOpenCurly
1977 = cling::utils::isUnnamedMacro(code,
fInterpreter->getCI()->getLangOpts());
1981 cling::MetaProcessor::MaybeRedirectOutputRAII RAII(
fMetaProcessor);
1982 if (unnamedMacroOpenCurly != std::string::npos) {
1984 unnamedMacroOpenCurly);
1994 if (0!=strncmp(sLine.Data(),
".autodict ",10) && sLine !=
".autodict") {
1997 cling::MetaProcessor::MaybeRedirectOutputRAII RAII(
fMetaProcessor);
2000 bool isInclusionDirective = sLine.Contains(
"\n#include") || sLine.BeginsWith(
"#include");
2001 if (isInclusionDirective) {
2009 if (result.isValid())
2018 case cling::Interpreter::kSuccess: *error =
kNoError;
break;
2019 case cling::Interpreter::kFailure: *error =
kRecoverable;
break;
2020 case cling::Interpreter::kMoreInputExpected: *error =
kProcessing;
break;
2023 if (compRes == cling::Interpreter::kSuccess
2025 && !result.isVoid())
2027 gROOT->SetLineHasBeenProcessed();
2028 return result.simplisticCastAs<
long>();
2030 gROOT->SetLineHasBeenProcessed();
2051 if (path[0] ==
'-' && path[1] ==
'I')
2075 static const TClassRef clRefString(
"std::string");
2076 if (clRefString == cl) {
2081 const char* cobj = (
const char*) obj;
2088 auto inspInspect = [&] (ptrdiff_t offset){
2089 insp.
Inspect(const_cast<TClass*>(cl), insp.
GetParent(),
"_real", cobj, isTransient);
2090 insp.
Inspect(const_cast<TClass*>(cl), insp.
GetParent(),
"_imag", cobj + offset, isTransient);
2094 switch(complexType) {
2101 inspInspect(
sizeof(
float));
2106 inspInspect(
sizeof(
double));
2111 inspInspect(
sizeof(
int));
2116 inspInspect(
sizeof(
long));
2121 static clang::PrintingPolicy
2123 if (printPol.Indentation) {
2125 printPol.Indentation = 0;
2126 printPol.SuppressInitializers =
true;
2129 const char* clname = cl->
GetName();
2132 const clang::ASTContext& astContext =
fInterpreter->getCI()->getASTContext();
2133 const clang::Decl *scopeDecl = 0;
2138 scopeDecl = clingCI->
GetDecl();
2139 recordType = clingCI->
GetType();
2141 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
2143 scopeDecl = lh.findScope(clname, cling::LookupHelper::NoDiagnostics,
2147 Error(
"InspectMembers",
"Cannot find Decl for class %s", clname);
2150 const clang::CXXRecordDecl* recordDecl
2151 = llvm::dyn_cast<
const clang::CXXRecordDecl>(scopeDecl);
2153 Error(
"InspectMembers",
"Cannot find Decl for class %s is not a CXXRecordDecl.", clname);
2160 cling::Interpreter::PushTransactionRAII deserRAII(
fInterpreter);
2162 astContext.getASTRecordLayout(recordDecl);
2164 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2165 eField = recordDecl->field_end(); iField != eField; ++iField) {}
2168 const clang::ASTRecordLayout& recLayout
2169 = astContext.getASTRecordLayout(recordDecl);
2176 if (cl->
Size() != recLayout.getSize().getQuantity()) {
2177 Error(
"InspectMembers",
"TClass and cling disagree on the size of the class %s, respectively %d %lld\n",
2181 unsigned iNField = 0;
2184 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2185 eField = recordDecl->field_end(); iField != eField;
2186 ++iField, ++iNField) {
2189 clang::QualType memberQT = iField->getType();
2194 memberQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, memberQT,
fNormalizedCtxt->
GetConfig(),
false );
2195 if (memberQT.isNull()) {
2196 std::string memberName;
2197 llvm::raw_string_ostream stream(memberName);
2199 printPol.AnonymousTagLocations =
false;
2200 iField->getNameForDiagnostic(stream, printPol,
true );
2202 Error(
"InspectMembers",
2203 "Cannot retrieve QualType for member %s while inspecting class %s",
2204 memberName.c_str(), clname);
2207 const clang::Type* memType = memberQT.getTypePtr();
2209 std::string memberName;
2210 llvm::raw_string_ostream stream(memberName);
2212 printPol.AnonymousTagLocations =
false;
2213 iField->getNameForDiagnostic(stream, printPol,
true );
2215 Error(
"InspectMembers",
2216 "Cannot retrieve Type for member %s while inspecting class %s",
2217 memberName.c_str(), clname);
2222 Bool_t ispointer =
false;
2223 if (memNonPtrType->isPointerType()) {
2225 clang::QualType ptrQT
2226 = memNonPtrType->getAs<clang::PointerType>()->getPointeeType();
2231 ptrQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, ptrQT,
fNormalizedCtxt->
GetConfig(),
false );
2232 if (ptrQT.isNull()) {
2233 std::string memberName;
2234 llvm::raw_string_ostream stream(memberName);
2236 printPol.AnonymousTagLocations =
false;
2237 iField->getNameForDiagnostic(stream, printPol,
true );
2239 Error(
"InspectMembers",
2240 "Cannot retrieve pointee Type for member %s while inspecting class %s",
2241 memberName.c_str(), clname);
2244 memNonPtrType = ptrQT.getTypePtr();
2248 llvm::SmallString<8> arraySize;
2249 const clang::ArrayType* arrType = memNonPtrType->getAsArrayTypeUnsafe();
2250 unsigned arrLevel = 0;
2251 bool haveErrorDueToArray =
false;
2255 const clang::ConstantArrayType* constArrType =
2256 clang::dyn_cast<clang::ConstantArrayType>(arrType);
2258 constArrType->getSize().toStringUnsigned(arraySize);
2261 clang::QualType subArrQT = arrType->getElementType();
2262 if (subArrQT.isNull()) {
2263 std::string memberName;
2264 llvm::raw_string_ostream stream(memberName);
2266 printPol.AnonymousTagLocations =
false;
2267 iField->getNameForDiagnostic(stream, printPol,
true );
2269 Error(
"InspectMembers",
2270 "Cannot retrieve QualType for array level %d (i.e. element type of %s) for member %s while inspecting class %s",
2271 arrLevel, subArrQT.getAsString(printPol).c_str(),
2272 memberName.c_str(), clname);
2273 haveErrorDueToArray =
true;
2276 arrType = subArrQT.getTypePtr()->getAsArrayTypeUnsafe();
2278 if (haveErrorDueToArray) {
2283 std::string fieldName;
2284 if (memType->isPointerType()) {
2289 std::string
ioname(iField->getName());
2292 fieldName += arraySize;
2297 clang::CharUnits offset(astContext.toCharUnitsFromBits(recLayout.getFieldOffset(iNField)));
2298 ptrdiff_t fieldOffset = offset.getQuantity();
2308 auto iFiledQtype = iField->getType();
2309 if (
auto tagDecl = iFiledQtype->getAsTagDecl()){
2310 auto declAccess = tagDecl->getAccess();
2311 if (declAccess == AS_private || declAccess == AS_protected) {
2317 insp.
Inspect(const_cast<TClass*>(cl), insp.
GetParent(), fieldName.c_str(), cobj + fieldOffset, isTransient);
2320 const clang::CXXRecordDecl* fieldRecDecl = memNonPtrType->getAsCXXRecordDecl();
2324 std::string sFieldRecName;
2327 clang::QualType(memNonPtrType,0),
2337 insp.
InspectMember(sFieldRecName.c_str(), cobj + fieldOffset,
2338 (fieldName +
'.').c_str(),
transient);
2346 unsigned iNBase = 0;
2347 for (clang::CXXRecordDecl::base_class_const_iterator iBase
2348 = recordDecl->bases_begin(), eBase = recordDecl->bases_end();
2349 iBase != eBase; ++iBase, ++iNBase) {
2350 clang::QualType baseQT = iBase->getType();
2351 if (baseQT.isNull()) {
2352 Error(
"InspectMembers",
2353 "Cannot find QualType for base number %d while inspecting class %s",
2357 const clang::CXXRecordDecl* baseDecl
2358 = baseQT->getAsCXXRecordDecl();
2360 Error(
"InspectMembers",
2361 "Cannot find CXXRecordDecl for base number %d while inspecting class %s",
2366 std::string sBaseName;
2368 std::vector<TClass*> foundClasses;
2370 if (foundClasses.size()==1){
2371 baseCl=foundClasses[0];
2384 std::string qualNameForDiag;
2386 Error(
"InspectMembers",
2387 "Cannot find TClass for base class %s", qualNameForDiag.c_str() );
2392 if (iBase->isVirtual()) {
2395 Error(
"InspectMembers",
2396 "Base %s of class %s is virtual but no object provided",
2397 sBaseName.c_str(), clname);
2405 baseOffset = ci->
GetBaseOffset(baseCi, const_cast<void*>(obj),
2407 if (baseOffset == -1) {
2408 Error(
"InspectMembers",
2409 "Error calculating offset of virtual base %s of class %s",
2410 sBaseName.c_str(), clname);
2413 Error(
"InspectMembers",
2414 "Cannot calculate offset of virtual base %s of class %s",
2415 sBaseName.c_str(), clname);
2420 baseOffset = recLayout.getBaseClassOffset(baseDecl).getQuantity();
2467 bool oldDynLookup =
fInterpreter->isDynamicLookupEnabled();
2518 std::string file_name = filename;
2519 size_t at = std::string::npos;
2520 while ((at = file_name.find(
"/./")) != std::string::npos)
2521 file_name.replace(at, 3,
"/");
2523 std::string filesStr =
"";
2524 llvm::raw_string_ostream filesOS(filesStr);
2525 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
2526 cling::ClangInternalState::printIncludedFiles(filesOS, SM);
2529 llvm::SmallVector<llvm::StringRef, 100> files;
2530 llvm::StringRef(filesStr).split(files,
"\n");
2532 std::set<std::string> fileMap;
2534 for (llvm::SmallVector<llvm::StringRef, 100>::const_iterator
2535 iF = files.begin(), iE = files.end(); iF != iE; ++iF) {
2536 if ((*iF) == file_name.c_str())
return kTRUE;
2537 fileMap.insert(*iF);
2540 if (fileMap.empty())
return kFALSE;
2543 TString sFilename(file_name.c_str());
2545 && fileMap.count(sFilename.Data())) {
2551 incPath.Append(
":").Prepend(
" ");
2552 incPath.ReplaceAll(
" -I",
":");
2553 while (incPath.Index(
" :") != -1) {
2554 incPath.ReplaceAll(
" :",
":");
2556 incPath.Prepend(
".:");
2557 sFilename = file_name.c_str();
2559 && fileMap.count(sFilename.Data())) {
2564 sFilename = file_name.c_str();
2566 cling::DynamicLibraryManager* dyLibManager
2569 if (dyLibManager->isLibraryLoaded(found)) {
2574 const clang::DirectoryLookup *CurDir = 0;
2575 clang::Preprocessor &PP =
fInterpreter->getCI()->getPreprocessor();
2576 clang::HeaderSearch &HS = PP.getHeaderSearchInfo();
2577 const clang::FileEntry *FE = HS.LookupFile(file_name.c_str(),
2578 clang::SourceLocation(),
2581 clang::ArrayRef<std::pair<
const clang::FileEntry *,
2582 const clang::DirectoryEntry *>>(),
2591 if (FE && FE->isValid()) {
2593 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
2595 clang::FileID FID = SM.translateFile(FE);
2596 if (!FID.isInvalid() && FID.getHashValue() == 0)
2599 clang::SrcMgr::SLocEntry SLocE = SM.getSLocEntry(FID);
2600 if (SLocE.isFile() && SLocE.getFile().getContentCache()->getRawBuffer() == 0)
2602 if (!FID.isInvalid())
2606 sFilename = FE->getName();
2608 && fileMap.count(sFilename.Data())) {
2619 #if defined(R__WIN32) || defined(__CYGWIN__)
2620 HMODULE hModules[1024];
2622 unsigned long cbModules;
2624 hProcess = (
void *)::GetCurrentProcess();
2625 ::EnumProcessModules(hProcess, hModules,
sizeof(hModules), &cbModules);
2627 for (i = 1; i < (cbModules /
sizeof(
void *)); i++) {
2628 static const int bufsize = 260;
2629 wchar_t winname[bufsize];
2630 char posixname[bufsize];
2631 ::GetModuleFileNameExW(hProcess, hModules[i], winname, bufsize);
2632 #if defined(__CYGWIN__)
2633 cygwin_conv_path(CCP_WIN_W_TO_POSIX, winname, posixname, bufsize);
2635 std::wstring wpath = winname;
2636 std::replace(wpath.begin(), wpath.end(),
'\\',
'/');
2637 string path(wpath.begin(), wpath.end());
2638 strncpy(posixname, path.c_str(), bufsize);
2644 #elif defined(R__MACOSX)
2647 const char* imageName = 0;
2648 while ((imageName = _dyld_get_image_name(imageIndex))) {
2655 #elif defined(R__LINUX)
2668 PointerNo4* procLinkMap = (PointerNo4*)dlopen(0, RTLD_LAZY | RTLD_GLOBAL);
2671 LinkMap* linkMap = (LinkMap*) ((PointerNo4*)procLinkMap->fPtr)->fPtr;
2675 dlclose(procLinkMap);
2679 while (iDyLib->fNext) {
2680 iDyLib = iDyLib->fNext;
2685 Error(
"TCling::UpdateListOfLoadedSharedLibraries",
2686 "Platform not supported!");
2697 if (!filename)
return;
2701 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
2702 if (!DLM->isLibraryLoaded(filename)) {
2703 DLM->loadLibrary(filename,
true );
2706 #if defined(R__MACOSX)
2708 if (!strncmp(filename,
"/usr/lib/system/", 16)
2709 || !strncmp(filename,
"/usr/lib/libc++", 15)
2710 || !strncmp(filename,
"/System/Library/Frameworks/", 27)
2711 || !strncmp(filename,
"/System/Library/PrivateFrameworks/", 34)
2712 || !strncmp(filename,
"/System/Library/CoreServices/", 29)
2713 || !strcmp(filename,
"cl_kernels")
2714 || strstr(filename,
"/usr/lib/libSystem")
2715 || strstr(filename,
"/usr/lib/libstdc++")
2716 || strstr(filename,
"/usr/lib/libicucore")
2717 || strstr(filename,
"/usr/lib/libbsm")
2718 || strstr(filename,
"/usr/lib/libobjc")
2719 || strstr(filename,
"/usr/lib/libresolv")
2720 || strstr(filename,
"/usr/lib/libauto")
2721 || strstr(filename,
"/usr/lib/libcups")
2722 || strstr(filename,
"/usr/lib/libDiagnosticMessagesClient")
2723 || strstr(filename,
"/usr/lib/liblangid")
2724 || strstr(filename,
"/usr/lib/libCRFSuite")
2725 || strstr(filename,
"/usr/lib/libpam")
2726 || strstr(filename,
"/usr/lib/libOpenScriptingUtil")
2727 || strstr(filename,
"/usr/lib/libextension"))
2729 #elif defined(__CYGWIN__)
2731 static const int bufsize = 260;
2732 char posixwindir[bufsize];
2733 char *windir = getenv(
"WINDIR");
2735 cygwin_conv_path(CCP_WIN_A_TO_POSIX, windir, posixwindir, bufsize);
2737 snprintf(posixwindir,
sizeof(posixwindir),
"/Windows/");
2738 if (strstr(filename, posixwindir) ||
2739 strstr(filename,
"/usr/bin/cyg"))
2741 #elif defined(R__WIN32)
2742 if (strstr(filename,
"/Windows/"))
2744 #elif defined (R__LINUX)
2745 if (strstr(filename,
"/ld-linux")
2746 || strstr(filename,
"linux-gnu/")
2747 || strstr(filename,
"/libstdc++.")
2748 || strstr(filename,
"/libgcc")
2749 || strstr(filename,
"/libc.")
2750 || strstr(filename,
"/libdl.")
2751 || strstr(filename,
"/libm."))
2769 Error(
"Load",
"Trying to load library (%s) from rootcling.",filename);
2775 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
2776 std::string canonLib = DLM->lookupLibrary(filename);
2777 cling::DynamicLibraryManager::LoadLibResult res
2778 = cling::DynamicLibraryManager::kLoadLibNotFound;
2779 if (!canonLib.empty()) {
2781 res = DLM->loadLibrary(filename, system);
2785 cling::Interpreter::CompilationResult compRes;
2786 cling::MetaProcessor::MaybeRedirectOutputRAII RAII(
fMetaProcessor);
2788 if (compRes == cling::Interpreter::kSuccess)
2789 res = cling::DynamicLibraryManager::kLoadLibSuccess;
2793 if (res == cling::DynamicLibraryManager::kLoadLibSuccess) {
2797 case cling::DynamicLibraryManager::kLoadLibSuccess:
return 0;
2798 case cling::DynamicLibraryManager::kLoadLibAlreadyLoaded:
return 1;
2848 Warning(
"Calc",
"waiting for cling thread to free");
2851 gROOT->SetLineIsProcessing();
2859 cling::Interpreter::CompilationResult cr =
fInterpreter->evaluate(line, valRef);
2860 if (cr != cling::Interpreter::kSuccess) {
2868 if (!valRef.isValid()) {
2877 if (valRef.isVoid()) {
2884 gROOT->SetLineHasBeenProcessed();
2887 return valRef.simplisticCastAs<
long>();
2894 void (*histaddFunc)(
const char* line))
2899 #if defined(R__MUST_REVISIT)
2900 #if R__MUST_REVISIT(6,2)
2901 Warning(
"SetGetline",
"Cling should support the equivalent of SetGetlineFunc(getlineFunc, histaddFunc)");
2914 if ((std::distance(T.decls_begin(), T.decls_end()) != 1)
2915 || T.deserialized_decls_begin() != T.deserialized_decls_end()
2916 || T.macros_begin() != T.macros_end()
2917 || ((!T.getFirstDecl().isNull()) && ((*T.getFirstDecl().begin()) != T.getWrapperFD()))) {
2934 std::set<TObject*>::iterator iSpecial = ((std::set<TObject*>*)
fgSetOfSpecials)->find(obj);
2951 #if defined(R__MUST_REVISIT)
2952 #if R__MUST_REVISIT(6,2)
2954 Warning(
"Reset",
"Cling should support the equivalent of scratch_upto(&fDictPos)");
2964 #if defined(R__MUST_REVISIT)
2965 #if R__MUST_REVISIT(6,2)
2967 Warning(
"ResetAll",
"Cling should support the equivalent of complete reset (unload everything but the startup decls.");
2994 #if defined(R__MUST_REVISIT)
2995 #if R__MUST_REVISIT(6,2)
2997 Warning(
"ResetGlobalVar",
"Cling should support the equivalent of resetglobalvar(obj)");
3009 #if defined(R__MUST_REVISIT)
3010 #if R__MUST_REVISIT(6,2)
3012 Warning(
"RewindDictionary",
"Cling should provide a way to revert transaction similar to rewinddictionary()");
3023 #if defined(R__MUST_REVISIT)
3024 #if R__MUST_REVISIT(6,2)
3026 Warning(
"DeleteGlobal",
"Cling should provide the equivalent of deleteglobal(obj), see also DeleteVariable.");
3038 #if defined(R__MUST_REVISIT)
3039 #if R__MUST_REVISIT(6,2)
3040 Warning(
"DeleteVariable",
"should do more that just reseting the value to zero");
3045 llvm::StringRef srName(name);
3046 const char* unscopedName =
name;
3047 llvm::StringRef::size_type posScope = srName.rfind(
"::");
3048 const clang::DeclContext* declCtx = 0;
3049 if (posScope != llvm::StringRef::npos) {
3050 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
3051 const clang::Decl* scopeDecl
3052 = lh.findScope(srName.substr(0, posScope),
3053 cling::LookupHelper::WithDiagnostics);
3055 Error(
"DeleteVariable",
"Cannot find enclosing scope for variable %s",
3059 declCtx = llvm::dyn_cast<clang::DeclContext>(scopeDecl);
3061 Error(
"DeleteVariable",
3062 "Enclosing scope for variable %s is not a declaration context",
3066 unscopedName += posScope + 2;
3068 clang::NamedDecl* nVarDecl
3069 = cling::utils::Lookup::Named(&
fInterpreter->getSema(), unscopedName, declCtx);
3071 Error(
"DeleteVariable",
"Unknown variable %s", name);
3074 clang::VarDecl* varDecl = llvm::dyn_cast<clang::VarDecl>(nVarDecl);
3076 Error(
"DeleteVariable",
"Entity %s is not a variable", name);
3080 clang::QualType qType = varDecl->getType();
3081 const clang::Type* type = qType->getUnqualifiedDesugaredType();
3084 if (type->isPointerType()) {
3085 int** ppInt = (
int**)
fInterpreter->getAddressOfGlobal(GlobalDecl(varDecl));
3087 if (ppInt) *ppInt = 0;
3097 #if defined(R__MUST_REVISIT)
3098 #if R__MUST_REVISIT(6,2)
3100 Warning(
"SaveContext",
"Cling should provide a way to record a state watermark similar to store_dictposition(&fDictPos)");
3110 #if defined(R__MUST_REVISIT)
3111 #if R__MUST_REVISIT(6,2)
3113 Warning(
"SaveGlobalsContext",
"Cling should provide a way to record a watermark for the list of global variable similar to store_dictposition(&fDictPosGlobals)");
3147 struct AlternateTupleIntDoubleAsc
3153 struct AlternateTupleIntDoubleDes
3161 std::tuple<int,double> value;
3162 AlternateTupleIntDoubleAsc asc;
3163 AlternateTupleIntDoubleDes des;
3165 size_t offset0 = ((
char*)&(std::get<0>(value))) - ((
char*)&value);
3166 size_t offset1 = ((
char*)&(std::get<1>(value))) - ((
char*)&value);
3168 size_t ascOffset0 = ((
char*)&(asc._0)) - ((
char*)&asc);
3169 size_t ascOffset1 = ((
char*)&(asc._1)) - ((
char*)&asc);
3171 size_t desOffset0 = ((
char*)&(des._0)) - ((
char*)&des);
3172 size_t desOffset1 = ((
char*)&(des._1)) - ((
char*)&des);
3174 if (offset0 == ascOffset0 && offset1 == ascOffset1) {
3176 }
else if (offset0 == desOffset0 && offset1 == desOffset1) {
3186 std::string alternateName =
"TEmulatedTuple";
3187 alternateName.append( classname + 5 );
3189 std::string guard_name;
3191 std::ostringstream guard;
3192 guard <<
"ROOT_INTERNAL_TEmulated_";
3193 guard << guard_name;
3195 std::ostringstream alternateTuple;
3196 alternateTuple <<
"#ifndef " << guard.str() <<
"\n";
3197 alternateTuple <<
"#define " << guard.str() <<
"\n";
3198 alternateTuple <<
"namespace ROOT { namespace Internal {\n";
3199 alternateTuple <<
"template <class... Types> struct TEmulatedTuple;\n";
3200 alternateTuple <<
"template <> struct " << alternateName <<
" {\n";
3205 unsigned int nMember = 0;
3206 auto iter = tupleContent.
fElements.begin() + 1;
3207 auto theEnd = tupleContent.
fElements.end() - 1;
3208 while (iter != theEnd) {
3209 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
3216 unsigned int nMember = tupleContent.
fElements.size() - 3;
3217 auto iter = tupleContent.
fElements.rbegin() + 1;
3218 auto theEnd = tupleContent.
fElements.rend() - 1;
3219 while (iter != theEnd) {
3220 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
3227 Fatal(
"TCling::SetClassInfo::AtlernateTuple",
3228 "Layout of std::tuple on this platform is unexpected.");
3233 alternateTuple <<
"};\n";
3234 alternateTuple <<
"}}\n";
3235 alternateTuple <<
"#endif\n";
3237 Error(
"Load",
"Could not declare %s",alternateName.c_str());
3240 alternateName =
"ROOT::Internal::" + alternateName;
3241 return alternateName;
3267 if (strncmp(cl->
GetName(),
"tuple<",strlen(
"tuple<"))==0) {
3298 zombieCandidate =
kTRUE;
3305 zombieCandidate =
kTRUE;
3355 static const char *anonEnum =
"anonymous enum ";
3356 static const int cmplen = strlen(anonEnum);
3358 if (0 == strncmp(name,anonEnum,cmplen)) {
3377 if (isClassOrNamespaceOnly &&
3380 const char *classname =
name;
3391 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
3393 const clang::Decl *decl
3394 = lh.findScope(classname,
3395 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
3396 : cling::LookupHelper::NoDiagnostics,
3400 decl = lh.findScope(buf,
3401 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
3402 : cling::LookupHelper::NoDiagnostics,
3419 clang::ClassTemplateSpecializationDecl *tmpltDecl =
3420 llvm::dyn_cast_or_null<clang::ClassTemplateSpecializationDecl>
3421 (type->getAsCXXRecordDecl());
3422 if (tmpltDecl && !tmpltDecl->getPointOfInstantiation().isValid()) {
3434 if (!tci.IsValid()) {
3441 if (tci.Property() & propertiesMask) {
3477 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
3478 const clang::Decl *decl
3479 = lh.findClassTemplate(name,
3480 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
3481 : cling::LookupHelper::NoDiagnostics);
3483 std::string strname =
"std::";
3485 decl = lh.findClassTemplate(strname,
3486 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
3487 : cling::LookupHelper::NoDiagnostics);
3507 if (t.IsValid() && t.Name()) {
3513 cl->
fBase = listOfBase;
3529 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
3532 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
3533 cling::Interpreter::PushTransactionRAII deserRAII(
fInterpreter);
3535 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
3536 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
3537 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(), declEnd = allDeclContexts.end();
3538 declIter != declEnd; ++declIter) {
3540 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
3541 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
3542 if (
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(*DI)) {
3545 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
3546 llvm::raw_string_ostream stream(buf);
3548 Policy.AnonymousTagLocations =
false;
3549 ED->getNameForDiagnostic(stream, Policy,
false);
3553 const char* name = buf.c_str();
3555 enumList.
Get(ED, name);
3577 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
3581 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
3582 cling::Interpreter::PushTransactionRAII deserRAII(
fInterpreter);
3584 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
3585 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
3586 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(),
3587 declEnd = allDeclContexts.end(); declIter != declEnd; ++declIter) {
3589 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
3590 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
3591 if (
const clang::FunctionTemplateDecl* FTD = dyn_cast<clang::FunctionTemplateDecl>(*DI)) {
3592 funcTempList->
Get(FTD);
3690 if (llvm::isa<clang::NamespaceDecl>(cli->
GetDecl())) {
3699 Error(
"GenerateTClass",
3700 "Cannot find %s::Class_Version()! Class version might be wrong.",
3707 if (newvers == -1) {
3714 callfunc.SetFunc(&mi);
3715 newvers = callfunc.ExecInt(0);
3717 Error(
"GenerateTClass",
3718 "Cannot invoke %s::Class_Version()! Class version might be wrong.",
3722 if (newvers != oldvers) {
3739 static void GenerateTClass_GatherInnerIncludes(cling::Interpreter *interp, TString &includes,
TClingClassInfo *info)
3743 const clang::ClassTemplateSpecializationDecl *templateCl
3744 = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(info->
GetDecl());
3746 for(
unsigned int i=0; i < templateCl->getTemplateArgs().size(); ++i) {
3747 const clang::TemplateArgument &arg( templateCl->getTemplateArgs().get(i) );
3751 if (!uType->isFundamentalType() && !uType->isEnumeralType()) {
3753 const clang::CXXRecordDecl *argdecl = uType->getAsCXXRecordDecl();
3756 TClingClassInfo subinfo(interp,*(argdecl->getASTContext().getRecordType(argdecl).getTypePtr()));
3757 GenerateTClass_GatherInnerIncludes(interp, includes, &subinfo);
3760 llvm::raw_string_ostream OS(Result);
3761 arg.print(argdecl->getASTContext().getPrintingPolicy(),OS);
3762 Warning(
"TCling::GenerateTClass",
"Missing header file for %s",OS.str().c_str());
3777 if (!info || !info->
IsValid()) {
3778 Fatal(
"GenerateTClass",
"Requires a valid ClassInfo object");
3783 std::string classname;
3787 Info(
"GenerateTClass",
"Will (try to) generate the compiled TClass for %s.",classname.c_str());
3791 GenerateTClass_GatherInnerIncludes(
fInterpreter,includes,info);
3797 Error(
"GenerateTClass",
"Even though the dictionary generation for %s seemed successful we can't find the TClass bootstrap!",classname.c_str());
3803 cl =
new TClass(classinfo, version, 0, 0, -1, -1, silent);
3809 cl =
new TClass(classinfo, 1, 0, 0, -1, -1, silent);
3834 if (classes == 0 || classes[0] == 0) {
3838 std::vector<std::string> listClasses;
3840 const char* current = classes, *prev = classes;
3844 if (*current ==
';') {
3845 listClasses.push_back(std::string(prev, current - prev));
3848 else if (*(current + 1) == 0) {
3849 listClasses.push_back(std::string(prev, current + 1 - prev));
3853 std::vector<std::string> listIncludes;
3855 const char* current = includes, *prev = includes;
3859 if (*current ==
';') {
3860 listIncludes.push_back(std::string(prev, current - prev));
3863 else if (*(current + 1) == 0) {
3864 listIncludes.push_back(std::string(prev, current + 1 - prev));
3870 std::vector<std::string>(), std::vector<std::string>());
3891 if (
const ValueDecl* decl = (
const ValueDecl*) d){
3894 if (hasIoName && ioName != name)
return 0;
3912 const clang::Decl* possibleEnum = 0;
3917 const clang::DeclContext* dc = 0;
3918 if (
const clang::Decl* D = cci->
GetDecl()) {
3919 if (!(dc = dyn_cast<clang::NamespaceDecl>(D))) {
3920 dc = dyn_cast<clang::RecordDecl>(D);
3925 possibleEnum = cling::utils::Lookup::Named(&
fInterpreter->getSema(),
name, dc);
3927 Error(
"TCling::GetEnum",
"DeclContext not found for %s .\n", name);
3932 possibleEnum = cling::utils::Lookup::Named(&
fInterpreter->getSema(),
name);
3934 if (possibleEnum && (possibleEnum != (clang::Decl*)-1)
3935 && isa<clang::EnumDecl>(possibleEnum)) {
3936 return possibleEnum;
3948 llvm::StringRef mangled_name = gv->getName();
3957 d = gcl.GetDataMember(mangled_name.str().c_str());
3963 std::string scopename(demangled_name_c);
3964 free(demangled_name_c);
3970 std::string dataname;
3972 if (!strncmp(scopename.c_str(),
"typeinfo for ",
sizeof(
"typeinfo for ")-1)) {
3973 scopename.erase(0,
sizeof(
"typeinfo for ")-1);
3974 }
else if (!strncmp(scopename.c_str(),
"vtable for ",
sizeof(
"vtable for ")-1)) {
3975 scopename.erase(0,
sizeof(
"vtable for ")-1);
3978 std::string::size_type pos = scopename.rfind(
'(');
3979 if (pos != std::string::npos) {
3983 pos = scopename.rfind(
':');
3984 if (pos != std::string::npos) {
3985 if ((pos != 0) && (scopename[pos-1] ==
':')) {
3986 dataname = scopename.substr(pos+1);
3987 scopename.erase(pos-1);
3991 dataname = scopename;
3999 if (scopename.size()) {
4005 d = gcl.GetDataMember(dataname.c_str());
4015 Error(
"GetDataMemberWithValue()",
"not implemented");
4025 Error(
"GetDataMemberAtAddr()",
"not implemented");
4035 const char* params,
Bool_t objectIsConst )
4047 func.SetFunc(&gcl, method, params, &offset);
4053 return mangled_name;
4068 GetMethod(method, proto, objectIsConst, 0 , mode).GetMangledName();
4071 return gcl.GetMethod(method, proto, objectIsConst, 0 , mode).GetMangledName();
4092 func.
SetFunc(&gcl, method, params, &offset);
4121 std::vector<DeclId_t>& res)
const
4124 const clang::Decl* CtxDecl
4126 S.
Context.getTranslationUnitDecl();
4127 const clang::DeclContext*
4128 DeclCtx = llvm::dyn_cast<const clang::RecordDecl>(CtxDecl);
4130 DeclCtx = dyn_cast<clang::NamespaceDecl>(CtxDecl);
4132 clang::DeclarationName DName
4133 = &S.
Context.Idents.get(funcname);
4134 clang::LookupResult
R(S, DName, clang::SourceLocation(),
4135 Sema::LookupOrdinaryName, clang::Sema::ForRedeclaration);
4136 S.LookupQualifiedName(
R, const_cast<DeclContext*>(DeclCtx));
4137 if (R.empty()) return;
4139 res.reserve(res.size() + (R.end() - R.begin()));
4140 for (clang::LookupResult::iterator IR = R.begin(), ER = R.end();
4142 if (
const clang::FunctionDecl* FD
4143 = llvm::dyn_cast<const clang::FunctionDecl>(*IR)) {
4144 if (!FD->getDescribedFunctionTemplate()) {
4191 f = gcl.GetMethod(method, params, objectIsConst, 0 ).GetDeclId();
4233 f = gcl.GetFunctionTemplate(name);
4279 void TCling::Execute(
const char*
function,
const char* params,
int* error)
4288 func.
SetFunc(&cl,
function, params, &offset);
4304 const char* params,
Bool_t objectIsConst,
int* error)
4317 void* address = (
void*)((
Long_t)addr + offset);
4324 const char* params,
int* error)
4326 Execute(obj,cl,method,params,
false,error);
4341 Error(
"Execute",
"No method was defined");
4350 if (argc > nparms) {
4351 Error(
"Execute",
"Too many parameters to call %s, got %d but expected at most %d.",method->
GetName(),argc,nparms);
4354 if (nparms != argc) {
4364 Int_t firstDefault = -1;
4365 for (
Int_t i = 0; i < nparms; i ++) {
4372 if (firstDefault >= 0) {
4373 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);
4375 Error(
"Execute",
"Too few arguments to call %s, got only %d but expected %d.",method->
GetName(),argc,nparms);
4381 const char* listpar =
"";
4382 TString complete(10);
4386 for (
Int_t i = 0; i < argc; i ++) {
4394 TString chpar(
'\"');
4395 chpar += (nxtpar->String()).
ReplaceAll(
"\"",
"\\\"");
4402 complete += nxtpar->String();
4405 listpar = complete.Data();
4420 func.SetArgs(listpar);
4423 const CXXMethodDecl * mdecl = dyn_cast<CXXMethodDecl>(minfo->
GetMethodDecl());
4425 void* address = (
void*)((
Long_t)addr + offset);
4432 const void* args[] ,
4437 Error(
"ExecuteWithArgsAndReturn",
"No method was defined");
4443 func.ExecWithArgsAndReturn(address, args, nargs, ret);
4464 Warning(
"GetTopLevelMacroName",
"Must change return type!");
4511 #if defined(R__MUST_REVISIT)
4512 #if R__MUST_REVISIT(6,0)
4513 Warning(
"GetCurrentMacroName",
"Must change return type!");
4526 TTHREAD_TLS(
char*) t = 0;
4527 TTHREAD_TLS(
unsigned int) tlen = 0;
4529 unsigned int dlen = strlen(typeDesc);
4532 t =
new char[dlen + 1];
4535 const char* s, *template_start;
4536 if (!strstr(typeDesc,
"(*)(")) {
4537 s = strchr(typeDesc,
' ');
4538 template_start = strchr(typeDesc,
'<');
4539 if (!strcmp(typeDesc,
"long long")) {
4540 strlcpy(t, typeDesc, dlen + 1);
4542 else if (!strncmp(typeDesc,
"unsigned ", s + 1 - typeDesc)) {
4543 strlcpy(t, typeDesc, dlen + 1);
4549 else if (s && (template_start == 0 || (s < template_start))) {
4550 strlcpy(t, s + 1, dlen + 1);
4553 strlcpy(t, typeDesc, dlen + 1);
4557 strlcpy(t, typeDesc, dlen + 1);
4560 while (l > 0 && (t[l - 1] ==
'*' || t[l - 1] ==
'&')) {
4574 const std::map<char, unsigned int> keyLenMap = {{
'c',6},{
'n',10},{
't',8},{
'h',7},{
'e',5},{
'v',4}};
4576 if (rootmapfile && *rootmapfile) {
4580 std::ifstream file(rootmapfile);
4581 std::string
line; line.reserve(200);
4582 std::string lib_name; line.reserve(100);
4583 bool newFormat=
false;
4584 while (getline(file, line,
'\n')) {
4586 (strstr(line.c_str(),
"Library.")!=
nullptr || strstr(line.c_str(),
"Declare.")!=
nullptr)) {
4592 if (line.compare(0, 9,
"{ decls }") == 0) {
4595 while (getline(file, line,
'\n')) {
4596 if (line[0] ==
'[')
break;
4597 uniqueString->
Append(line);
4600 const char firstChar=line[0];
4601 if (firstChar ==
'[') {
4603 auto brpos = line.find(
']');
4604 if (brpos == string::npos)
continue;
4605 lib_name = line.substr(1, brpos-1);
4607 while( lib_name[nspaces] ==
' ' ) ++nspaces;
4608 if (nspaces) lib_name.replace(0, nspaces,
"");
4610 TString lib_nameTstr(lib_name.c_str());
4611 TObjArray* tokens = lib_nameTstr.Tokenize(
" ");
4615 Info(
"ReadRootmapFile",
"new section for %s", lib_nameTstr.Data());
4618 Info(
"ReadRootmapFile",
"section for %s (library does not exist)", lib_nameTstr.Data());
4625 auto keyLenIt = keyLenMap.find(firstChar);
4626 if (keyLenIt == keyLenMap.end())
continue;
4627 unsigned int keyLen = keyLenIt->second;
4629 const char *keyname = line.c_str()+keyLen;
4631 Info(
"ReadRootmapFile",
"class %s in %s", keyname, lib_name.c_str());
4634 if(lib_name != isThere->GetValue()){
4635 if (firstChar ==
'n') {
4637 Info(
"ReadRootmapFile",
"namespace %s found in %s is already in %s",
4638 keyname, lib_name.c_str(), isThere->GetValue());
4639 }
else if (firstChar ==
'h'){
4641 lib_name+=isThere->GetValue();
4645 Warning(
"ReadRootmapFile",
"%s %s found in %s is already in %s", line.substr(0, keyLen).c_str(),
4646 keyname, lib_name.c_str(), isThere->GetValue());
4650 Info(
"ReadRootmapFile",
"Key %s was already defined for %s", keyname, lib_name.c_str());
4680 TString
sname =
"system";
4709 using namespace clang;
4711 class ExtVisibleStorageAdder:
public RecursiveASTVisitor<ExtVisibleStorageAdder>{
4717 ExtVisibleStorageAdder(std::unordered_set<const NamespaceDecl*>& nsSet): fNSSet(nsSet) {};
4718 bool VisitNamespaceDecl(NamespaceDecl* nsDecl) {
4722 nsDecl->setHasExternalVisibleStorage();
4723 fNSSet.insert(nsDecl);
4727 std::unordered_set<const NamespaceDecl*>& fNSSet;
4756 TUniqueString uniqueString(1048576);
4764 TObjArray* paths = ldpath.Tokenize(
";");
4766 TObjArray* paths = ldpath.Tokenize(
":");
4773 for (
Int_t j = 0; j < i; j++) {
4774 TString pd = ((
TObjString *)paths->
At(j))->GetString();
4784 Info(
"LoadLibraryMap",
"%s", d.Data());
4789 if (f.EndsWith(
".rootmap")) {
4795 Info(
"LoadLibraryMap",
" rootmap file: %s", p.Data());
4812 if (f.BeginsWith(
"rootmap")) {
4817 Warning(
"LoadLibraryMap",
"please rename %s to end with \".rootmap\"", p.Data());
4830 if (rootmapfile && *rootmapfile) {
4837 else if (res == -3) {
4847 while ((rec = (
TEnvRec*) next())) {
4849 if (!strncmp(cls.Data(),
"Library.", 8) && cls.Length() > 8) {
4856 TObjArray* tokens = libs.Tokenize(delim);
4861 cls.ReplaceAll(
"@@",
"::");
4864 cls.ReplaceAll(
"-",
" ");
4868 Info(
"LoadLibraryMap",
"class %s in %s", cls.Data(), wlib);
4871 Info(
"LoadLibraryMap",
"class %s in %s (library does not exist)", cls.Data(), lib);
4886 else if (!strncmp(cls.Data(),
"Declare.", 8) && cls.Length() > 8) {
4890 cls.ReplaceAll(
"-",
" ");
4896 cling::Transaction* T =
nullptr;
4898 assert(cling::Interpreter::kSuccess == compRes &&
"A declaration in a rootmap could not be compiled");
4900 if (compRes!=cling::Interpreter::kSuccess){
4902 "Problems in %s declaring '%s' were encountered.", rootmapfile, uniqueString.
Data()) ;
4907 for (
auto declIt = T->decls_begin(); declIt < T->decls_end(); ++declIt) {
4908 if (declIt->m_DGR.isSingleDecl()) {
4909 if (Decl* D = declIt->m_DGR.getSingleDecl()) {
4910 if (NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(D)) {
4911 evsAdder.TraverseDecl(NSD);
4944 const TObjArray* sharedLibL = sharedLibLStr.Tokenize(
" ");
4946 for (
Int_t ilib = 0; ilib < nrSharedLibs; ilib++) {
4947 const TString sharedLibStr = ((
TObjString*)sharedLibL->
At(ilib))->GetString();
4953 TString rootMapBaseStr = sharedLibBaseStr;
4954 if (sharedLibBaseStr.EndsWith(
".dll")) {
4955 rootMapBaseStr.ReplaceAll(
".dll",
"");
4957 else if (sharedLibBaseStr.EndsWith(
".DLL")) {
4958 rootMapBaseStr.ReplaceAll(
".DLL",
"");
4960 else if (sharedLibBaseStr.EndsWith(
".so")) {
4961 rootMapBaseStr.ReplaceAll(
".so",
"");
4963 else if (sharedLibBaseStr.EndsWith(
".sl")) {
4964 rootMapBaseStr.ReplaceAll(
".sl",
"");
4966 else if (sharedLibBaseStr.EndsWith(
".dl")) {
4967 rootMapBaseStr.ReplaceAll(
".dl",
"");
4969 else if (sharedLibBaseStr.EndsWith(
".a")) {
4970 rootMapBaseStr.ReplaceAll(
".a",
"");
4973 Error(
"ReloadAllSharedLibraryMaps",
"Unknown library type %s", sharedLibBaseStr.Data());
4977 rootMapBaseStr +=
".rootmap";
4980 Error(
"ReloadAllSharedLibraryMaps",
"Could not find rootmap %s in path", rootMap);
4987 Error(
"ReloadAllSharedLibraryMaps",
"Error loading map %s", rootMap);
5005 const TObjArray* sharedLibL = sharedLibLStr.Tokenize(
" ");
5007 const TString sharedLibStr = ((
TObjString*)sharedLibL->
At(ilib))->GetString();
5022 if (!
fMapfile || !library || !*library) {
5025 TString libname(library);
5026 Ssiz_t idx = libname.Last(
'.');
5028 libname.Remove(idx);
5030 size_t len = libname.Length();
5035 while ((rec = (
TEnvRec *) next())) {
5037 if (cls.Length() > 2) {
5044 TObjArray* tokens = libs.Tokenize(delim);
5046 if (!strncmp(cls.Data(),
"Library.", 8) && cls.Length() > 8) {
5050 cls.ReplaceAll(
"@@",
"::");
5053 cls.ReplaceAll(
"-",
" ");
5055 if (!strncmp(lib, libname.Data(), len)) {
5057 Error(
"UnloadLibraryMap",
"entry for <%s, %s> not found in library map table", cls.Data(), lib);
5065 TString library_rootmap(library);
5066 if (!library_rootmap.EndsWith(
".rootmap"))
5067 library_rootmap.Append(
".rootmap");
5087 TString key = TString(
"Library.") + cls;
5090 key.ReplaceAll(
"::",
"@@");
5093 key.ReplaceAll(
" ",
"-");
5122 free(demangled_name);
5138 std::string demangled_name(demangled_name_c);
5139 free(demangled_name_c);
5152 result =
AutoLoad(demangled_name.c_str(), knowDictNotLoaded);
5177 Info(
"TCling::AutoLoad",
5178 "Trying to autoload for %s", cls);
5184 Info(
"TCling::AutoLoad",
5185 "Disabled due to gROOT or gInterpreter being invalid/not ready (the class name is %s)", cls);
5192 Info(
"TCling::AutoLoad",
5193 "Explicitly disabled (the class name is %s)", cls);
5209 if (!deplibs.IsNull()) {
5211 TObjArray* tokens = deplibs.Tokenize(delim);
5214 if (
gROOT->LoadClass(cls, deplib) == 0) {
5216 Info(
"TCling::AutoLoad",
5217 "loaded dependent library %s for %s", deplib, cls);
5221 Error(
"TCling::AutoLoad",
5222 "failure loading dependent library %s for %s",
5227 if (lib && lib[0]) {
5228 if (
gROOT->LoadClass(cls, lib) == 0) {
5230 Info(
"TCling::AutoLoad",
5231 "loaded library %s for %s", lib, cls);
5236 Error(
"TCling::AutoLoad",
5237 "failure loading library %s for %s", lib, cls);
5252 cling::Interpreter *interpreter)
5254 std::string code = gNonInterpreterClassDef ;
5261 code += (
"#include \"");
5265 code += (
"#ifdef __ROOTCLING__\n"
5266 "#undef __ROOTCLING__\n"
5267 + gInterpreterClassDef +
5270 cling::Interpreter::CompilationResult cr;
5276 Sema &SemaR = interpreter->getSema();
5278 clangDiagSuppr diagSuppr(SemaR.getDiagnostics());
5280 #if defined(R__MUST_REVISIT)
5281 #if R__MUST_REVISIT(6,2)
5282 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
5286 cr = interpreter->parseForModule(code);
5304 Int_t nHheadersParsed = 0;
5307 bool skipFirstEntry =
false;
5308 std::vector<std::string> autoparseKeys;
5309 if (strchr(cls,
'<')) {
5315 if (!autoparseKeys.empty()){
5316 TString templateName(autoparseKeys[0]);
5317 auto tokens = templateName.Tokenize(
"::");
5318 clang::NamedDecl* previousScopeAsNamedDecl =
nullptr;
5319 clang::DeclContext* previousScopeAsContext =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
5321 previousScopeAsContext =
fInterpreter->getSema().getStdNamespace();
5322 for (
auto const scopeObj : *tokens){
5323 auto scopeName = ((
TObjString*) scopeObj)->String().Data();
5324 previousScopeAsNamedDecl = cling::utils::Lookup::Named(&
fInterpreter->getSema(), scopeName, previousScopeAsContext);
5326 if ((clang::NamedDecl*)-1 == previousScopeAsNamedDecl)
break;
5327 previousScopeAsContext = llvm::dyn_cast_or_null<clang::DeclContext>(previousScopeAsNamedDecl);
5328 if (!previousScopeAsContext)
break;
5332 if ((clang::NamedDecl*)-1 != previousScopeAsNamedDecl) {
5333 if (
auto templateDecl = llvm::dyn_cast_or_null<clang::ClassTemplateDecl>(previousScopeAsNamedDecl)) {
5334 if (
auto templatedDecl = templateDecl->getTemplatedDecl()) {
5335 skipFirstEntry =
nullptr != templatedDecl->getDefinition();
5342 if (topLevel) autoparseKeys.emplace_back(cls);
5344 for (
const auto & apKeyStr : autoparseKeys) {
5345 if (skipFirstEntry) {
5346 skipFirstEntry=
false;
5349 if (apKeyStr.empty())
continue;
5350 const char *apKey = apKeyStr.c_str();
5354 Info(
"TCling::AutoParse",
5355 "Starting autoparse for %s\n", apKey);
5360 const cling::Transaction *T =
fInterpreter->getCurrentTransaction();
5362 auto const &hNamesPtrs = iter->second;
5364 Info(
"TCling::AutoParse",
5365 "We can proceed for %s. We have %s headers.", apKey, std::to_string(hNamesPtrs.size()).c_str());
5367 for (
auto & hName : hNamesPtrs) {
5369 if (0 !=
fPayloads.count(normNameHash)) {
5370 float initRSSval=0.f, initVSIZEval=0.f;
5372 (
void) initVSIZEval;
5375 "Parsing full payload for %s", apKey);
5382 if (cRes != cling::Interpreter::kSuccess) {
5383 if (hName[0] ==
'\n')
5384 Error(
"AutoParse",
"Error parsing payload code for class %s with content:\n%s", apKey, hName);
5393 Info(
"Autoparse",
">>> RSS key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initRSSval, endRSSval, endRSSval-initRSSval);
5394 Info(
"Autoparse",
">>> VSIZE key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initVSIZEval, endVSIZEval, endVSIZEval-initVSIZEval);
5400 "Parsing single header %s", hName);
5403 if (cRes != cling::Interpreter::kSuccess) {
5404 Error(
"AutoParse",
"Error parsing headerfile %s for class %s.", hName, apKey);
5416 if (strchr(apKey,
'<')) {
5423 return nHheadersParsed;
5444 Info(
"TCling::AutoParse",
5445 "Trying to autoparse for %s", cls);
5465 if (nHheadersParsed != 0) {
5484 return nHheadersParsed > 0 ? 1 : 0;
5497 mangled_name.c_str())) {
5508 std::string
name(demangled_name_c);
5509 free(demangled_name_c);
5517 if (!strncmp(name.c_str(),
"typeinfo for ",
sizeof(
"typeinfo for ")-1)) {
5518 name.erase(0,
sizeof(
"typeinfo for ")-1);
5519 }
else if (!strncmp(name.c_str(),
"vtable for ",
sizeof(
"vtable for ")-1)) {
5520 name.erase(0,
sizeof(
"vtable for ")-1);
5521 }
else if (!strncmp(name.c_str(),
"operator",
sizeof(
"operator")-1)
5522 && !isalnum(name[
sizeof(
"operator")])) {
5524 name.erase(0,
sizeof(
"operator")-1);
5525 std::string::size_type pos = name.rfind(
'(');
5526 if (pos != std::string::npos) {
5527 name.erase(0, pos + 1);
5528 pos = name.find(
",");
5529 if (pos != std::string::npos) {
5533 pos = name.rfind(
" const");
5534 if (pos != std::string::npos) {
5535 name.erase(pos, strlen(
" const"));
5537 while (!name.empty() && strchr(
"&*", name.back()))
5538 name.erase(name.length() - 1);
5542 std::string::size_type pos = name.rfind(
'(');
5543 if (pos != std::string::npos) {
5547 pos = name.rfind(
':');
5548 if (pos != std::string::npos) {
5549 if ((pos != 0) && (name[pos-1] ==
':')) {
5557 if (libs.IsNull()) {
5566 while (libs.Tokenize(lib, posLib)) {
5576 void* addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(mangled_name.c_str());
5603 const NamedDecl* ND =
static_cast<const NamedDecl*
>(vTD);
5604 const TagDecl* td = dyn_cast<TagDecl>(ND);
5608 tdDef = td->getDefinition();
5614 if (llvm::isa<clang::FunctionDecl>(td->getDeclContext())) {
5618 clang::QualType
type( td->getTypeForDecl(), 0 );
5620 auto declName=ND->getNameAsString();
5628 name = ND->getNameAsString();
5643 const TagDecl* tdOld = llvm::dyn_cast_or_null<TagDecl>(cci->
GetDecl());
5644 if (!tdOld || (tdDef && tdDef != tdOld)) {
5701 std::set<TClass*> modifiedTClasses;
5706 bool isTUTransaction =
false;
5707 if (!T.empty() && T.decls_begin() + 1 == T.decls_end() && !T.hasNestedTransactions()) {
5708 clang::Decl* FirstDecl = *(T.decls_begin()->m_DGR.begin());
5709 if (llvm::isa<clang::TranslationUnitDecl>(FirstDecl)) {
5712 isTUTransaction =
true;
5716 std::set<const void*> TransactionDeclSet;
5717 if (!isTUTransaction && T.decls_end() - T.decls_begin()) {
5718 const clang::Decl* WrapperFD = T.getWrapperFD();
5719 for (cling::Transaction::const_iterator
I = T.decls_begin(),
E = T.decls_end();
5721 if (
I->m_Call != cling::Transaction::kCCIHandleTopLevelDecl
5722 &&
I->m_Call != cling::Transaction::kCCIHandleTagDeclDefinition)
5725 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
5726 DE =
I->m_DGR.end(); DI != DE; ++DI) {
5727 if (*DI == WrapperFD)
5729 TransactionDeclSet.insert(*DI);
5730 ((
TCling*)
gCling)->HandleNewDecl(*DI,
false, modifiedTClasses);
5737 for (cling::Transaction::const_iterator
I = T.deserialized_decls_begin(),
5738 E = T.deserialized_decls_end();
I !=
E; ++
I) {
5739 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
5740 DE =
I->m_DGR.end(); DI != DE; ++DI)
5741 if (TransactionDeclSet.find(*DI) == TransactionDeclSet.end()) {
5757 std::vector<TClass*> modifiedTClassesDiff(modifiedTClasses.size());
5758 std::vector<TClass*>::iterator it;
5759 it = set_difference(modifiedTClasses.begin(), modifiedTClasses.end(),
5762 modifiedTClassesDiff.begin());
5763 modifiedTClassesDiff.resize(it - modifiedTClassesDiff.begin());
5766 ((
TCling*)
gCling)->GetModTClasses().insert(modifiedTClassesDiff.begin(),
5767 modifiedTClassesDiff.end());
5768 for (std::vector<TClass*>::const_iterator
I = modifiedTClassesDiff.begin(),
5769 E = modifiedTClassesDiff.end();
I !=
E; ++
I) {
5771 if (!
gROOT->GetListOfClasses()->FindObject(*
I)) {
5775 cling::Interpreter::PushTransactionRAII RAII(
fInterpreter);
5795 for (DeclContext::decl_iterator RI = DC->decls_begin(), RE = DC->decls_end(); RI != RE; ++RI) {
5796 if (isa<VarDecl>(*RI) || isa<FieldDecl>(*RI)) {
5797 const clang::ValueDecl* VD = dyn_cast<ValueDecl>(*RI);
5801 datamembers->
Unload(var);
5804 }
else if (
const FunctionDecl* FD = dyn_cast<FunctionDecl>(*RI)) {
5807 functions->
Unload(
function);
5808 function->Update(0);
5810 }
else if (
const EnumDecl* ED = dyn_cast<EnumDecl>(*RI)) {
5818 if (enumConst && enumConst->IsValid()) {
5819 datamembers->
Unload(enumConst);
5820 enumConst->Update(0);
5826 }
else if (
const FunctionTemplateDecl* FTD = dyn_cast<FunctionTemplateDecl>(*RI)) {
5828 if (functiontemplate) {
5829 functiontemplates->
Unload(functiontemplate);
5830 functiontemplate->
Update(0);
5847 cling::Transaction::const_nested_iterator iNested = T.nested_begin();
5848 for(cling::Transaction::const_iterator
I = T.decls_begin(),
E = T.decls_end();
5850 if (
I->m_Call == cling::Transaction::kCCIHandleVTable)
5853 if (
I->m_Call == cling::Transaction::kCCINone) {
5859 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
5860 DE =
I->m_DGR.end(); DI != DE; ++DI) {
5864 if ( (*DI)->isFromASTFile() )
5868 if (isa<VarDecl>(*DI) || isa<EnumConstantDecl>(*DI)) {
5886 }
else if (
const FunctionDecl* FD = dyn_cast<FunctionDecl>(*DI)) {
5888 if (
function && function->IsValid()) {
5889 functions->
Unload(
function);
5890 function->Update(0);
5893 }
else if (
const FunctionTemplateDecl* FTD = dyn_cast<FunctionTemplateDecl>(*DI)) {
5895 if (functiontemplate) {
5896 functiontemplates->
Unload(functiontemplate);
5897 functiontemplate->
Update(0);
5900 }
else if (
const EnumDecl* ED = dyn_cast<EnumDecl>(*DI)) {
5909 globals->
Unload(enumConst);
5910 enumConst->Update(0);
5918 }
else if (
const clang::RecordDecl* RD = dyn_cast<RecordDecl>(*DI)) {
5919 std::vector<TClass*> vectTClass;
5921 if (RD->isCompleteDefinition()) {
5923 for (std::vector<TClass*>::iterator CI = vectTClass.begin(), CE = vectTClass.end();
5926 (*CI)->ResetClassInfo();
5931 }
else if (
const clang::NamespaceDecl* ND = dyn_cast<NamespaceDecl>(*DI)) {
5932 std::vector<TClass*> vectTClass;
5934 for (std::vector<TClass*>::iterator CI = vectTClass.begin(), CE = vectTClass.end();
5937 if (ND->isOriginalNamespace()) {
5938 (*CI)->ResetClassInfo();
5954 std::size_t normNameHash = triter->second;
5960 auto const &hNamesPtrs = iter->second;
5961 for (
auto &hName : hNamesPtrs) {
5963 Info(
"TransactionRollback",
5964 "Restoring ability to autoaparse: %s", hName);
6003 if (!cls || !*cls) {
6011 const char* libs = libs_record->
GetValue();
6012 return (*libs) ? libs : 0;
6016 TString
c = TString(
"Library.") + cls;
6019 c.ReplaceAll(
"::",
"@@");
6022 c.ReplaceAll(
" ",
"-");
6029 const char* libs = libs_record->
GetValue();
6030 return (*libs) ? libs : 0;
6045 if (!
fMapfile || !lib || !lib[0]) {
6048 TString libname(lib);
6049 Ssiz_t idx = libname.Last(
'.');
6051 libname.Remove(idx);
6055 size_t len = libname.Length();
6056 while ((rec = (
TEnvRec*) next())) {
6057 const char* libs = rec->
GetValue();
6058 if (!strncmp(libs, libname.Data(), len) && strlen(libs) >= len
6059 && (!libs[len] || libs[len] ==
' ' || libs[len] ==
'.')) {
6072 #if defined(R__MUST_REVISIT)
6073 #if R__MUST_REVISIT(6,2)
6074 Warning(
"IsErrorMessagesEnabled",
"Interface not available yet.");
6086 #if defined(R__MUST_REVISIT)
6087 #if R__MUST_REVISIT(6,2)
6088 Warning(
"SetErrorMessages",
"Interface not available yet.");
6104 llvm::SmallVector<std::string, 10> includePaths;
6106 fInterpreter->GetIncludePaths(includePaths,
false,
true);
6107 if (
const size_t nPaths = includePaths.size()) {
6108 assert(!(nPaths & 1) &&
"GetIncludePath, number of paths and options is not equal");
6110 for (
size_t i = 0; i < nPaths; i += 2) {
6115 if (includePaths[i] !=
"-I")
6118 fIncludePath.Append(includePaths[i + 1], includePaths[i + 1].length());
6149 assert(fout != 0 &&
"DisplayIncludePath, 'fout' parameter is null");
6151 llvm::SmallVector<std::string, 10> includePaths;
6153 fInterpreter->GetIncludePaths(includePaths,
false,
true);
6154 if (
const size_t nPaths = includePaths.size()) {
6155 assert(!(nPaths & 1) &&
"DisplayIncludePath, number of paths and options is not equal");
6157 std::string allIncludes(
"include path:");
6158 for (
size_t i = 0; i < nPaths; i += 2) {
6160 allIncludes += includePaths[i];
6162 if (includePaths[i] !=
"-I")
6164 allIncludes += includePaths[i + 1];
6167 fprintf(fout,
"%s\n", allIncludes.c_str());
6186 #if defined(R__MUST_REVISIT)
6187 #if R__MUST_REVISIT(6,2)
6188 Warning(
"GenericError",
"Interface not available yet.");
6218 Error(
"Getgvp",
"This was controlling the behavior of the wrappers for object construction and destruction.\nThis is now a nop and likely change the behavior of the calling routines.");
6226 Error(
"Getp2f2funcname",
"Will not be implemented: "
6227 "all function pointers are compiled!");
6236 #if defined(R__MUST_REVISIT)
6237 #if R__MUST_REVISIT(6,2)
6238 Warning(
"GetSecurityError",
"Interface not available yet.");
6249 cling::Interpreter::CompilationResult compRes;
6250 cling::MetaProcessor::MaybeRedirectOutputRAII RAII(
fMetaProcessor);
6252 return compRes == cling::Interpreter::kFailure;
6263 return (
fInterpreter->declare(text) == cling::Interpreter::kSuccess);
6271 TTHREAD_TLS_DECL(std::string,buffer);
6273 return buffer.c_str();
6339 #if defined(R__MUST_REVISIT)
6340 #if R__MUST_REVISIT(6,2)
6341 Warning(
"SetErrmsgcallback",
"Interface not available yet.");
6353 Error(
"Setgvp",
"This was controlling the behavior of the wrappers for object construction and destruction.\nThis is now a nop and likely change the behavior of the calling routines.");
6361 Error(
"SetRTLD_NOW()",
"Will never be implemented! Don't use!");
6368 Error(
"SetRTLD_LAZY()",
"Will never be implemented! Don't use!");
6383 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
6384 std::string canonical = DLM->lookupLibrary(path);
6385 if (canonical.empty()) {
6389 cling::Interpreter::CompilationResult compRes;
6390 cling::MetaProcessor::MaybeRedirectOutputRAII RAII(
fMetaProcessor);
6392 return compRes == cling::Interpreter::kFailure;
6408 std::vector<std::string>& completions)
6419 auto compRes = interpreter->evaluate(code, *V);
6420 return compRes!=cling::Interpreter::kSuccess ? 0 : 1 ;
6441 if (value.isValid() && value.needsManagedAllocation()) {
6454 cling::Interpreter *interpreter = ((
TCling*)
gCling)->GetInterpreter();
6464 auto iSpecObj = iSpecObjMap->second.find(Name);
6465 if (iSpecObj != iSpecObjMap->second.end()) {
6467 return iSpecObj->second;
6473 Sema &SemaR = interpreter->getSema();
6474 ASTContext&
C = SemaR.getASTContext();
6475 Preprocessor &PP = SemaR.getPreprocessor();
6476 Parser&
P =
const_cast<Parser&
>(interpreter->getParser());
6477 Preprocessor::CleanupAndRestoreCacheRAII cleanupRAII(PP);
6478 Parser::ParserCurTokRestoreRAII savedCurToken(P);
6481 Token& Tok =
const_cast<Token&
>(P.getCurToken());
6482 Tok.setKind(tok::semi);
6488 Sema::ContextAndScopeRAII pushedDCAndS(SemaR, C.getTranslationUnitDecl(),
6491 TObject* specObj =
gROOT->FindSpecialObject(Name, LookupCtx);
6494 Error(
"GetObjectAddress",
"Got a special object without LookupCtx!");
6508 clang::CXXRecordDecl* klass)
const
6510 using namespace clang;
6511 ASTContext& Ctx = klass->getASTContext();
6512 FriendDecl::FriendUnion friendUnion(
function);
6515 FriendDecl* friendDecl = FriendDecl::Create(Ctx, klass, sl, friendUnion, sl);
6516 klass->pushFriendDecl(friendDecl);
6530 if (func)
return ((
TClingCallFunc*)func)->GetDecl()->getCanonicalDecl();
6601 f->
Exec(address, &val);
6615 const void* args[] ,
6782 f->
SetFunc(ci, method, params, offset);
6787 void TCling::CallFunc_SetFunc(CallFunc_t* func, ClassInfo_t* info,
const char* method,
const char* params,
bool objectIsConst,
Long_t* offset)
const
6791 f->
SetFunc(ci, method, params, objectIsConst, offset);
6819 f->
SetFuncProto(ci, method, proto, objectIsConst, offset, mode);
6829 llvm::SmallVector<clang::QualType, 4> funcProto;
6830 for (std::vector<TypeInfo_t*>::const_iterator iter = proto.begin(), end = proto.end();
6831 iter != end; ++iter) {
6832 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
6844 llvm::SmallVector<clang::QualType, 4> funcProto;
6845 for (std::vector<TypeInfo_t*>::const_iterator iter = proto.begin(), end = proto.end();
6846 iter != end; ++iter) {
6847 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
6849 f->
SetFuncProto(ci, method, funcProto, objectIsConst, offset, mode);
6864 if (!declid)
return kFALSE;
6866 const clang::Decl *scope;
6868 else scope =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
6870 const clang::Decl *decl =
reinterpret_cast<const clang::Decl*
>(declid);
6871 const clang::DeclContext *ctxt = clang::Decl::castToDeclContext(scope);
6872 if (!decl || !ctxt)
return kFALSE;
6873 if (decl->getDeclContext()->Equals(ctxt))
6875 else if (decl->getDeclContext()->isTransparentContext() &&
6876 decl->getDeclContext()->getParent()->Equals(ctxt))
6948 return TClinginfo->
GetMethodNArg(method, proto, objectIsConst, mode);
6973 TClinginfo->
Init(name);
6982 TClinginfo->
Init(tagnum);
6990 return TClinginfo->
IsBase(name);
7021 return TClinginfo->
IsValidMethod(method, proto,
false, offset, mode);
7029 return TClinginfo->
IsValidMethod(method, proto, objectIsConst, offset, mode);
7037 return TClinginfo->
Next();
7085 return TClinginfo->
Size();
7093 return TClinginfo->
Tagnum();
7109 TTHREAD_TLS_DECL(std::string,
output);
7119 return TClinginfo->
Name();
7127 return TClinginfo->
Title();
7164 ClassInfo_t* base)
const
7177 return TClinginfo->
Next();
7185 return TClinginfo->
Next(onlyDirect);
7193 return TClinginfo->
Offset(address, isDerivedObject);
7206 return TClinginfo->
GetBaseOffset(TClinginfoBase, address, isDerivedObject);
7222 return (ClassInfo_t *)TClinginfo->
GetBase();
7230 return TClinginfo->
Tagnum();
7238 TTHREAD_TLS_DECL(std::string,
output);
7248 return TClinginfo->
Name();
7293 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
7294 const clang::ValueDecl* vd = llvm::dyn_cast_or_null<clang::ValueDecl>(decl);
7335 return TClinginfo->
Offset();
7383 return TClinginfo->
Name();
7391 return TClinginfo->
Title();
7398 TTHREAD_TLS_DECL(std::string,result);
7402 return result.c_str();
7409 Decl* decl =
static_cast<Decl*
>(
const_cast<void*
>(declId));
7410 ASTContext &C = decl->getASTContext();
7411 SourceRange commentRange;
7412 decl->addAttr(
new (C) AnnotateAttr( commentRange, C, attribute, 0 ) );
7422 static void ConstructorName(std::string &name,
const clang::NamedDecl *decl,
7423 cling::Interpreter &interp,
7426 const clang::TypeDecl* td = llvm::dyn_cast<clang::TypeDecl>(decl->getDeclContext());
7429 clang::QualType qualType(td->getTypeForDecl(),0);
7431 unsigned int level = 0;
7432 for(
size_t cursor = name.length()-1; cursor != 0; --cursor) {
7433 if (name[cursor] ==
'>') ++level;
7434 else if (name[cursor] ==
'<' && level) --level;
7435 else if (level == 0 && name[cursor] ==
':') {
7436 name.erase(0,cursor+1);
7447 if (llvm::isa<clang::CXXConstructorDecl>(decl))
7451 }
else if (llvm::isa<clang::CXXDestructorDecl>(decl))
7454 output.insert(output.begin(),
'~');
7456 llvm::raw_string_ostream stream(output);
7457 auto printPolicy = decl->getASTContext().getPrintingPolicy();
7459 printPolicy.AnonymousTagLocations =
false;
7460 decl->getNameForDiagnostic(stream, printPolicy,
false);
7490 return (FuncTempInfo_t*)
const_cast<void*
>(declid);
7501 return (FuncTempInfo_t*)ft_info;
7521 if (!ft_info)
return 0;
7522 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
7523 return ft->getTemplateParameters()->size();
7532 if (!ft_info)
return 0;
7533 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
7534 return ft->getTemplateParameters()->getMinRequiredArguments();
7542 if (!ft_info)
return 0;
7547 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
7549 switch (ft->getAccess()) {
7550 case clang::AS_public:
7553 case clang::AS_protected:
7556 case clang::AS_private:
7559 case clang::AS_none:
7560 if (ft->getDeclContext()->isNamespace())
7568 const clang::FunctionDecl *fd = ft->getTemplatedDecl();
7569 if (
const clang::CXXMethodDecl *md =
7570 llvm::dyn_cast<clang::CXXMethodDecl>(fd)) {
7571 if (md->getTypeQualifiers() & clang::Qualifiers::Const) {
7574 if (md->isVirtual()) {
7580 if (
const clang::CXXConstructorDecl *cd =
7581 llvm::dyn_cast<clang::CXXConstructorDecl>(md)) {
7582 if (cd->isExplicit()) {
7586 else if (
const clang::CXXConversionDecl *cd =
7587 llvm::dyn_cast<clang::CXXConversionDecl>(md)) {
7588 if (cd->isExplicit()) {
7602 if (!ft_info)
return;
7603 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
7615 if (!ft_info)
return;
7616 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
7620 if (
const RedeclarableTemplateDecl *AnnotFD
7622 if (AnnotateAttr *
A = AnnotFD->getAttr<AnnotateAttr>()) {
7623 output =
A->getAnnotation().str();
7627 if (!ft->isFromASTFile()) {
7677 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
7679 const clang::FunctionDecl* fd = llvm::dyn_cast_or_null<clang::FunctionDecl>(decl);
7711 return info->
NArg();
7727 return info->
Next();
7751 return (TypeInfo_t*)info->
Type();
7759 TTHREAD_TLS_DECL(TString, mangled_name);
7761 return mangled_name;
7804 return info->
Title();
7823 if (info && info->
IsValid()) {
7825 clang::QualType QT( typeinfo->
GetQualType().getCanonicalType() );
7826 if (QT->isEnumeralType()) {
7828 }
else if (QT->isPointerType()) {
7830 QT = llvm::cast<clang::PointerType>(QT)->getPointeeType();
7831 if ( QT->isCharType() ) {
7836 }
else if ( QT->isFloatingType() ) {
7837 int sz = typeinfo->
Size();
7838 if (sz == 4 || sz == 8) {
7844 }
else if ( QT->isIntegerType() ) {
7845 int sz = typeinfo->
Size();
7898 return (MethodArgInfo_t*)
7915 return info->
Next();
7939 return info->
Name();
7999 TClinginfo->
Init(name);
8015 return TClinginfo->
Name();
8039 return TClinginfo->
Size();
8089 const char* name)
const
8093 TClinginfo->
Init(name);
8109 return TClinginfo->
Next();
8125 return TClinginfo->
Size();
8141 return TClinginfo->
Name();
8149 return TClinginfo->
Title();
8151
int TCling__AutoLoadCallback(const char *className)
virtual TObject * FindObject(const TObject *obj) const
Find object using its hash value (returned by its Hash() member).
virtual MethodArgInfo_t * MethodArgInfo_Factory() const
Describe Streamer information for one class version.
const char * GetIncludePath()
Refresh the list of include paths known to the interpreter and return it with -I prepended.
void ResetCaches()
To clean out all caches.
virtual Long_t MethodInfo_Property(MethodInfo_t *minfo) const
virtual Long_t ClassInfo_ClassProperty(ClassInfo_t *info) const
long TypeProperty() const
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual Int_t GetEntries() const
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual void SetTempLevel(int val) const
Create / close a scope for temporaries.
const clang::FunctionTemplateDecl * GetFunctionTemplate(const char *fname) const
virtual void SetRcName(const char *name)
ETupleOrdering
Check in what order the member of a tuple are layout.
TObject * GetObjectAddress(const char *Name, void *&LookupCtx)
If the interpreter encounters Name, check whether that is an object ROOT could retrieve.
A collection of TDataMember objects designed for fast access given a DeclId_t and for keep track of T...
TClass *(* DictFuncPtr_t)()
The TEnum class implements the enum type.
virtual DeclId_t GetDataMemberAtAddr(const void *addr) const
Return pointer to cling DeclId for a data member with a given name.
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form: ~~~ {.cpp} [path/]macro.C[+|++[k|f|g|O|c|s|d|v|-]][(args)]...
int TCling__IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *nsDecl)
This class defines an abstract interface to a generic command line interpreter.
int TCling__CompileMacro(const char *fileName, const char *options)
const char * Name() const
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 ...
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...
virtual void SetRTLD_NOW() const
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.e.
void TransactionRollback(const cling::Transaction &T)
virtual int TypedefInfo_Size(TypedefInfo_t *tinfo) const
virtual TVirtualMutex * Factory(Bool_t=kFALSE)=0
virtual void SetAllocunlockfunc(void(*)()) const
[Place holder for Mutex Unlock] Provide the interpreter with a way to release a lock used to protect ...
virtual bool ClassInfo_HasDefaultConstructor(ClassInfo_t *info) const
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
void LibraryLoaded(const void *dyLibHandle, const char *canonicalName)
Bool_t HandleNewTransaction(const cling::Transaction &T)
Helper function to increase the internal Cling count of transactions that change the AST...
virtual CallFuncIFacePtr_t CallFunc_IFacePtr(CallFunc_t *func) const
void TCling__UpdateListsOnCommitted(const cling::Transaction &T, cling::Interpreter *)
virtual void PostLoadCheck()
Do the initialization that can only be done after the CINT dictionary has been fully populated and ca...
virtual void BaseClassInfo_Delete(BaseClassInfo_t *bcinfo) const
virtual DataMemberInfo_t * DataMemberInfo_Factory(ClassInfo_t *clinfo=0) const
virtual bool CallFunc_IsValid(CallFunc_t *func) const
static void ConstructorName(std::string &name, const clang::NamedDecl *decl, cling::Interpreter &interp, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt)
R__EXTERN Int_t gErrorIgnoreLevel
virtual int ClassInfo_Next(ClassInfo_t *info) const
virtual const char * WorkingDirectory()
Return working directory.
virtual const char * DataMemberInfo_TypeName(DataMemberInfo_t *dminfo) const
virtual void CallFunc_ExecWithReturn(CallFunc_t *func, void *address, void *ret) const
virtual void StackTrace()
Print a stack trace.
std::map< SpecialObjectLookupCtx_t, SpecialObjectMap_t > fSpecialObjectMaps
virtual TypedefInfo_t * TypedefInfo_FactoryCopy(TypedefInfo_t *tinfo) const
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
static Bool_t Check(const char *cname, std::string &normname)
static const char **& GetExtraInterpreterArgs()
static cling::Interpreter::CompilationResult ExecAutoParse(const char *what, Bool_t header, cling::Interpreter *interpreter)
Parse the payload or header.
void Fatal(const char *location, const char *msgfmt,...)
void RegisterLoadedSharedLibrary(const char *name)
Register a new shared library name with the interpreter; add it to fSharedLibs.
Collectable string class.
static void AddClassToDeclIdMap(TDictionary::DeclId_t id, TClass *cl)
static: Add a TClass* to the map of classes.
const char * Name() const
virtual DeclId_t GetEnum(TClass *cl, const char *name) const
Return pointer to cling Decl of global/static variable that is located at the address given by addr...
R__EXTERN TClassTable * gClassTable
TClass * GetClass() const
const char * GetPrototype(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
void UpdateListsOnCommitted(const cling::Transaction &T)
TDictionary::DeclId_t DeclId_t
virtual int BaseClassInfo_Next(BaseClassInfo_t *bcinfo) const
RooArgList L(const RooAbsArg &v1)
void * llvmLazyFunctionCreator(const std::string &mangled_name)
Autoload a library provided the mangled name of a missing symbol.
TEnum * Find(DeclId_t id) const
Return the TEnum corresponding to the Decl 'id' or NULL if it does not exist.
Dictionary for function template This class describes one single function template.
double ExecDouble(void *address)
void Init(const char *name)
virtual TypeInfo_t * TypeInfo_FactoryCopy(TypeInfo_t *) const
All ROOT classes may have RTTI (run time type identification) support added.
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.
virtual void MethodInfo_CreateSignature(MethodInfo_t *minfo, TString &signature) const
static TProtoClass * GetProtoNorm(const char *cname)
Given the class normalized name returns the TClassProto object for the class.
TObject * FindObject(const char *name) const
Find object using its name.
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
int GetMethodNArg(const char *method, const char *proto, Bool_t objectIsConst, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
R__EXTERN TVirtualMutex * gInterpreterMutex
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...
TList * GetListOfEnums(Bool_t load=kTRUE)
Return a list containing the TEnums of a class.
const char * Name() const
bool HasMethod(const char *name) const
void Init(const char *name)
Lookup named typedef and reset the iterator to point to it.
std::atomic< TListOfEnums * > fEnums
virtual CallFunc_t * CallFunc_FactoryCopy(CallFunc_t *func) const
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.
void SetFunc(const TClingClassInfo *info, const char *method, const char *arglist, long *poffset)
void Destruct(void *arena, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
virtual const char * MethodInfo_Title(MethodInfo_t *minfo) const
void SetArgArray(long *argArr, int narg)
cling::MetaProcessor * fMetaProcessor
virtual int DataMemberInfo_TypeSize(DataMemberInfo_t *dminfo) const
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
const char * GetFullTypeName() const
Get full type description of typedef, e,g.: "class TDirectory*".
Persistent version of a TClass.
virtual void SetRTLD_LAZY() const
Emulation of the CINT DataMemberInfo class.
Small helper to keep current directory context.
TEnum * Get(DeclId_t id, const char *name)
Return (after creating it if necessary) the TEnum describing the enum corresponding to the Decl 'id'...
std::atomic< Bool_t > fHasRootPcmInfo
C++ Property of the class (is abstract, has virtual table, etc.)
TClass * GenerateTClass(const char *classname, Bool_t emulation, Bool_t silent=kFALSE)
Generate a TClass for the given class.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
void UpdateListOfGlobals()
No op: see TClingCallbacks (used to update the list of globals)
void UpdateListOfGlobalFunctions()
No op: see TClingCallbacks (used to update the list of global functions)
Emulation of the CINT MethodInfo class.
ptrdiff_t GetBaseOffset(TClingClassInfo *toBase, void *address, bool isDerivedObject)
virtual std::string MethodArgInfo_TypeNormalizedName(MethodArgInfo_t *marginfo) const
const char * Name() const
void SaveContext()
Save the current Cling state.
virtual MethodInfo_t * CallFunc_FactoryMethod(CallFunc_t *func) const
cling::Interpreter * fInterpreter
virtual ClassInfo_t * ClassInfo_Factory(Bool_t all=kTRUE) const
virtual const char * HomeDirectory(const char *userName=0)
Return the user's home directory.
static void RemoveClassDeclId(TDictionary::DeclId_t id)
Long_t Property() const
Set TObject::fBits and fStreamerType to cache information about the class.
virtual BaseClassInfo_t * BaseClassInfo_Factory(ClassInfo_t *info) const
const char * GetClassSharedLibs(const char *cls)
Get the list of shared libraries containing the code for class cls.
const char * GetValue() const
void TCling__DEBUG__dump(clang::DeclContext *DC)
const TClingTypeInfo * Type() const
virtual TObject * FindObject(const char *name) const
Specialize FindObject to do search for the a function just by name or create it if its not already in...
virtual void MethodInfo_Delete(MethodInfo_t *minfo) const
Interface to cling function.
virtual void CallFunc_SetArgArray(CallFunc_t *func, Long_t *paramArr, Int_t nparam) const
virtual const char * TypedefInfo_TrueName(TypedefInfo_t *tinfo) const
Bool_t IsPersistent() const
void TCling__UpdateListsOnUnloaded(const cling::Transaction &T)
virtual TObject * Remove(TObject *obj)
Remove object from array.
TList * GetListOfDataMembers(Bool_t load=kTRUE)
Return list containing the TDataMembers of a class.
bool LoadPCM(TString pcmFileName, const char **headers, void(*triggerFunc)()) const
Tries to load a PCM; returns true on success.
virtual Bool_t IsTreatingNonAccessibleTypes()
virtual FuncTempInfo_t * FuncTempInfo_FactoryCopy(FuncTempInfo_t *) const
Construct a FuncTempInfo_t.
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Int_t Load(const char *filenam, Bool_t system=kFALSE)
Load a library file in cling's memory.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
The TEnv class reads config files, by default named .rootrc.
std::string InsertStd(const char *tname)
clang::DeclContext * TCling__DEBUG__getDeclContext(clang::Decl *D)
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 (...
ROOT::TMetaUtils::TNormalizedCtxt * fNormalizedCtxt
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...
static int HandleInterpreterException(cling::MetaProcessor *metaProcessor, const char *input_line, cling::Interpreter::CompilationResult &compRes, cling::Value *result)
Let cling process a command line.
static Bool_t HasNoInfoOrEmuOrFwdDeclaredDecl(const char *)
bool HasDefaultConstructor() const
virtual TApplicationImp * GetApplicationImp()
TClingMethodInfo GetMethod(const char *fname) const
TClingTypeInfo * Type() const
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
virtual const char * MethodInfo_GetMangledName(MethodInfo_t *minfo) const
virtual UInt_t FuncTempInfo_TemplateNargs(FuncTempInfo_t *) const
Return the maximum number of template arguments of the function template described by ft_info...
virtual int DisplayIncludePath(FILE *fout) const
Interface to cling function.
void * fPrevLoadedDynLibInfo
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
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)
Inject the module named "modulename" into cling; load all headers.
Each ROOT method (see TMethod) has a linked list of its arguments.
virtual const char * BaseClassInfo_Name(BaseClassInfo_t *bcinfo) const
virtual void TypeInfo_Delete(TypeInfo_t *tinfo) const
virtual Long_t CallFunc_ExecInt(CallFunc_t *func, void *address) const
Int_t DeleteVariable(const char *name)
Undeclare obj called name.
virtual int SetClassAutoparsing(int)
Enable/Disable the Autoparsing of headers.
Int_t GetEntriesFast() const
llvm::StringRef ValidArrayIndex() const
virtual int LoadFile(const char *path) const
Load a source file or library called path into the interpreter.
const char * TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Get the name of the underlying type of the current typedef.
void SetAutoParsingSuspended(bool val=true)
R__EXTERN TApplication * gApplication
Abstract base class for accessing the data-members of a class.
virtual void TypeInfo_Init(TypeInfo_t *tinfo, const char *funcname) const
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.e.
std::vector< cling::Value > * fTemporaries
virtual ~TCling()
Destroy the interpreter interface.
virtual const char * DataMemberInfo_Title(DataMemberInfo_t *dminfo) const
virtual void LoadFunctionTemplates(TClass *cl) const
Create list of pointers to function templates for TClass cl.
virtual Long_t CINT not applicable to cling return
virtual bool MethodArgInfo_IsValid(MethodArgInfo_t *marginfo) const
virtual bool Update(FuncTempInfo_t *info)
Update the TFunctionTemplate to reflect the new info.
virtual Long_t DataMemberInfo_Property(DataMemberInfo_t *dminfo) const
virtual Long_t TypedefInfo_Property(TypedefInfo_t *tinfo) const
virtual void * ClassInfo_New(ClassInfo_t *info) const
const clang::Type * GetType() const
Emulation of the CINT CallFunc class.
virtual int DisplayClass(FILE *fout, const char *name, int base, int start) const
virtual const char * GetTopLevelMacroName() const
Return the file name of the current un-included interpreted file.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
int(* AutoLoadCallBack_t)(const char *)
static const TString & GetIncludeDir()
Get the include directory in the installation. Static utility function.
virtual int GetProcInfo(ProcInfo_t *info) const
Returns cpu and memory used by this process into the ProcInfo_t structure.
RAII used to store Parser, Sema, Preprocessor state for recursive parsing.
Bool_t R_ISREG(Int_t mode)
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void SetDeclAttr(DeclId_t, const char *)
virtual bool ClassInfo_IsValidMethod(ClassInfo_t *info, const char *method, const char *proto, Long_t *offset, ROOT::EFunctionMatchMode=ROOT::kConversionMatch) const
virtual int DataMemberInfo_MaxIndex(DataMemberInfo_t *dminfo, Int_t dim) const
V GetOffset(E val1, E val2, V iso)
void Execute(const char *function, const char *params, int *error=0)
Execute a global function with arguments params.
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
const char * GetSharedLibDeps(const char *lib)
Get the list a libraries on which the specified lib depends.
virtual bool DiagnoseIfInterpreterException(const std::exception &e) const
static const char * GetMacroPath()
Get macro search path. Static utility function.
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.
std::set< size_t > fPayloads
TDictionary * Find(DeclId_t id) const
Return (after creating it if necessary) the TDataMember describing the data member corresponding to t...
const TSeqCollection * GetConstants() const
virtual Long_t GetExecByteCode() const
This routines used to return the address of the internal wrapper function (of the interpreter) that w...
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).
virtual void MethodArgInfo_Delete(MethodArgInfo_t *marginfo) const
std::vector< const char * > fCurExecutingMacros
Bool_t IsValid()
Return true if this data member object is pointing to a currently loaded data member.
virtual int TypeInfo_RefType(TypeInfo_t *) const
void AddFriendToClass(clang::FunctionDecl *, clang::CXXRecordDecl *) const
Inject function as a friend into klass.
virtual Long_t BaseClassInfo_Offset(BaseClassInfo_t *toBaseClassInfo, void *address, bool isDerivedObject) const
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
void TCling__DEBUG__decl_dump(void *D)
Int_t UnloadLibraryMap(const char *library)
Unload library map entries coming from the specified library.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual TEnum * CreateEnum(void *VD, TClass *cl) const
virtual void GenericError(const char *error) const
Let the interpreter issue a generic error, and set its error state.
void ClearStack()
Delete existing temporary values.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
virtual void ClassInfo_Init(ClassInfo_t *info, const char *funcname) const
void ResetAll()
Reset the Cling state to its initial state.
void Exec(void *address, TInterpreterValue *interpVal=0)
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...
int Next()
Increment the iterator.
void CreateSignature(TString &signature) const
virtual void CallFunc_Init(CallFunc_t *func) const
TInterpreter::CallFuncIFacePtr_t IFacePtr()
Int_t GenerateDictionary(const char *classes, const char *includes=0, const char *options=0)
Generate the dictionary for the C++ classes listed in the first argument (in a semi-colon separated l...
THashTable implements a hash table to store TObject's.
const char * TCling__GetClassSharedLibs(const char *className)
clang::NamespaceDecl * TCling__DEBUG__DCtoNamespace(clang::DeclContext *DC)
void ExecuteWithArgsAndReturn(TMethod *method, void *address, const void *args[]=0, int nargs=0, void *ret=0) const
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...
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
virtual TypedefInfo_t * TypedefInfo_Factory() const
virtual Long_t BaseClassInfo_Property(BaseClassInfo_t *bcinfo) const
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Bool_t CheckClassInfo(const char *name, Bool_t autoload, Bool_t isClassOrNamespaceOnly=kFALSE)
Checks if an entity with the specified name is defined in Cling.
std::atomic< TList * > fBase
virtual void CallFunc_Exec(CallFunc_t *func, void *address) const
Bool_t Declare(const char *code)
Declare code to the interpreter, without any of the interpreter actions that could trigger a re-inter...
std::map< const cling::Transaction *, size_t > fTransactionHeadersMap
virtual UInt_t FuncTempInfo_TemplateMinReqArgs(FuncTempInfo_t *) const
Return the number of required template arguments of the function template described by ft_info...
void ShortType(std::string &answer, int mode)
Return the absolute type of typeDesc into the string answ.
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...
The TNamed class is the base class for all named ROOT classes.
void SetObjectValidity(EObjectPointerState val)
void CreateListOfDataMembers(TClass *cl) const
Create list of pointers to data members for TClass cl.
void SetArgs(const char *args)
char * DemangleName(const char *mangled_name, int &errorCode)
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 void ClassInfo_DeleteArray(ClassInfo_t *info, void *arena, bool dtorOnly) const
long ClassProperty() 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 Init(TClassEdit::TInterpreterLookupHelper *helper)
virtual MethodInfo_t * MethodInfo_FactoryCopy(MethodInfo_t *minfo) const
void ClearFileBusy()
Reset the interpreter internal state in case a previous action was not correctly terminated.
static void UpdateClassInfo(char *name, Long_t tagnum)
No op: see TClingCallbacks.
TClass * GetClass() const
void CreateListOfBaseClasses(TClass *cl) const
Create list of pointers to base class(es) for TClass cl.
virtual const char * GetDynamicPath()
Return the dynamic path (used to find shared libraries).
virtual Long_t DataMemberInfo_Offset(DataMemberInfo_t *dminfo) const
virtual Bool_t Declare(const char *code)=0
virtual const char CINT not applicable to cling
bool Append(const std::string &str)
Append string to the storage if not added already.
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 * ClassInfo_FileName(ClassInfo_t *info) const
virtual const char * TypeInfo_Name(TypeInfo_t *) const
virtual const char * Getenv(const char *env)
Get environment variable.
virtual const char * MapCppName(const char *) const
Interface to cling function.
void Info(const char *location, const char *msgfmt,...)
static bool IsEnum(cling::Interpreter *interp, const char *name)
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
virtual const char * GetCurrentMacroName() const
Return the file name of the currently interpreted file, included or not.
virtual int SetClassAutoloading(int) const
Enable/Disable the Autoloading of libraries.
ULong64_t fTransactionCount
const char * GetDefault() const
Get default value of method argument.
virtual bool ClassInfo_IsBase(ClassInfo_t *info, const char *name) const
char * DemangleTypeIdName(const std::type_info &ti, int &errorCode)
Demangle in a portable way the type id name.
virtual Long_t ClassInfo_GetBaseOffset(ClassInfo_t *fromDerived, ClassInfo_t *toBase, void *address, bool isDerivedObject) 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...
virtual int MethodInfo_NArg(MethodInfo_t *minfo) const
long Property() const
Return a bit mask of metadata about the current typedef.
virtual void Setgvp(Long_t) const
Interface to the cling global object pointer which was controlling the behavior of the wrapper around...
const char * TypeName() const
Long_t ProcessLine(const char *line, EErrorCode *error=0)
virtual Long_t ClassInfo_Property(ClassInfo_t *info) const
virtual bool Update(DataMemberInfo_t *info)
Update the TFunction to reflect the new info.
Emulation of the CINT TypeInfo class.
virtual int TypedefInfo_Next(TypedefInfo_t *tinfo) const
virtual bool TypeInfo_IsValid(TypeInfo_t *tinfo) const
cling::Interpreter * GetInterpreter()
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
clang::RecordDecl * TCling__DEBUG__DCtoRecordDecl(clang::DeclContext *DC)
This class defines an interface to the cling C++ interpreter.
Bool_t IgnoreDuplicates(Bool_t ignore)
If set to true, no warnings in case of duplicates are issued.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
DeclId_t GetDeclId(const llvm::GlobalValue *gv) const
Return pointer to cling DeclId for a global value.
const char * TypeTrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Int_t UnloadAllSharedLibraryMaps()
Unload the library map entries coming from all the loaded shared libraries.
void InitRootmapFile(const char *name)
Create a resource table and read the (possibly) three resource files, i.e $ROOTSYS/etc/system<name> (...
std::string GetLong64_Name(const char *original)
Replace 'long long' and 'unsigned long long' by 'Long64_t' and 'ULong64_t'.
void InspectMembers(TMemberInspector &, const void *obj, const TClass *cl, Bool_t isTransient)
Visit all members over members, recursing over base classes.
void Error(const char *location, const char *msgfmt,...)
virtual bool ClassInfo_IsEnum(const char *name) const
static void TCling__UpdateClassInfo(const NamedDecl *TD)
Update TClingClassInfo for a class (e.g. upon seeing a definition).
void TCling__DEBUG__printName(clang::Decl *D)
EComplexType GetComplexType(const char *)
long ExtraProperty() const
virtual Long_t DataMemberInfo_TypeProperty(DataMemberInfo_t *dminfo) const
TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
virtual Bool_t IsCmdThread()
void PrintIntro()
No-op; see TRint instead.
R__EXTERN TVirtualMutex * gGlobalMutex
virtual Int_t ReadFile(const char *fname, EEnvLevel level)
Read and parse the resource file for a certain level.
const Decl * TCling__GetObjectDecl(TObject *obj)
R__EXTERN TROOT * gROOTLocal
void UpdateListOfTypes()
No op: see TClingCallbacks (used to update the list of types)
virtual const char * TypeInfo_TrueName(TypeInfo_t *tinfo) const
virtual std::string MethodInfo_TypeNormalizedName(MethodInfo_t *minfo) const
const char * Name() const
RooArgSet S(const RooAbsArg &v1)
const char * TmpltName() 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 TList * GetListOfMethodArgs()
Returns methodarg list and additionally updates fDataMember in TMethod by calling FindDataMember();...
virtual void CallFunc_SetArgs(CallFunc_t *func, const char *param) const
const char * TmpltName() const
void Init(const char *name)
bool TCling__TEST_isInvalidDecl(clang::Decl *D)
TClingClassInfo * GetBase() const
std::vector< void * > fRegisterModuleDyLibs
TFunctionTemplate * Get(DeclId_t id)
Return (after creating it if necessary) the TMethod or TFunction describing the function correspondin...
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 bool MethodInfo_IsValid(MethodInfo_t *minfo) const
int MaxIndex(int dim) const
void TCling__SplitAclicMode(const char *fileName, string &mode, string &args, string &io, string &fname)
std::vector< std::string > fElements
const char * GetName() const
Returns name of object.
virtual Long_t TypeInfo_Property(TypeInfo_t *tinfo) const
Emulation of the CINT BaseClassInfo class.
TClingMethodInfo * FactoryMethod() const
R__EXTERN TSystem * gSystem
if object ctor succeeded but object should not be used
void * InterfaceMethod(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
virtual const char * DataMemberInfo_TypeTrueName(DataMemberInfo_t *dminfo) const
ptrdiff_t Offset(void *address=0, bool isDerivedObject=true) const
virtual void GetFunctionName(const clang::FunctionDecl *decl, std::string &name) const
Basic data type descriptor (datatype information is obtained from CINT).
void SetFuncProto(const TClingClassInfo *info, const char *method, const char *proto, long *poffset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
virtual void LoadEnums(TListOfEnums &cl) const
Create list of pointers to enums for TClass cl.
std::set< TClass * > & GetModTClasses()
virtual int TypeInfo_Size(TypeInfo_t *tinfo) const
static void UpdateAllCanvases()
Update all canvases at end the terminal input command.
const clang::FunctionDecl * GetMethodDecl() const
const char * TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Return the normalized name of the type (i.e.
ClassInfo_t * GetClassInfo() const
virtual CallFunc_t * CallFunc_Factory() const
const char * DefaultValue() const
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 TEnvRec * Lookup(const char *n)
Loop over all resource records and return the one with name.
TObject * Remove(TObject *obj)
Remove object from the list.
virtual Int_t AutoParse(const char *cls)=0
Collection abstract base class.
Bool_t SetErrorMessages(Bool_t enable=kTRUE)
If error messages are disabled, the interpreter should suppress its failures and warning messages fro...
int TCling__AutoParseCallback(const char *className)
virtual const char * DataMemberInfo_ValidArrayIndex(DataMemberInfo_t *dminfo) const
void SaveGlobalsContext()
Save the current Cling state of global objects.
void UpdateClassInfoWithDecl(const void *vTD)
Internal function. Inform a TClass about its new TagDecl or NamespaceDecl.
virtual Long_t BaseClassInfo_Tagnum(BaseClassInfo_t *bcinfo) const
Bool_t TestBit(UInt_t f) const
virtual Bool_t IsValid()
Return true if this global object is pointing to a currently loaded global.
virtual const char * ClassInfo_Title(ClassInfo_t *info) const
void UpdateListOfLoadedSharedLibraries()
char * Form(const char *fmt,...)
virtual void CallFunc_SetFunc(CallFunc_t *func, ClassInfo_t *info, const char *method, const char *params, Long_t *Offset) const
virtual TypeInfo_t * MethodInfo_Type(MethodInfo_t *minfo) const
Long_t Calc(const char *line, EErrorCode *error=0)
Directly execute an executable statement (e.g.
Int_t RescanLibraryMap()
Scan again along the dynamic path for library maps.
virtual const char * GetName() const
Returns name of object.
The TEnumConstant class implements the constants of the enum type.
virtual const char * Getp2f2funcname(void *receiver) const
virtual bool TypedefInfo_IsValid(TypedefInfo_t *tinfo) const
virtual Bool_t LoadText(const char *text) const
Load the declarations from text into the interpreter.
The ROOT global object gROOT contains a list of all defined classes.
virtual int MethodInfo_Next(MethodInfo_t *minfo) const
clang::QualType GetQualType() const
virtual int MethodInfo_NDefaultArg(MethodInfo_t *minfo) const
virtual int MethodArgInfo_Next(MethodArgInfo_t *marginfo) const
void TCling__PrintStackTrace()
Print a StackTrace!
Global variables class (global variables are obtained from CINT).
void * LazyFunctionCreatorAutoload(const std::string &mangled_name)
Autoload a library based on a missing symbol.
Version_t GetClassVersion() const
Long_t ExecuteMacro(const char *filename, EErrorCode *error=0)
Execute a cling macro.
virtual void Initialize()
Initialize the interpreter, once TROOT::fInterpreter is set.
Bool_t CheckClassTemplate(const char *name)
Return true if there is a class template by the given name ...
static void indent(ostringstream &buf, int indent_level)
THashList * GetTable() 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.
void Warning(const char *location, const char *msgfmt,...)
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
virtual void FreeDirectory(void *dirp)
Free a directory.
virtual const char * MethodInfo_GetPrototype(MethodInfo_t *minfo) const
TDictionary::DeclId_t GetDeclId() const
virtual void CallFunc_ExecWithArgsAndReturn(CallFunc_t *func, void *address, const void *args[]=0, int nargs=0, void *ret=0) const
TObject * TCling__GetObjectAddress(const char *Name, void *&LookupCtx)
virtual Bool_t FuncTempInfo_IsValid(FuncTempInfo_t *) const
Check validity of a FuncTempInfo_t.
Each class (see TClass) has a linked list of its base class(es).
const char * Name() const
Get the name of the current typedef.
void EnableAutoLoading()
Enable the automatic loading of shared libraries when a class is used that is stored in a not yet loa...
Type
enumeration specifying the integration types.
R__DLLEXPORT void DestroyInterpreter(TInterpreter *interp)
bool IsAutoloadingEnabled()
const char * TypeName() const
TDictionary::DeclId_t DeclId_t
#define R__LOCKGUARD2(mutex)
virtual void CallFunc_Delete(CallFunc_t *func) const
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::unordered_set< const clang::NamespaceDecl * > fNSFromRootmaps
virtual const char * BaseClassInfo_FullName(BaseClassInfo_t *bcinfo) const
virtual MethodInfo_t * MethodInfo_Factory() const
void TCling__GetNormalizedContext(const ROOT::TMetaUtils::TNormalizedCtxt *&normCtxt)
int Size() const
Return the size in bytes of the underlying type of the current typedef.
virtual const char * FindDynamicLibrary(TString &lib, Bool_t quiet=kFALSE)
Find a dynamic library using the system search paths.
void EndOfLineAction()
It calls a "fantom" method to synchronize user keyboard input and ROOT prompt line.
std::string GetMangledName() const
const char * Name(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
void SetClassInfo(TClass *cl, Bool_t reload=kFALSE)
Set pointer to the TClingClassInfo in TClass.
Emulation of the CINT TypedefInfo class.
const clang::Decl * GetDecl() const
const char * TypeName() const
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
virtual const char * MethodArgInfo_DefaultValue(MethodArgInfo_t *marginfo) const
virtual const char * ClassInfo_Name(ClassInfo_t *info) const
virtual const char * GetIncludePath()
Get the list of include path.
virtual bool DataMemberInfo_IsValid(DataMemberInfo_t *dminfo) const
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)
TInterpreterValue * CreateTemporary()
The created temporary must be deleted by the caller.
void GetFunctionOverloads(ClassInfo_t *cl, const char *funcname, std::vector< DeclId_t > &res) const
Insert overloads of name in cl to res.
void UpdateListsOnUnloaded(const cling::Transaction &T)
virtual FuncTempInfo_t * FuncTempInfo_Factory(DeclId_t declid) const
Construct a FuncTempInfo_t.
TObjArray * fStreamerInfo
virtual void FuncTempInfo_Title(FuncTempInfo_t *, TString &name) const
Return the comments associates with this function template.
std::set< size_t > fLookedUpClasses
void UpdateListOfDataMembers(TClass *cl) const
Update the list of pointers to data members for TClass cl This is now a nop.
const char * GetParent() const
void UnloadClassMembers(TClass *cl, const clang::DeclContext *DC)
Helper function to go through the members of a class or namespace and unload them.
virtual const void * GetValAddr() const =0
EState fState
cached of the streaming method to use
void TCling__LibraryLoadedRTTI(const void *dyLibHandle, const char *canonicalName)
Emulation of the CINT MethodInfo class.
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
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'...
TFunction * Find(DeclId_t id) const
Return the TMethod or TFunction describing the function corresponding to the Decl 'id'...
virtual const char * DataMemberInfo_Name(DataMemberInfo_t *dminfo) const
void Unload()
Mark 'all func' as being unloaded.
virtual int DataMemberInfo_ArrayDim(DataMemberInfo_t *dminfo) const
void RegisterTClassUpdate(TClass *oldcl, DictFuncPtr_t dict)
Register classes that already existed prior to their dictionary loading and that already had a ClassI...
Bool_t IsAutoLoadNamespaceCandidate(const char *name)
virtual void CallFunc_ResetArg(CallFunc_t *func) const
virtual void FuncTempInfo_Delete(FuncTempInfo_t *) const
Delete the FuncTempInfo_t.
TDictionary::DeclId_t DeclId_t
void DeleteArray(void *arena, bool dtorOnly, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
void ResetGlobalVar(void *obj)
Reset the Cling 'user' global objects/variables state to the state saved by the last call to TCling::...
unsigned long long ULong64_t
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...
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
virtual Long64_t CallFunc_ExecInt64(CallFunc_t *func, void *address) const
void Reset()
Pressing Ctrl+C should forward here.
Int_t LoadLibraryMap(const char *rootmapfile=0)
Load map between class and library.
void CreateListOfMethodArgs(TFunction *m) const
Create list of pointers to method arguments for TMethod m.
TObjArray * fRootmapFiles
double func(double *x, double *p)
virtual void Expand(Int_t newSize)
Expand or shrink the array to newSize elements.
std::set< const char * > fParsedPayloadsAddresses
ROOT::TMetaUtils::TClingLookupHelper * fLookupHelper
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
TClingCallbacks * fClingCallbacks
Int_t AutoLoad(const char *classname, Bool_t knowDictNotLoaded=kFALSE)
Load library containing the specified class.
Emulation of the CINT ClassInfo class.
EObjectPointerState GetObjectValidity() const
virtual ~TROOT()
Clean up and free resources used by ROOT (files, network sockets, shared memory segments, etc.).
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
virtual int GetSecurityError() const
Interface to cling function.
#define R__LOCKGUARD(mutex)
void InspectMember(const T &obj, const char *name, Bool_t isTransient)
Int_t GetEntries() const
Return the number of objects in array (i.e.
virtual void Add(TObject *obj)=0
virtual void * MethodInfo_InterfaceMethod(MethodInfo_t *minfo) const
void SetGetline(const char *(*getlineFunc)(const char *prompt), void(*histaddFunc)(const char *line))
Set a getline function to call when input is needed.
friend class SuspendAutoParsing
const clang::ValueDecl * GetDataMember(const char *name) const
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.
virtual void ClassInfo_Delete(ClassInfo_t *info) const
void Delete(void *arena, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
virtual bool Update(DataMemberInfo_t *info)
Update the TFunction to reflect the new info.
Int_t ReloadAllSharedLibraryMaps()
Reload the library map entries coming from all the loaded shared libraries, after first unloading the...
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...
static TClass * LoadClass(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
void UpdateListOfMethods(TClass *cl) const
Update the list of pointers to method for TClass cl This is now a nop.
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
void * New(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
virtual const char * TypedefInfo_Name(TypedefInfo_t *tinfo) const
void RecursiveRemove(TObject *obj)
Delete object from cling symbol table so it can not be used anymore.
TDataMember * GetDataMember(const char *datamember) const
Return pointer to datamember object with name "datamember".
virtual int ClassInfo_Size(ClassInfo_t *info) const
void UnRegisterTClassUpdate(const TClass *oldcl)
If the dictionary is loaded, we can remove the class from the list (otherwise the class might be load...
virtual Double_t CallFunc_ExecDouble(CallFunc_t *func, void *address) const
Mother of all ROOT objects.
virtual bool ClassInfo_HasMethod(ClassInfo_t *info, const char *name) const
void TCling__LibraryUnloadedRTTI(const void *dyLibHandle, const char *canonicalName)
virtual Long_t MethodArgInfo_Property(MethodArgInfo_t *marginfo) const
void RegisterTemporary(const TInterpreterValue &value)
Global functions class (global functions are obtained from CINT).
virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr)
virtual Long_t Getgvp() const
Interface to the CINT global object pointer which was controlling the behavior of the wrapper around ...
TClassRef is used to implement a permanent reference to a TClass object.
void HandleNewDecl(const void *DV, bool isDeserialized, std::set< TClass * > &modifiedClasses)
typedef void((*Func_t)())
void Unload()
Mark 'all func' as being unloaded.
const char * GetDeclFileName() const
virtual bool ClassInfo_IsLoaded(ClassInfo_t *info) const
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
virtual DeclId_t GetDataMemberWithValue(const void *ptrvalue) const
NOT IMPLEMENTED.
void SetAutoloadingEnabled(bool val=true)
Bridge between cling::Value and ROOT.
virtual const char * MethodInfo_Name(MethodInfo_t *minfo) const
const char * GetUnqualifiedName(const char *name)
Return the start of the unqualified name include in 'original'.
const char * GetFullTypeName() const
Get full type description of method argument, e.g.: "class TDirectory*".
void Unload()
Mark 'all func' as being unloaded.
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
TDictionary::DeclId_t DeclId_t
virtual void Add(TObject *obj)
TClingMethodInfo GetMethodWithArgs(const char *fname, const char *arglist, long *poffset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch, EInheritanceMode imode=kWithInheritance) const
virtual bool ClassInfo_IsValid(ClassInfo_t *info) const
virtual Long_t ClassInfo_Tagnum(ClassInfo_t *info) const
Bool_t fHeaderParsingOnDemand
virtual Long_t MethodInfo_ExtraProperty(MethodInfo_t *minfo) const
Each ROOT class (see TClass) has a linked list of methods.
std::vector< std::pair< TClass *, DictFuncPtr_t > > fClassesToUpdate
std::string AtlernateTuple(const char *classname)
virtual void CallFunc_IgnoreExtraArgs(CallFunc_t *func, bool ignore) const
virtual const char * GetSTLIncludePath() const
Return the directory containing CINT's stl cintdlls.
static void * fgSetOfSpecials
virtual const char * MethodInfo_TypeName(MethodInfo_t *minfo) const
static void SetFactory(TVirtualStreamerInfo *factory)
static function: Set the StreamerInfo factory
long ExecInt(void *address)
Int_t SetClassSharedLibs(const char *cls, const char *libs)
Register the autoloading information for a class.
Bool_t IsLoaded(const char *filename) const
Return true if the file has already been loaded by cint.
bool IsValid() const
Return true if the current iterator position is valid.
virtual void ClassInfo_Destruct(ClassInfo_t *info, void *arena) const
virtual const char * ClassInfo_FullName(ClassInfo_t *info) const
virtual void UpdateEnumConstants(TEnum *enumObj, TClass *cl) const
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
Bool_t SetSuspendAutoParsing(Bool_t value)
Suspend the Autoparsing of headers.
virtual const char * BaseClassInfo_TmpltName(BaseClassInfo_t *bcinfo) const
virtual const char * MethodArgInfo_Name(MethodArgInfo_t *marginfo) const
virtual const char * ClassInfo_TmpltName(ClassInfo_t *info) const
virtual int Evaluate(const char *, TInterpreterValue &)
Get the interpreter value corresponding to the statement.
static bool R__InitStreamerInfoFactory()
Helper to initialize TVirtualStreamerInfo's factor early.
Bool_t IsErrorMessagesEnabled() const
If error messages are disabled, the interpreter should suppress its failures and warning messages fro...
void IgnoreExtraArgs(bool ignore)
Bool_t fIsAutoParsingSuspended
static void UpdateClassInfoWork(const char *name)
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.
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
bool TClingLookupHelper__AutoParse(const char *cname)
Allow calling autoparsing from TMetaUtils.
std::hash< std::string > fStringHashFunction
virtual void TypedefInfo_Init(TypedefInfo_t *tinfo, const char *name) const
const char * GetSharedLibs()
Return the list of shared libraries loaded into the process.
TObject * At(Int_t idx) const
bool IsBase(const char *name) const
static const char * FindLibraryName(void(*func)())
Wrapper around dladdr (and friends)
virtual EReturnType MethodInfo_MethodCallReturnType(MethodInfo_t *minfo) const
R__EXTERN TInterpreter * gCling
R__DLLEXPORT TInterpreter * CreateInterpreter(void *interpLibHandle)
virtual void * FindSym(const char *entry) const
Interface to cling function.
void CodeComplete(const std::string &, size_t &, std::vector< std::string > &)
The call to Cling's tab complition.
virtual void Compress()
Remove empty slots from array.
bool IsValidMethod(const char *method, const char *proto, Bool_t objectIsConst, long *offset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
Long_t ProcessLineAsynch(const char *line, EErrorCode *error=0)
Let cling process a command line asynch.
virtual void DataMemberInfo_Delete(DataMemberInfo_t *dminfo) const
void TCling__TransactionRollback(const cling::Transaction &T)
virtual const char * GetTitle() const
Returns title of object.
TList * GetListOfMethods(Bool_t load=kTRUE)
Return list containing the TMethods of a class.
std::string NormalizedName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Return the normalized name of the type (i.e.
void Unload()
Mark 'all func' as being unloaded.
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
void LoadMacro(const char *filename, EErrorCode *error=0)
Load a macro file in cling's memory.
virtual ClassInfo_t * BaseClassInfo_ClassInfo(BaseClassInfo_t *) const
static DictFuncPtr_t GetDictNorm(const char *cname)
Given the normalized class name returns the Dictionary() function of a class (uses hash of name)...
static ETupleOrdering IsTupleAscending()
const char * TypeName(const char *typeDesc)
Return the absolute type of typeDesc.
virtual EReturnType MethodCallReturnType(TFunction *func) const
static char * skip(char **buf, const char *delimiters)
void LibraryUnloaded(const void *dyLibHandle, const char *canonicalName)
void RewindDictionary()
Rewind Cling dictionary to the point where it was before executing the current macro.
virtual MethodArgInfo_t * MethodArgInfo_FactoryCopy(MethodArgInfo_t *marginfo) const
void AddIncludePath(const char *path)
Add the given path to the list of directories in which the interpreter looks for include files...
void CreateListOfMethods(TClass *cl) const
Create list of pointers to methods for TClass cl.
Int_t DeleteGlobal(void *obj)
Delete obj from Cling symbol table so it cannot be accessed anymore.
virtual TypeInfo_t * TypeInfo_Factory() const
virtual const char * MethodArgInfo_TypeName(MethodArgInfo_t *marginfo) const
TDictionary::DeclId_t GetDeclId() const
virtual void SetErrmsgcallback(void *p) const
Set a callback to receive error messages.
void ResetGlobals()
Reset in Cling the list of global variables to the state saved by the last call to TCling::SaveGlobal...
virtual const char * TypedefInfo_Title(TypedefInfo_t *tinfo) const
Int_t Size() const
Return size of object of this class.
virtual void SetAlloclockfunc(void(*)()) const
[Place holder for Mutex Lock] Provide the interpreter with a way to acquire a lock used to protect cr...
void ExecWithArgsAndReturn(void *address, const void *args[]=0, int nargs=0, void *ret=0)
virtual void CallFunc_SetArg(CallFunc_t *func, Long_t param) const
if(line.BeginsWith("/*"))
virtual Long_t FuncTempInfo_Property(FuncTempInfo_t *) const
Return the property of the function template.
DeclId_t GetDeclId() const
virtual DataMemberInfo_t * DataMemberInfo_FactoryCopy(DataMemberInfo_t *dminfo) const
void ExecWithReturn(void *address, void *ret=0)
virtual int UnloadFile(const char *path) const
virtual int DataMemberInfo_Next(DataMemberInfo_t *dminfo) const
std::map< size_t, std::vector< const char * > > fClassesHeadersMap
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 ClassInfo_GetMethodNArg(ClassInfo_t *info, const char *method, const char *proto, Bool_t objectIsConst=false, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
TList * GetListOfFunctionTemplates(Bool_t load=kTRUE)
Return list containing the TEnums of a class.
virtual const char * GetClassSharedLibs(const char *cls)=0
long long ExecInt64(void *address)
virtual void FuncTempInfo_Name(FuncTempInfo_t *, TString &name) const
Return the name of this function template.
virtual void TypedefInfo_Delete(TypedefInfo_t *tinfo) const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.