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> 139 #include <mach-o/loader.h> 146 #if defined(__CYGWIN__) 147 #include <sys/cygwin.h> 148 #define HMODULE void * 150 __declspec(dllimport)
void * __stdcall GetCurrentProcess();
151 __declspec(dllimport)
bool __stdcall EnumProcessModules(
void *,
void **,
unsigned long,
unsigned long *);
152 __declspec(dllimport)
unsigned long __stdcall GetModuleFileNameExW(
void *,
void *,
wchar_t *,
unsigned long);
157 #if defined(_MSC_VER) 159 # define STDIN_FILENO 0 161 #ifndef STDOUT_FILENO 162 # define STDOUT_FILENO 1 164 #ifndef STDERR_FILENO 165 # define STDERR_FILENO 2 174 #undef GetModuleFileName 175 #define RTLD_DEFAULT ((void *)::GetModuleHandle(NULL)) 176 #define dlsym(library, function_name) ::GetProcAddress((HMODULE)library, function_name) 177 #define dlopen(library_name, flags) ::LoadLibrary(library_name) 178 #define dlclose(library) ::FreeLibrary((HMODULE)library) 179 #define R__DLLEXPORT __declspec(dllexport) 187 class TCling_UnloadMarker {
189 ~TCling_UnloadMarker() {
195 static TCling_UnloadMarker gTClingUnloadMarker;
204 return D->getDeclContext();
207 return llvm::dyn_cast<clang::NamespaceDecl>(DC);
210 return llvm::dyn_cast<clang::RecordDecl>(DC);
213 return DC->dumpDeclContext();
222 return ((clang::Decl*)D)->dump();
225 if (clang::NamedDecl* ND = llvm::dyn_cast<clang::NamedDecl>(D)) {
228 llvm::raw_string_ostream OS(name);
229 ND->getNameForDiagnostic(OS, D->getASTContext().getPrintingPolicy(),
232 printf(
"%s\n", name.c_str());
240 return D->isInvalidDecl();
244 assert(info && info->
IsValid());
245 return info->
GetDecl()->isInvalidDecl();
249 using namespace clang;
250 using namespace ROOT;
253 static const std::string gInterpreterClassDef = R
"ICF( 255 #define ClassDef(name, id) \ 256 _ClassDefInterp_(name,id,virtual,) \ 257 static int DeclFileLine() { return __LINE__; } 259 #define ClassDefNV(name, id) \ 260 _ClassDefInterp_(name,id,,) \ 261 static int DeclFileLine() { return __LINE__; } 262 #undef ClassDefOverride 263 #define ClassDefOverride(name, id) \ 264 _ClassDefInterp_(name,id,,override) \ 265 static int DeclFileLine() { return __LINE__; } 268 static const std::string gNonInterpreterClassDef = R
"ICF( 269 #define __ROOTCLING__ 1 271 #define ClassDef(name,id) \ 272 _ClassDef_(name,id,virtual,) \ 273 static int DeclFileLine() { return __LINE__; } 275 #define ClassDefNV(name, id)\ 276 _ClassDef_(name,id,,)\ 277 static int DeclFileLine() { return __LINE__; } 278 #undef ClassDefOverride 279 #define ClassDefOverride(name, id)\ 280 _ClassDef_(name,id,,override)\ 281 static int DeclFileLine() { return __LINE__; } 285 static const std::string gClassDefInterpMacro = R
"ICF( 290 #define _ClassDefInterp_(name,id,virtual_keyword, overrd) \ 293 static TClass *Class() { static TClass* sIsA = 0; if (!sIsA) sIsA = TClass::GetClass(#name); return sIsA; } \ 294 static const char *Class_Name() { return #name; } \ 295 static Version_t Class_Version() { return id; } \ 296 static TClass *Dictionary() { return 0; } \ 297 virtual_keyword TClass *IsA() const overrd { return name::Class(); } \ 298 virtual_keyword void ShowMembers(TMemberInspector&insp) const overrd { ::ROOT::Class_ShowMembers(name::Class(), this, insp); } \ 299 virtual_keyword void Streamer(TBuffer&) overrd { ::Error("Streamer", "Cannot stream interpreted class."); } \ 300 void StreamerNVirtual(TBuffer&ClassDef_StreamerNVirtual_b) { name::Streamer(ClassDef_StreamerNVirtual_b); } \ 301 static const char *DeclFileName() { return __FILE__; } \ 302 static int ImplFileLine() { return 0; } \ 303 static const char *ImplFileName() { return __FILE__; } 314 class EnumVisitor :
public RecursiveASTVisitor<EnumVisitor> {
316 llvm::SmallVector<EnumDecl*,128> &fClassEnums;
318 EnumVisitor(llvm::SmallVector<EnumDecl*,128> &enums) : fClassEnums(enums)
321 bool TraverseStmt(Stmt*) {
326 bool shouldVisitTemplateInstantiations()
const {
return true; }
328 bool TraverseClassTemplateDecl(ClassTemplateDecl*) {
333 bool TraverseClassTemplatePartialSpecializationDecl(ClassTemplatePartialSpecializationDecl*) {
338 bool VisitEnumDecl(EnumDecl *TEnumD) {
339 if (!TEnumD->getDeclContext()->isDependentContext())
340 fClassEnums.push_back(TEnumD);
359 static vector<const NamedDecl*> updateList;
362 if (entered) topLevel =
kFALSE;
377 updateList.push_back(TD);
380 while (!updateList.empty()) {
382 updateList.pop_back();
389 const clang::Decl* D =
static_cast<const clang::Decl*
>(enumObj->
GetDeclId());
390 if(
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(D)) {
392 for (EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(),
393 EDE = ED->enumerator_end(); EDI != EDE; ++EDI) {
395 std::string constbuf;
396 if (
const NamedDecl* END = llvm::dyn_cast<NamedDecl>(*EDI)) {
397 PrintingPolicy Policy((*EDI)->getASTContext().getPrintingPolicy());
398 llvm::raw_string_ostream stream(constbuf);
400 Policy.AnonymousTagLocations =
false;
401 (END)->getNameForDiagnostic(stream, Policy,
false);
403 const char* constantName = constbuf.c_str();
407 const llvm::APSInt valAPSInt = (*EDI)->getInitVal();
408 if (valAPSInt.isSigned()) {
409 value = valAPSInt.getSExtValue();
411 value = valAPSInt.getZExtValue();
418 DataMemberInfo_t* dmInfo = (DataMemberInfo_t*) tcDmInfo;
422 enumConstant =
new TEnumConstant(dmInfo, constantName, value, enumObj);
429 globals->
Add(enumConstant);
442 const clang::Decl* D =
static_cast<const clang::Decl*
>(VD);
444 if (
const EnumDecl* ED = llvm::dyn_cast<EnumDecl>(D)) {
446 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
447 llvm::raw_string_ostream stream(buf);
449 Policy.AnonymousTagLocations =
false;
450 ED->getNameForDiagnostic(stream, Policy,
false);
456 const char*
name = buf.c_str();
457 enumType =
new TEnum(name, VD, cl);
458 UpdateEnumConstants(enumType, cl);
467 const clang::Decl* D =
static_cast<const clang::Decl*
>(DV);
469 if (!D->isCanonicalDecl() && !isa<clang::NamespaceDecl>(D)
470 && !dyn_cast<clang::RecordDecl>(D))
return;
472 if (isa<clang::FunctionDecl>(D->getDeclContext())
473 || isa<clang::TagDecl>(D->getDeclContext()))
477 if (
const clang::CXXRecordDecl* RD = dyn_cast<clang::CXXRecordDecl>(D)) {
478 if (RD->getDescribedClassTemplate())
480 }
else if (
const clang::FunctionDecl* FD = dyn_cast<clang::FunctionDecl>(D)) {
481 if (FD->getDescribedFunctionTemplate())
485 if (
const RecordDecl *TD = dyn_cast<RecordDecl>(D)) {
486 if (TD->isCanonicalDecl() || TD->isThisDeclarationADefinition())
489 else if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
491 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
495 }
else if (
const NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(D)) {
503 if (
const NamespaceDecl* NCtx = dyn_cast<NamespaceDecl>(ND->getDeclContext())) {
504 if (NCtx->getIdentifier()) {
507 std::string NCtxName;
508 PrintingPolicy Policy(NCtx->getASTContext().getPrintingPolicy());
509 llvm::raw_string_ostream stream(NCtxName);
511 Policy.AnonymousTagLocations =
false;
512 NCtx->getNameForDiagnostic(stream, Policy,
true);
516 modifiedTClasses.insert(cl);
523 if (!isa<TranslationUnitDecl>(ND->getDeclContext()))
527 if (isa<EnumDecl>(ND))
532 if (!(isa<VarDecl>(ND)))
536 if (
gROOT->GetListOfGlobals()->FindObject(ND->getNameAsString().c_str()))
540 gROOT->GetListOfGlobals()->Add(
new TGlobal((DataMemberInfo_t *)
542 cast<ValueDecl>(ND), 0)));
569 const char* canonicalName) {
571 ((
TCling*)
gCling)->LibraryLoaded(dyLibHandle, canonicalName);
575 const char* canonicalName) {
577 ((
TCling*)
gCling)->LibraryUnloaded(dyLibHandle, canonicalName);
583 return ((
TCling*)
gCling)->GetObjectAddress(Name, LookupCtx);
592 cling::DynamicLibraryManager::ExposeHiddenSharedLibrarySymbols(interpLibHandle);
593 return new TCling(
"C++",
"cling C++ Interpreter");
615 return ((
TCling*)
gCling)->GetClassSharedLibs(className);
627 return ((
TCling*)
gCling)->IsAutoLoadNamespaceCandidate(nsDecl);
632 string file(fileName);
638 string &args,
string &io,
string &fname)
640 string file(fileName);
641 TString
f, amode, arguments, aclicio;
643 mode = amode.Data(); args = arguments.Data();
644 io = aclicio.Data(); fname = f.Data();
654 char *__unDName(
char *demangled,
const char *mangled,
int out_len,
655 void * (* pAlloc )(
size_t),
void (* pFree )(
void *),
656 unsigned short int flags);
668 using namespace clang;
669 if (NamespaceDecl* nsd = llvm::dyn_cast<NamespaceDecl>(decl)){
673 if (ClassTemplateDecl* ctd = llvm::dyn_cast<ClassTemplateDecl>(decl)){
685 return ((
TCling*)
gCling)->LazyFunctionCreatorAutoload(mangled_name);
694 const std::vector<std::string> &headers,
695 const std::vector<std::string> &fwdDecls,
696 const std::vector<std::string> &unknown)
702 if (classes.empty()) {
706 const std::string& className = classes[0];
708 TString fileName =
"AutoDict_";
709 std::string::const_iterator sIt;
710 for (sIt = className.begin(); sIt != className.end(); sIt++) {
711 if (*sIt ==
'<' || *sIt ==
'>' ||
712 *sIt ==
' ' || *sIt ==
'*' ||
713 *sIt ==
',' || *sIt ==
'&' ||
721 if (classes.size() > 1) {
723 std::vector<std::string>::const_iterator it = classes.begin();
724 while ((++it) != classes.end()) {
725 for (
UInt_t cursor = 0; cursor != it->length(); ++cursor) {
726 chk = chk * 3 + it->at(cursor);
739 static const std::set<std::string> sSTLTypes {
740 "vector",
"list",
"forward_list",
"deque",
"map",
"unordered_map",
"multimap",
741 "unordered_multimap",
"set",
"unordered_set",
"multiset",
"unordered_multiset",
742 "queue",
"priority_queue",
"stack",
"iterator"};
743 std::vector<std::string>::const_iterator it;
744 std::string fileContent(
"");
745 for (it = headers.begin(); it != headers.end(); ++it) {
746 fileContent +=
"#include \"" + *it +
"\"\n";
748 for (it = unknown.begin(); it != unknown.end(); ++it) {
754 while (dirbase.Length() && dirbase !=
"." 755 && dirbase !=
"include" && dirbase !=
"inc" 756 && dirbase !=
"prec_stl") {
760 fileContent += TString(
"#include \"") + header +
"\"\n";
763 for (it = fwdDecls.begin(); it != fwdDecls.end(); ++it) {
764 fileContent +=
"class " + *it +
";\n";
766 fileContent +=
"#ifdef __CINT__ \n";
767 fileContent +=
"#pragma link C++ nestedclasses;\n";
768 fileContent +=
"#pragma link C++ nestedtypedefs;\n";
769 for (it = classes.begin(); it != classes.end(); ++it) {
771 size_t posTemplate = n.find(
'<');
772 std::set<std::string>::const_iterator iSTLType = sSTLTypes.end();
773 if (posTemplate != std::string::npos) {
774 n.erase(posTemplate, std::string::npos);
775 if (n.compare(0, 5,
"std::") == 0) {
778 iSTLType = sSTLTypes.find(n);
780 fileContent +=
"#pragma link C++ class ";
781 fileContent += *it +
"+;\n" ;
782 fileContent +=
"#pragma link C++ class ";
783 if (iSTLType != sSTLTypes.end()) {
787 fileContent += *it +
"::*;\n" ;
792 fileContent += *it +
"::*+;\n" ;
794 std::string oprLink(
"#pragma link C++ operators ");
798 if (iSTLType != sSTLTypes.end()) {
800 fileContent +=
"#ifdef G__VECTOR_HAS_CLASS_ITERATOR\n";
802 fileContent += oprLink +
"::iterator;\n";
803 fileContent += oprLink +
"::const_iterator;\n";
804 fileContent += oprLink +
"::reverse_iterator;\n";
806 fileContent +=
"#endif\n";
810 fileContent +=
"#endif\n";
814 filePointer = fopen(fileName,
"w");
815 if (filePointer ==
NULL) {
821 fprintf(filePointer,
"%s", fileContent.c_str());
837 const std::vector<std::string> &headers,
838 const std::vector<std::string> &fwdDecls,
839 const std::vector<std::string> &unknown)
845 std::vector<std::string> classes;
846 classes.push_back(className);
874 void exceptionErrorHandler(
void * ,
875 const std::string& reason,
877 throw std::runtime_error(std::string(
">>> Interpreter compilation error:\n") + reason);
891 class clangDiagSuppr {
893 clangDiagSuppr(clang::DiagnosticsEngine& diag): fDiagEngine(diag){
894 fOldDiagValue = fDiagEngine.getIgnoreAllWarnings();
895 fDiagEngine.setIgnoreAllWarnings(
true);
899 fDiagEngine.setIgnoreAllWarnings(fOldDiagValue);
902 clang::DiagnosticsEngine& fDiagEngine;
924 unsigned long offset = 0;
925 if (strncmp(tname.c_str(),
"const ", 6) == 0) {
928 unsigned long end = tname.length();
929 while( end && (tname[end-1]==
'&' || tname[end-1]==
'*' || tname[end-1]==
']') ) {
930 if ( tname[end-1]==
']' ) {
932 while ( end && tname[end-1]!=
'[' ) --end;
936 std::string innerbuf;
938 if (end != tname.length()) {
939 innerbuf = tname.substr(offset,end-offset);
940 inner = innerbuf.c_str();
942 inner = tname.c_str()+offset;
946 if (
gROOT->GetListOfClasses()->FindObject(inner)
958 newname =
"Long64_t";
960 newname =
"ULong64_t";
962 if (strcmp(inner,newname) == 0) {
965 if (offset) result =
"const ";
967 if ( end != tname.length() ) {
968 result += tname.substr(end,tname.length()-end);
970 if (result == tname) result.clear();
976 if (lastPos != inner)
980 const auto enName = lastPos;
981 const auto scopeNameSize = ((
Long64_t)lastPos - (
Long64_t)inner) /
sizeof(decltype(*lastPos)) - 2;
982 char *scopeName =
new char[scopeNameSize + 1];
983 strncpy(scopeName, inner, scopeNameSize);
984 scopeName[scopeNameSize] =
'\0';
986 if (
auto scope = static_cast<TClass *>(
gROOT->GetListOfClasses()->FindObject(scopeName))) {
987 auto enumTable =
dynamic_cast<const THashList *
>(scope->GetListOfEnums(
false));
988 if (enumTable && enumTable->THashList::FindObject(enName))
return true;
992 auto listOfEnums = scope->GetListOfEnums();
994 auto enumTable =
dynamic_cast<const THashList *
>(listOfEnums);
995 if (enumTable && enumTable->THashList::FindObject(enName))
return true;
1002 auto enumTable =
dynamic_cast<const THashList *
>(
gROOT->GetListOfEnums());
1003 if (enumTable && enumTable->THashList::FindObject(inner))
return true;
1019 fContent.reserve(size);
1026 return fContent.c_str();
1034 bool notPresent = fLinesHashSet.emplace(fHashFunc(str)).second;
1045 :
TInterpreter(name, title), fGlobalsListSerial(-1), fInterpreter(0),
1046 fMetaProcessor(0), fNormalizedCtxt(0), fPrevLoadedDynLibInfo(0),
1047 fClingCallbacks(0), fAutoLoadCallBack(0),
1048 fTransactionCount(0), fHeaderParsingOnDemand(true), fIsAutoParsingSuspended(
kFALSE)
1051 bool fromRootCling = dlsym(RTLD_DEFAULT,
"usedToIdentifyRootClingByDlSym");
1053 llvm::install_fatal_error_handler(&exceptionErrorHandler);
1057 std::vector<std::string> clingArgsStorage;
1058 clingArgsStorage.push_back(
"cling4root");
1060 std::string interpInclude;
1062 if (!fromRootCling) {
1067 clingArgsStorage.push_back(interpInclude);
1072 clingArgsStorage.push_back(interpInclude +
"/cling");
1080 std::string pchFilename = interpInclude.substr(2) +
"/allDict.cxx.pch";
1084 clingArgsStorage.push_back(
"-include-pch");
1085 clingArgsStorage.push_back(pchFilename);
1090 clingArgsStorage.push_back(
"-Wno-undefined-inline");
1091 clingArgsStorage.push_back(
"-fsigned-char");
1094 std::vector<const char*> interpArgs;
1095 for (std::vector<std::string>::const_iterator iArg = clingArgsStorage.begin(),
1096 eArg = clingArgsStorage.end(); iArg != eArg; ++iArg)
1097 interpArgs.push_back(iArg->c_str());
1102 extraArgs && *extraArgs; ++extraArgs) {
1103 if (!strcmp(*extraArgs,
"-resource-dir")) {
1105 llvmResourceDir = *(++extraArgs);
1107 interpArgs.push_back(*extraArgs);
1111 fInterpreter =
new cling::Interpreter(interpArgs.size(),
1113 llvmResourceDir.c_str());
1115 if (!fromRootCling) {
1120 fInterpreter->getCI()->getPreprocessorOpts().DisablePCHValidation =
true;
1124 fInterpreter->getCI()->getLangOpts().SpellChecking =
false;
1130 static llvm::raw_fd_ostream fMPOuts (STDOUT_FILENO,
false);
1136 if (fromRootCling) {
1138 "#include <string>\n" 1139 "using std::string;");
1142 + gClassDefInterpMacro +
"\n" 1143 + gInterpreterClassDef +
"\n" 1144 +
"#undef ClassImp\n" 1145 "#define ClassImp(X)\n" 1146 "#include <string>\n" 1147 "using namespace std;");
1175 if (!fromRootCling) {
1182 std::unique_ptr<TClingCallbacks>
1205 #if defined(R__MUST_REVISIT) 1206 #if R__MUST_REVISIT(6,2) 1207 Warning(
"~TCling",
"Interface not available yet.");
1208 #ifdef R__COMPLETE_MEM_TERMINATION 1229 #if defined(__CYGWIN__) && defined(__GNUC__) 1231 #elif defined(G__WIN32) 1232 MEMORY_BASIC_INFORMATION mbi;
1233 if (!VirtualQuery (
func, &mbi,
sizeof (mbi)))
1238 HMODULE hMod = (HMODULE) mbi.AllocationBase;
1239 TTHREAD_TLS_ARRAY(
char, MAX_PATH, moduleName);
1241 if (!GetModuleFileNameA (hMod, moduleName,
sizeof (moduleName)))
1248 if (dladdr((
void*)
func,&info)==0) {
1253 return info.dli_fname;
1265 auto setFactory = []() {
1269 static bool doneFactory = setFactory();
1278 const char** headers,
1279 void (*triggerFunc)())
const {
1287 searchPath = llvm::sys::path::parent_path(libraryName);
1307 if (
gROOT->IsRootFile(pcmFileName)) {
1311 ::Info(
"TCling::LoadPCM",
"Loading ROOT PCM %s", pcmFileName.Data());
1318 TFile *pcmFile =
new TFile(pcmFileName+
"?filetype=pcm",
"READ");
1320 auto listOfKeys = pcmFile->GetListOfKeys();
1326 (listOfKeys->GetSize() == 0) ||
1328 (listOfKeys->GetSize() == 1) &&
1329 !strcmp(((
TKey*)listOfKeys->At(0))->
GetName(),
"EMPTY")
1340 ::Info(
"TCling::LoadPCM",
"reading protoclasses for %s \n",pcmFileName.Data());
1342 pcmFile->GetObject(
"__ProtoClasses", protoClasses);
1345 for (
auto obj : *protoClasses) {
1355 for (
auto proto : *protoClasses) {
1364 ::Error(
"TCling::LoadPCM",
"Inconsistent TClassTable for %s",
1376 protoClasses->Clear();
1377 delete protoClasses;
1381 pcmFile->GetObject(
"__Typedefs", dataTypes);
1383 for (
auto typedf: *dataTypes)
1384 gROOT->GetListOfTypes()->Add(typedf);
1390 pcmFile->GetObject(
"__Enums", enums);
1393 auto listOfGlobals =
gROOT->GetListOfGlobals();
1394 auto listOfEnums =
dynamic_cast<THashList*
>(
gROOT->GetListOfEnums());
1396 for (
auto selEnum: *enums){
1397 const char* enumScope = selEnum->
GetTitle();
1398 const char* enumName = selEnum->GetName();
1399 if (strcmp(enumScope,
"") == 0){
1402 if (!listOfEnums->THashList::FindObject(enumName)){
1403 ((
TEnum*) selEnum)->SetClass(
nullptr);
1404 listOfEnums->Add(selEnum);
1406 for (
auto enumConstant: *static_cast<TEnum*>(selEnum)->GetConstants()){
1407 if (!listOfGlobals->FindObject(enumConstant)){
1408 listOfGlobals->Add(enumConstant);
1416 if (!nsTClassEntry){
1419 auto listOfEnums = nsTClassEntry->
fEnums.load();
1430 if (listOfEnums && !listOfEnums->THashList::FindObject(enumName)){
1431 ((
TEnum*) selEnum)->SetClass(nsTClassEntry);
1432 listOfEnums->Add(selEnum);
1445 ::Info(
"TCling::LoadPCM",
"Loading clang PCM %s", pcmFileName.Data());
1459 using namespace clang;
1461 class ExtLexicalStorageAdder:
public RecursiveASTVisitor<ExtLexicalStorageAdder>{
1466 bool VisitRecordDecl(clang::RecordDecl* rcd){
1468 Info(
"ExtLexicalStorageAdder",
1469 "Adding external lexical storage to class %s",
1470 rcd->getNameAsString().c_str());
1471 auto reDeclPtr = rcd->getMostRecentDecl();
1473 reDeclPtr->setHasExternalLexicalStorage();
1474 }
while ((reDeclPtr = reDeclPtr->getPreviousDecl()));
1494 const char** headers,
1495 const char** includePaths,
1496 const char* payloadCode,
1497 const char* fwdDeclsCode,
1498 void (*triggerFunc)(),
1500 const char** classesHeaders,
1501 Bool_t lateRegistration )
1504 static const bool fromRootCling = dlsym(RTLD_DEFAULT,
"usedToIdentifyRootClingByDlSym");
1508 if (fromRootCling)
return;
1512 bool isACLiC =
false;
1513 if (hasHeaderParsingOnDemand &&
1514 strstr(modulename,
"_ACLiC_dict") !=
nullptr){
1516 Info(
"TCling::RegisterModule",
1517 "Header parsing on demand is active but this is an Aclic library. Disabling it for this library.");
1518 hasHeaderParsingOnDemand =
false;
1535 for (
const char** inclPath = includePaths; *inclPath; ++inclPath) {
1538 cling::Transaction*
T = 0;
1540 for (
auto& fwdDeclArgToSkipPair : fwdDeclsArgToSkip){
1541 const std::string& fwdDecl = fwdDeclArgToSkipPair.first;
1542 const int nArgsToSkip = fwdDeclArgToSkipPair.second;
1544 assert(cling::Interpreter::kSuccess == compRes &&
1545 "A fwd declaration could not be compiled");
1546 if (compRes!=cling::Interpreter::kSuccess){
1547 Warning(
"TCling::RegisterModule",
1548 "Problems in declaring string '%s' were encountered.",
1563 TString code = gNonInterpreterClassDef;
1564 code += payloadCode;
1566 const char* dyLibName =
nullptr;
1570 if (!lateRegistration) {
1578 void* dyLibHandle = dlopen(dyLibName, RTLD_LAZY | RTLD_GLOBAL);
1581 char dyLibError[1000];
1582 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL, GetLastError(),
1583 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), dyLibError,
1584 sizeof(dyLibError),
NULL);
1586 const char* dyLibError = dlerror();
1591 ::Info(
"TCling::RegisterModule",
1592 "Cannot open shared library %s for dictionary %s:\n %s",
1593 dyLibName, modulename, dyLibError);
1603 if (hasHeaderParsingOnDemand && fwdDeclsCode){
1606 std::string fwdDeclsCodeLessEnums;
1610 std::string fwdDeclsLine;
1611 std::istringstream fwdDeclsCodeStr(fwdDeclsCode);
1612 std::vector<std::string> scope;
1613 while (std::getline(fwdDeclsCodeStr, fwdDeclsLine)) {
1614 if (fwdDeclsLine.find(
"namespace ") == 0
1615 || fwdDeclsLine.find(
"inline namespace ") == 0) {
1617 scope.push_back(fwdDeclsLine.substr(10,
1618 fwdDeclsLine.length() - 10 - 2));
1619 }
else if (fwdDeclsLine ==
"}") {
1621 }
else if (fwdDeclsLine.find(
"enum __attribute__((annotate(\"") == 0) {
1622 clang::DeclContext* DC = 0;
1623 for (
auto &&aScope: scope) {
1624 DC = cling::utils::Lookup::Namespace(&
fInterpreter->getSema(), aScope.c_str(), DC);
1630 if (scope.empty() || DC) {
1632 size_t posEnumName = fwdDeclsLine.find(
"\"))) ", 32);
1633 R__ASSERT(posEnumName != std::string::npos &&
"Inconsistent enum fwd decl!");
1635 while (isspace(fwdDeclsLine[posEnumName]))
1637 size_t posEnumNameEnd = fwdDeclsLine.find(
" : ", posEnumName);
1638 R__ASSERT(posEnumNameEnd != std::string::npos &&
"Inconsistent enum fwd decl (end)!");
1639 while (isspace(fwdDeclsLine[posEnumNameEnd]))
1643 std::string enumName = fwdDeclsLine.substr(posEnumName,
1644 posEnumNameEnd - posEnumName + 1);
1646 if (clang::NamedDecl* enumDecl
1647 = cling::utils::Lookup::Named(&
fInterpreter->getSema(),
1648 enumName.c_str(), DC)) {
1651 R__ASSERT(llvm::dyn_cast<clang::EnumDecl>(enumDecl) &&
"not an enum decl!");
1657 fwdDeclsCodeLessEnums += fwdDeclsLine +
"\n";
1661 if (fwdDeclsCodeLessEnums.size() != 0){
1662 auto compRes =
fInterpreter->declare(fwdDeclsCodeLessEnums, &T);
1663 assert(cling::Interpreter::kSuccess == compRes &&
1664 "The forward declarations could not be compiled");
1665 if (compRes!=cling::Interpreter::kSuccess){
1666 Warning(
"TCling::RegisterModule",
1667 "Problems in compiling forward declarations for module %s: '%s'",
1668 modulename, fwdDeclsCodeLessEnums.c_str()) ;
1676 ExtLexicalStorageAdder elsa;
1677 for (
auto dciIt = T->decls_begin();dciIt!=T->decls_end();dciIt++){
1678 cling::Transaction::DelayCallInfo& dci = *dciIt;
1679 for(
auto dit = dci.m_DGR.begin(); dit != dci.m_DGR.end(); ++dit) {
1680 clang::Decl* declPtr = *dit;
1681 elsa.TraverseDecl(declPtr);
1695 for (
const char** classesHeader = classesHeaders; *classesHeader; ++classesHeader) {
1696 temp=*classesHeader;
1698 size_t theTemplateHash = 0;
1699 bool addTemplate =
false;
1700 size_t posTemplate = temp.find(
'<');
1701 if (posTemplate != std::string::npos) {
1703 std::string templateName = temp.substr(0, posTemplate);
1709 for (
const char** classesHeader_inner = classesHeader; 0!=strcmp(*classesHeader_inner,
"@"); ++classesHeader_inner,++classesHeader){
1711 if (payloadCode == *classesHeader_inner ){
1713 if (addTemplate)
fPayloads.insert(theTemplateHash);
1716 Info(
"TCling::RegisterModule",
1717 "Adding a header for %s", temp.c_str());
1723 addTemplate =
false;
1730 if (strcmp(modulename,
"libCore")!=0 && strcmp(modulename,
"libRint")!=0
1731 && strcmp(modulename,
"libThread")!=0 && strcmp(modulename,
"libRIO")!=0
1732 && strcmp(modulename,
"libcomplexDict")!=0 && strcmp(modulename,
"libdequeDict")!=0
1733 && strcmp(modulename,
"liblistDict")!=0 && strcmp(modulename,
"libforward_listDict")!=0
1734 && strcmp(modulename,
"libvectorDict")!=0
1735 && strcmp(modulename,
"libmapDict")!=0 && strcmp(modulename,
"libmultimap2Dict")!=0
1736 && strcmp(modulename,
"libmap2Dict")!=0 && strcmp(modulename,
"libmultimapDict")!=0
1737 && strcmp(modulename,
"libsetDict")!=0 && strcmp(modulename,
"libmultisetDict")!=0
1738 && strcmp(modulename,
"libunordered_setDict")!=0 && strcmp(modulename,
"libunordered_multisetDict")!=0
1739 && strcmp(modulename,
"libunordered_mapDict")!=0 && strcmp(modulename,
"libunordered_multimapDict")!=0
1740 && strcmp(modulename,
"libvalarrayDict")!=0
1741 && strcmp(modulename,
"G__GenVector32")!=0 && strcmp(modulename,
"G__Smatrix32")!=0
1745 if (!
LoadPCM(pcmFileName, headers, triggerFunc)) {
1746 ::Error(
"TCling::RegisterModule",
"cannot find dictionary module %s",
1751 bool oldValue =
false;
1759 clangDiagSuppr diagSuppr(
fInterpreter->getSema().getDiagnostics());
1761 #if defined(R__MUST_REVISIT) 1762 #if R__MUST_REVISIT(6,2) 1763 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
1767 if (!hasHeaderParsingOnDemand){
1770 const cling::Transaction* watermark =
fInterpreter->getLastTransaction();
1771 cling::Interpreter::CompilationResult compRes =
fInterpreter->parseForModule(code.Data());
1777 assert(cling::Interpreter::kSuccess == compRes &&
1778 "Payload code of a dictionary could not be parsed correctly.");
1779 if (compRes!=cling::Interpreter::kSuccess) {
1780 Warning(
"TCling::RegisterModule",
1781 "Problems declaring payload for module %s.", modulename) ;
1790 if (!hasHeaderParsingOnDemand) {
1817 if (!hasHeaderParsingOnDemand) {
1820 "#undef __ROOTCLING__\n" 1821 + gInterpreterClassDef +
1828 dlclose(dyLibHandle);
1850 typedef std::vector<std::pair<TClass*,DictFuncPtr_t> >::iterator iterator;
1856 if ( i->first == oldcl ) {
1878 const char* input_line,
1879 cling::Interpreter::CompilationResult& compRes,
1883 return metaProcessor->process(input_line, compRes, result);
1885 catch (cling::InvalidDerefException&
ex)
1887 Error(
"HandleInterpreterException",
"%s.\n%s", ex.what(),
"Execution of your code was aborted.");
1897 if (
auto ie = dynamic_cast<const cling::InterpreterException*>(&e)) {
1913 TString sLine(line);
1929 gROOT->SetLineIsProcessing();
1933 gROOT->SetLineHasBeenProcessed();
1946 gROOT->SetLineIsProcessing();
1948 struct InterpreterFlagsRAII {
1950 bool fWasDynamicLookupEnabled;
1952 InterpreterFlagsRAII(cling::Interpreter* interp):
1954 fWasDynamicLookupEnabled(interp->isDynamicLookupEnabled())
1956 fInterpreter->enableDynamicLookup(
true);
1958 ~InterpreterFlagsRAII() {
1959 fInterpreter->enableDynamicLookup(fWasDynamicLookupEnabled);
1960 gROOT->SetLineHasBeenProcessed();
1969 cling::Interpreter::CompilationResult compRes = cling::Interpreter::kSuccess;
1970 if (!strncmp(sLine.Data(),
".L", 2) || !strncmp(sLine.Data(),
".x", 2) ||
1971 !strncmp(sLine.Data(),
".X", 2)) {
1974 TString mod_line(sLine);
1979 aclicMode, arguments, io);
1980 if (aclicMode.Length()) {
1982 R__ASSERT(aclicMode[0]==
'+' &&
"ACLiC mode must start with a +");
1984 if (aclicMode[1]==
'+') {
1990 compRes = cling::Interpreter::kFailure;
1992 if (strncmp(sLine.Data(),
".L", 2) != 0) {
1995 if (arguments.Length()==0) {
1999 Ssiz_t ext = fname.Last(
'.');
2004 mod_line =
function + arguments + io;
2005 cling::MetaProcessor::MaybeRedirectOutputRAII RAII(
fMetaProcessor);
2011 size_t unnamedMacroOpenCurly;
2014 std::string codeline;
2015 std::ifstream in(fname);
2017 std::getline(in, codeline);
2018 code += codeline +
"\n";
2020 unnamedMacroOpenCurly
2021 = cling::utils::isUnnamedMacro(code,
fInterpreter->getCI()->getLangOpts());
2025 cling::MetaProcessor::MaybeRedirectOutputRAII RAII(
fMetaProcessor);
2026 if (unnamedMacroOpenCurly != std::string::npos) {
2028 unnamedMacroOpenCurly);
2038 if (0!=strncmp(sLine.Data(),
".autodict ",10) && sLine !=
".autodict") {
2041 cling::MetaProcessor::MaybeRedirectOutputRAII RAII(
fMetaProcessor);
2044 bool isInclusionDirective = sLine.Contains(
"\n#include") || sLine.BeginsWith(
"#include");
2045 if (isInclusionDirective) {
2053 if (result.isValid())
2062 case cling::Interpreter::kSuccess: *error =
kNoError;
break;
2063 case cling::Interpreter::kFailure: *error =
kRecoverable;
break;
2064 case cling::Interpreter::kMoreInputExpected: *error =
kProcessing;
break;
2067 if (compRes == cling::Interpreter::kSuccess
2069 && !result.isVoid())
2071 gROOT->SetLineHasBeenProcessed();
2072 return result.simplisticCastAs<
long>();
2074 gROOT->SetLineHasBeenProcessed();
2095 if (path[0] ==
'-' && path[1] ==
'I')
2119 static const TClassRef clRefString(
"std::string");
2120 if (clRefString == cl) {
2130 const char* cobj = (
const char*) obj;
2137 auto inspInspect = [&] (ptrdiff_t offset){
2138 insp.
Inspect(const_cast<TClass*>(cl), insp.
GetParent(),
"_real", cobj, isTransient);
2139 insp.
Inspect(const_cast<TClass*>(cl), insp.
GetParent(),
"_imag", cobj + offset, isTransient);
2143 switch(complexType) {
2150 inspInspect(
sizeof(
float));
2155 inspInspect(
sizeof(
double));
2160 inspInspect(
sizeof(
int));
2165 inspInspect(
sizeof(
long));
2170 static clang::PrintingPolicy
2172 if (printPol.Indentation) {
2174 printPol.Indentation = 0;
2175 printPol.SuppressInitializers =
true;
2178 const char* clname = cl->
GetName();
2181 const clang::ASTContext& astContext =
fInterpreter->getCI()->getASTContext();
2182 const clang::Decl *scopeDecl = 0;
2187 scopeDecl = clingCI->
GetDecl();
2188 recordType = clingCI->
GetType();
2190 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
2192 scopeDecl = lh.findScope(clname, cling::LookupHelper::NoDiagnostics,
2196 Error(
"InspectMembers",
"Cannot find Decl for class %s", clname);
2199 const clang::CXXRecordDecl* recordDecl
2200 = llvm::dyn_cast<
const clang::CXXRecordDecl>(scopeDecl);
2202 Error(
"InspectMembers",
"Cannot find Decl for class %s is not a CXXRecordDecl.", clname);
2209 cling::Interpreter::PushTransactionRAII deserRAII(
fInterpreter);
2211 astContext.getASTRecordLayout(recordDecl);
2213 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2214 eField = recordDecl->field_end(); iField != eField; ++iField) {}
2217 const clang::ASTRecordLayout& recLayout
2218 = astContext.getASTRecordLayout(recordDecl);
2225 if (cl->
Size() != recLayout.getSize().getQuantity()) {
2226 Error(
"InspectMembers",
"TClass and cling disagree on the size of the class %s, respectively %d %lld\n",
2230 unsigned iNField = 0;
2233 for (clang::RecordDecl::field_iterator iField = recordDecl->field_begin(),
2234 eField = recordDecl->field_end(); iField != eField;
2235 ++iField, ++iNField) {
2238 clang::QualType memberQT = iField->getType();
2243 memberQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, memberQT,
fNormalizedCtxt->
GetConfig(),
false );
2244 if (memberQT.isNull()) {
2245 std::string memberName;
2246 llvm::raw_string_ostream stream(memberName);
2248 printPol.AnonymousTagLocations =
false;
2249 iField->getNameForDiagnostic(stream, printPol,
true );
2251 Error(
"InspectMembers",
2252 "Cannot retrieve QualType for member %s while inspecting class %s",
2253 memberName.c_str(), clname);
2256 const clang::Type* memType = memberQT.getTypePtr();
2258 std::string memberName;
2259 llvm::raw_string_ostream stream(memberName);
2261 printPol.AnonymousTagLocations =
false;
2262 iField->getNameForDiagnostic(stream, printPol,
true );
2264 Error(
"InspectMembers",
2265 "Cannot retrieve Type for member %s while inspecting class %s",
2266 memberName.c_str(), clname);
2271 Bool_t ispointer =
false;
2272 if (memNonPtrType->isPointerType()) {
2274 clang::QualType ptrQT
2275 = memNonPtrType->getAs<clang::PointerType>()->getPointeeType();
2280 ptrQT = cling::utils::Transform::GetPartiallyDesugaredType(astContext, ptrQT,
fNormalizedCtxt->
GetConfig(),
false );
2281 if (ptrQT.isNull()) {
2282 std::string memberName;
2283 llvm::raw_string_ostream stream(memberName);
2285 printPol.AnonymousTagLocations =
false;
2286 iField->getNameForDiagnostic(stream, printPol,
true );
2288 Error(
"InspectMembers",
2289 "Cannot retrieve pointee Type for member %s while inspecting class %s",
2290 memberName.c_str(), clname);
2293 memNonPtrType = ptrQT.getTypePtr();
2297 llvm::SmallString<8> arraySize;
2298 const clang::ArrayType* arrType = memNonPtrType->getAsArrayTypeUnsafe();
2299 unsigned arrLevel = 0;
2300 bool haveErrorDueToArray =
false;
2304 const clang::ConstantArrayType* constArrType =
2305 clang::dyn_cast<clang::ConstantArrayType>(arrType);
2307 constArrType->getSize().toStringUnsigned(arraySize);
2310 clang::QualType subArrQT = arrType->getElementType();
2311 if (subArrQT.isNull()) {
2312 std::string memberName;
2313 llvm::raw_string_ostream stream(memberName);
2315 printPol.AnonymousTagLocations =
false;
2316 iField->getNameForDiagnostic(stream, printPol,
true );
2318 Error(
"InspectMembers",
2319 "Cannot retrieve QualType for array level %d (i.e. element type of %s) for member %s while inspecting class %s",
2320 arrLevel, subArrQT.getAsString(printPol).c_str(),
2321 memberName.c_str(), clname);
2322 haveErrorDueToArray =
true;
2325 arrType = subArrQT.getTypePtr()->getAsArrayTypeUnsafe();
2327 if (haveErrorDueToArray) {
2332 std::string fieldName;
2333 if (memType->isPointerType()) {
2338 std::string
ioname(iField->getName());
2341 fieldName += arraySize;
2346 clang::CharUnits offset(astContext.toCharUnitsFromBits(recLayout.getFieldOffset(iNField)));
2347 ptrdiff_t fieldOffset = offset.getQuantity();
2357 auto iFiledQtype = iField->getType();
2358 if (
auto tagDecl = iFiledQtype->getAsTagDecl()){
2359 auto declAccess = tagDecl->getAccess();
2360 if (declAccess == AS_private || declAccess == AS_protected) {
2366 insp.
Inspect(const_cast<TClass*>(cl), insp.
GetParent(), fieldName.c_str(), cobj + fieldOffset, isTransient);
2369 const clang::CXXRecordDecl* fieldRecDecl = memNonPtrType->getAsCXXRecordDecl();
2373 std::string sFieldRecName;
2374 if (!ROOT::TMetaUtils::ExtractAttrPropertyFromName(*fieldRecDecl,
"iotype",sFieldRecName)){
2376 clang::QualType(memNonPtrType,0),
2386 insp.
InspectMember(sFieldRecName.c_str(), cobj + fieldOffset,
2387 (fieldName +
'.').c_str(),
transient);
2395 unsigned iNBase = 0;
2396 for (clang::CXXRecordDecl::base_class_const_iterator iBase
2397 = recordDecl->bases_begin(), eBase = recordDecl->bases_end();
2398 iBase != eBase; ++iBase, ++iNBase) {
2399 clang::QualType baseQT = iBase->getType();
2400 if (baseQT.isNull()) {
2401 Error(
"InspectMembers",
2402 "Cannot find QualType for base number %d while inspecting class %s",
2406 const clang::CXXRecordDecl* baseDecl
2407 = baseQT->getAsCXXRecordDecl();
2409 Error(
"InspectMembers",
2410 "Cannot find CXXRecordDecl for base number %d while inspecting class %s",
2415 std::string sBaseName;
2417 std::vector<TClass*> foundClasses;
2419 if (foundClasses.size()==1){
2420 baseCl=foundClasses[0];
2433 std::string qualNameForDiag;
2435 Error(
"InspectMembers",
2436 "Cannot find TClass for base class %s", qualNameForDiag.c_str() );
2441 if (iBase->isVirtual()) {
2444 Error(
"InspectMembers",
2445 "Base %s of class %s is virtual but no object provided",
2446 sBaseName.c_str(), clname);
2454 baseOffset = ci->
GetBaseOffset(baseCi, const_cast<void*>(obj),
2456 if (baseOffset == -1) {
2457 Error(
"InspectMembers",
2458 "Error calculating offset of virtual base %s of class %s",
2459 sBaseName.c_str(), clname);
2462 Error(
"InspectMembers",
2463 "Cannot calculate offset of virtual base %s of class %s",
2464 sBaseName.c_str(), clname);
2469 baseOffset = recLayout.getBaseClassOffset(baseDecl).getQuantity();
2516 bool oldDynLookup =
fInterpreter->isDynamicLookupEnabled();
2567 std::string file_name = filename;
2568 size_t at = std::string::npos;
2569 while ((at = file_name.find(
"/./")) != std::string::npos)
2570 file_name.replace(at, 3,
"/");
2572 std::string filesStr =
"";
2573 llvm::raw_string_ostream filesOS(filesStr);
2574 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
2575 cling::ClangInternalState::printIncludedFiles(filesOS, SM);
2578 llvm::SmallVector<llvm::StringRef, 100> files;
2579 llvm::StringRef(filesStr).split(files,
"\n");
2581 std::set<std::string> fileMap;
2583 for (llvm::SmallVector<llvm::StringRef, 100>::const_iterator
2584 iF = files.begin(), iE = files.end(); iF != iE; ++iF) {
2585 if ((*iF) == file_name.c_str())
return kTRUE;
2586 fileMap.insert(*iF);
2589 if (fileMap.empty())
return kFALSE;
2592 TString sFilename(file_name.c_str());
2594 && fileMap.count(sFilename.Data())) {
2600 incPath.Append(
":").Prepend(
" ");
2601 incPath.ReplaceAll(
" -I",
":");
2602 while (incPath.Index(
" :") != -1) {
2603 incPath.ReplaceAll(
" :",
":");
2605 incPath.Prepend(
".:");
2606 sFilename = file_name.c_str();
2608 && fileMap.count(sFilename.Data())) {
2613 sFilename = file_name.c_str();
2615 cling::DynamicLibraryManager* dyLibManager
2618 if (dyLibManager->isLibraryLoaded(found)) {
2623 const clang::DirectoryLookup *CurDir = 0;
2624 clang::Preprocessor &PP =
fInterpreter->getCI()->getPreprocessor();
2625 clang::HeaderSearch &HS = PP.getHeaderSearchInfo();
2626 const clang::FileEntry *FE = HS.LookupFile(file_name.c_str(),
2627 clang::SourceLocation(),
2630 clang::ArrayRef<std::pair<
const clang::FileEntry *,
2631 const clang::DirectoryEntry *>>(),
2640 if (FE && FE->isValid()) {
2642 clang::SourceManager &SM =
fInterpreter->getCI()->getSourceManager();
2644 clang::FileID FID = SM.translateFile(FE);
2645 if (!FID.isInvalid() && FID.getHashValue() == 0)
2648 clang::SrcMgr::SLocEntry SLocE = SM.getSLocEntry(FID);
2649 if (SLocE.isFile() && SLocE.getFile().getContentCache()->getRawBuffer() == 0)
2651 if (!FID.isInvalid())
2655 sFilename = FE->getName();
2657 && fileMap.count(sFilename.Data())) {
2668 #if defined(R__WIN32) || defined(__CYGWIN__) 2669 HMODULE hModules[1024];
2671 unsigned long cbModules;
2673 hProcess = (
void *)::GetCurrentProcess();
2674 ::EnumProcessModules(hProcess, hModules,
sizeof(hModules), &cbModules);
2676 for (i = 1; i < (cbModules /
sizeof(
void *)); i++) {
2677 static const int bufsize = 260;
2678 wchar_t winname[bufsize];
2679 char posixname[bufsize];
2680 ::GetModuleFileNameExW(hProcess, hModules[i], winname, bufsize);
2681 #if defined(__CYGWIN__) 2682 cygwin_conv_path(CCP_WIN_W_TO_POSIX, winname, posixname, bufsize);
2684 std::wstring wpath = winname;
2685 std::replace(wpath.begin(), wpath.end(),
'\\',
'/');
2686 string path(wpath.begin(), wpath.end());
2687 strncpy(posixname, path.c_str(), bufsize);
2693 #elif defined(R__MACOSX) 2697 while (
const mach_header* mh = _dyld_get_image_header(imageIndex)) {
2699 if (mh->filetype == MH_DYLIB) {
2700 if (
const char* imageName = _dyld_get_image_name(imageIndex)) {
2708 #elif defined(R__LINUX) 2721 PointerNo4* procLinkMap = (PointerNo4*)dlopen(0, RTLD_LAZY | RTLD_GLOBAL);
2724 LinkMap* linkMap = (LinkMap*) ((PointerNo4*)procLinkMap->fPtr)->fPtr;
2728 dlclose(procLinkMap);
2732 while (iDyLib->fNext) {
2733 iDyLib = iDyLib->fNext;
2738 Error(
"TCling::UpdateListOfLoadedSharedLibraries",
2739 "Platform not supported!");
2750 if (!filename)
return;
2754 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
2755 if (!DLM->isLibraryLoaded(filename)) {
2756 DLM->loadLibrary(filename,
true );
2759 #if defined(R__MACOSX) 2761 if (!strncmp(filename,
"/usr/lib/system/", 16)
2762 || !strncmp(filename,
"/usr/lib/libc++", 15)
2763 || !strncmp(filename,
"/System/Library/Frameworks/", 27)
2764 || !strncmp(filename,
"/System/Library/PrivateFrameworks/", 34)
2765 || !strncmp(filename,
"/System/Library/CoreServices/", 29)
2766 || !strcmp(filename,
"cl_kernels")
2767 || strstr(filename,
"/usr/lib/libSystem")
2768 || strstr(filename,
"/usr/lib/libstdc++")
2769 || strstr(filename,
"/usr/lib/libicucore")
2770 || strstr(filename,
"/usr/lib/libbsm")
2771 || strstr(filename,
"/usr/lib/libobjc")
2772 || strstr(filename,
"/usr/lib/libresolv")
2773 || strstr(filename,
"/usr/lib/libauto")
2774 || strstr(filename,
"/usr/lib/libcups")
2775 || strstr(filename,
"/usr/lib/libDiagnosticMessagesClient")
2776 || strstr(filename,
"/usr/lib/liblangid")
2777 || strstr(filename,
"/usr/lib/libCRFSuite")
2778 || strstr(filename,
"/usr/lib/libpam")
2779 || strstr(filename,
"/usr/lib/libOpenScriptingUtil")
2780 || strstr(filename,
"/usr/lib/libextension"))
2782 #elif defined(__CYGWIN__) 2784 static const int bufsize = 260;
2785 char posixwindir[bufsize];
2786 char *windir = getenv(
"WINDIR");
2788 cygwin_conv_path(CCP_WIN_A_TO_POSIX, windir, posixwindir, bufsize);
2790 snprintf(posixwindir,
sizeof(posixwindir),
"/Windows/");
2791 if (strstr(filename, posixwindir) ||
2792 strstr(filename,
"/usr/bin/cyg"))
2794 #elif defined(R__WIN32) 2795 if (strstr(filename,
"/Windows/"))
2797 #elif defined (R__LINUX) 2798 if (strstr(filename,
"/ld-linux")
2799 || strstr(filename,
"linux-gnu/")
2800 || strstr(filename,
"/libstdc++.")
2801 || strstr(filename,
"/libgcc")
2802 || strstr(filename,
"/libc.")
2803 || strstr(filename,
"/libdl.")
2804 || strstr(filename,
"/libm."))
2822 Error(
"Load",
"Trying to load library (%s) from rootcling.",filename);
2828 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
2829 std::string canonLib = DLM->lookupLibrary(filename);
2830 cling::DynamicLibraryManager::LoadLibResult res
2831 = cling::DynamicLibraryManager::kLoadLibNotFound;
2832 if (!canonLib.empty()) {
2834 res = DLM->loadLibrary(filename, system);
2838 cling::Interpreter::CompilationResult compRes;
2839 cling::MetaProcessor::MaybeRedirectOutputRAII RAII(
fMetaProcessor);
2841 if (compRes == cling::Interpreter::kSuccess)
2842 res = cling::DynamicLibraryManager::kLoadLibSuccess;
2846 if (res == cling::DynamicLibraryManager::kLoadLibSuccess) {
2850 case cling::DynamicLibraryManager::kLoadLibSuccess:
return 0;
2851 case cling::DynamicLibraryManager::kLoadLibAlreadyLoaded:
return 1;
2901 Warning(
"Calc",
"waiting for cling thread to free");
2904 gROOT->SetLineIsProcessing();
2912 cling::Interpreter::CompilationResult cr =
fInterpreter->evaluate(line, valRef);
2913 if (cr != cling::Interpreter::kSuccess) {
2921 if (!valRef.isValid()) {
2930 if (valRef.isVoid()) {
2937 gROOT->SetLineHasBeenProcessed();
2940 return valRef.simplisticCastAs<
long>();
2947 void (*histaddFunc)(
const char*
line))
2952 #if defined(R__MUST_REVISIT) 2953 #if R__MUST_REVISIT(6,2) 2954 Warning(
"SetGetline",
"Cling should support the equivalent of SetGetlineFunc(getlineFunc, histaddFunc)");
2967 if ((std::distance(T.decls_begin(), T.decls_end()) != 1)
2968 || T.deserialized_decls_begin() != T.deserialized_decls_end()
2969 || T.macros_begin() != T.macros_end()
2970 || ((!T.getFirstDecl().isNull()) && ((*T.getFirstDecl().begin()) != T.getWrapperFD()))) {
2987 std::set<TObject*>::iterator iSpecial = ((std::set<TObject*>*)
fgSetOfSpecials)->find(obj);
2990 ((std::set<TObject*>*)fgSetOfSpecials)->erase(iSpecial);
3004 #if defined(R__MUST_REVISIT) 3005 #if R__MUST_REVISIT(6,2) 3007 Warning(
"Reset",
"Cling should support the equivalent of scratch_upto(&fDictPos)");
3017 #if defined(R__MUST_REVISIT) 3018 #if R__MUST_REVISIT(6,2) 3020 Warning(
"ResetAll",
"Cling should support the equivalent of complete reset (unload everything but the startup decls.");
3047 #if defined(R__MUST_REVISIT) 3048 #if R__MUST_REVISIT(6,2) 3050 Warning(
"ResetGlobalVar",
"Cling should support the equivalent of resetglobalvar(obj)");
3062 #if defined(R__MUST_REVISIT) 3063 #if R__MUST_REVISIT(6,2) 3065 Warning(
"RewindDictionary",
"Cling should provide a way to revert transaction similar to rewinddictionary()");
3076 #if defined(R__MUST_REVISIT) 3077 #if R__MUST_REVISIT(6,2) 3079 Warning(
"DeleteGlobal",
"Cling should provide the equivalent of deleteglobal(obj), see also DeleteVariable.");
3091 #if defined(R__MUST_REVISIT) 3092 #if R__MUST_REVISIT(6,2) 3093 Warning(
"DeleteVariable",
"should do more that just reseting the value to zero");
3098 llvm::StringRef srName(name);
3099 const char* unscopedName =
name;
3100 llvm::StringRef::size_type posScope = srName.rfind(
"::");
3101 const clang::DeclContext* declCtx = 0;
3102 if (posScope != llvm::StringRef::npos) {
3103 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
3104 const clang::Decl* scopeDecl
3105 = lh.findScope(srName.substr(0, posScope),
3106 cling::LookupHelper::WithDiagnostics);
3108 Error(
"DeleteVariable",
"Cannot find enclosing scope for variable %s",
3112 declCtx = llvm::dyn_cast<clang::DeclContext>(scopeDecl);
3114 Error(
"DeleteVariable",
3115 "Enclosing scope for variable %s is not a declaration context",
3119 unscopedName += posScope + 2;
3121 clang::NamedDecl* nVarDecl
3122 = cling::utils::Lookup::Named(&
fInterpreter->getSema(), unscopedName, declCtx);
3124 Error(
"DeleteVariable",
"Unknown variable %s", name);
3127 clang::VarDecl* varDecl = llvm::dyn_cast<clang::VarDecl>(nVarDecl);
3129 Error(
"DeleteVariable",
"Entity %s is not a variable", name);
3133 clang::QualType qType = varDecl->getType();
3137 if (type->isPointerType()) {
3138 int** ppInt = (
int**)
fInterpreter->getAddressOfGlobal(GlobalDecl(varDecl));
3140 if (ppInt) *ppInt = 0;
3150 #if defined(R__MUST_REVISIT) 3151 #if R__MUST_REVISIT(6,2) 3153 Warning(
"SaveContext",
"Cling should provide a way to record a state watermark similar to store_dictposition(&fDictPos)");
3163 #if defined(R__MUST_REVISIT) 3164 #if R__MUST_REVISIT(6,2) 3166 Warning(
"SaveGlobalsContext",
"Cling should provide a way to record a watermark for the list of global variable similar to store_dictposition(&fDictPosGlobals)");
3200 struct AlternateTupleIntDoubleAsc
3206 struct AlternateTupleIntDoubleDes
3214 std::tuple<int,double> value;
3215 AlternateTupleIntDoubleAsc asc;
3216 AlternateTupleIntDoubleDes des;
3218 size_t offset0 = ((
char*)&(std::get<0>(value))) - ((
char*)&value);
3219 size_t offset1 = ((
char*)&(std::get<1>(value))) - ((
char*)&value);
3221 size_t ascOffset0 = ((
char*)&(asc._0)) - ((
char*)&asc);
3222 size_t ascOffset1 = ((
char*)&(asc._1)) - ((
char*)&asc);
3224 size_t desOffset0 = ((
char*)&(des._0)) - ((
char*)&des);
3225 size_t desOffset1 = ((
char*)&(des._1)) - ((
char*)&des);
3227 if (offset0 == ascOffset0 && offset1 == ascOffset1) {
3229 }
else if (offset0 == desOffset0 && offset1 == desOffset1) {
3239 std::string alternateName =
"TEmulatedTuple";
3240 alternateName.append( classname + 5 );
3242 std::string guard_name;
3244 std::ostringstream guard;
3245 guard <<
"ROOT_INTERNAL_TEmulated_";
3246 guard << guard_name;
3248 std::ostringstream alternateTuple;
3249 alternateTuple <<
"#ifndef " << guard.str() <<
"\n";
3250 alternateTuple <<
"#define " << guard.str() <<
"\n";
3251 alternateTuple <<
"namespace ROOT { namespace Internal {\n";
3252 alternateTuple <<
"template <class... Types> struct TEmulatedTuple;\n";
3253 alternateTuple <<
"template <> struct " << alternateName <<
" {\n";
3258 unsigned int nMember = 0;
3259 auto iter = tupleContent.
fElements.begin() + 1;
3260 auto theEnd = tupleContent.
fElements.end() - 1;
3261 while (iter != theEnd) {
3262 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
3269 unsigned int nMember = tupleContent.
fElements.size() - 3;
3270 auto iter = tupleContent.
fElements.rbegin() + 1;
3271 auto theEnd = tupleContent.
fElements.rend() - 1;
3272 while (iter != theEnd) {
3273 alternateTuple <<
" " << *iter <<
" _" << nMember <<
";\n";
3280 Fatal(
"TCling::SetClassInfo::AtlernateTuple",
3281 "Layout of std::tuple on this platform is unexpected.");
3286 alternateTuple <<
"};\n";
3287 alternateTuple <<
"}}\n";
3288 alternateTuple <<
"#endif\n";
3290 Error(
"Load",
"Could not declare %s",alternateName.c_str());
3293 alternateName =
"ROOT::Internal::" + alternateName;
3294 return alternateName;
3320 if (strncmp(cl->
GetName(),
"tuple<",strlen(
"tuple<"))==0) {
3327 if (!info->IsValid()) {
3351 zombieCandidate =
kTRUE;
3353 if (!info->IsLoaded()) {
3358 zombieCandidate =
kTRUE;
3408 static const char *anonEnum =
"anonymous enum ";
3409 static const int cmplen = strlen(anonEnum);
3411 if (0 == strncmp(name,anonEnum,cmplen)) {
3430 if (isClassOrNamespaceOnly &&
3433 const char *classname =
name;
3444 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
3446 const clang::Decl *decl
3447 = lh.findScope(classname,
3448 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
3449 : cling::LookupHelper::NoDiagnostics,
3453 decl = lh.findScope(buf,
3454 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
3455 : cling::LookupHelper::NoDiagnostics,
3472 clang::ClassTemplateSpecializationDecl *tmpltDecl =
3473 llvm::dyn_cast_or_null<clang::ClassTemplateSpecializationDecl>
3474 (type->getAsCXXRecordDecl());
3475 if (tmpltDecl && !tmpltDecl->getPointOfInstantiation().isValid()) {
3494 if (tci.
Property() & propertiesMask) {
3530 const cling::LookupHelper& lh =
fInterpreter->getLookupHelper();
3531 const clang::Decl *decl
3532 = lh.findClassTemplate(name,
3533 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
3534 : cling::LookupHelper::NoDiagnostics);
3536 std::string strname =
"std::";
3538 decl = lh.findClassTemplate(strname,
3539 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
3540 : cling::LookupHelper::NoDiagnostics);
3566 cl->
fBase = listOfBase;
3582 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
3585 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
3586 cling::Interpreter::PushTransactionRAII deserRAII(
fInterpreter);
3588 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
3589 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
3590 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(), declEnd = allDeclContexts.end();
3591 declIter != declEnd; ++declIter) {
3593 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
3594 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
3595 if (
const clang::EnumDecl* ED = dyn_cast<clang::EnumDecl>(*DI)) {
3598 PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy());
3599 llvm::raw_string_ostream stream(buf);
3601 Policy.AnonymousTagLocations =
false;
3602 ED->getNameForDiagnostic(stream, Policy,
false);
3606 const char*
name = buf.c_str();
3608 enumList.
Get(ED, name);
3630 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
3634 if (
const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
3635 cling::Interpreter::PushTransactionRAII deserRAII(
fInterpreter);
3637 llvm::SmallVector< DeclContext *, 4> allDeclContexts;
3638 const_cast< clang::DeclContext *
>(DC)->collectAllContexts(allDeclContexts);
3639 for (llvm::SmallVector<DeclContext*, 4>::iterator declIter = allDeclContexts.begin(),
3640 declEnd = allDeclContexts.end(); declIter != declEnd; ++declIter) {
3642 for (clang::DeclContext::decl_iterator DI = (*declIter)->decls_begin(),
3643 DE = (*declIter)->decls_end(); DI != DE; ++DI) {
3644 if (
const clang::FunctionTemplateDecl* FTD = dyn_cast<clang::FunctionTemplateDecl>(*DI)) {
3645 funcTempList->
Get(FTD);
3743 if (llvm::isa<clang::NamespaceDecl>(cli->
GetDecl())) {
3752 Error(
"GenerateTClass",
3753 "Cannot find %s::Class_Version()! Class version might be wrong.",
3760 if (newvers == -1) {
3768 newvers = callfunc.
ExecInt(0);
3770 Error(
"GenerateTClass",
3771 "Cannot invoke %s::Class_Version()! Class version might be wrong.",
3775 if (newvers != oldvers) {
3792 static void GenerateTClass_GatherInnerIncludes(cling::Interpreter *interp, TString &includes,
TClingClassInfo *info)
3796 const clang::ClassTemplateSpecializationDecl *templateCl
3797 = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(info->
GetDecl());
3799 for(
unsigned int i=0; i < templateCl->getTemplateArgs().size(); ++i) {
3800 const clang::TemplateArgument &arg( templateCl->getTemplateArgs().get(i) );
3804 if (!uType->isFundamentalType() && !uType->isEnumeralType()) {
3806 const clang::CXXRecordDecl *argdecl = uType->getAsCXXRecordDecl();
3809 TClingClassInfo subinfo(interp,*(argdecl->getASTContext().getRecordType(argdecl).getTypePtr()));
3810 GenerateTClass_GatherInnerIncludes(interp, includes, &subinfo);
3813 llvm::raw_string_ostream OS(Result);
3814 arg.print(argdecl->getASTContext().getPrintingPolicy(),OS);
3815 Warning(
"TCling::GenerateTClass",
"Missing header file for %s",OS.str().c_str());
3830 if (!info || !info->
IsValid()) {
3831 Fatal(
"GenerateTClass",
"Requires a valid ClassInfo object");
3836 std::string classname;
3840 Info(
"GenerateTClass",
"Will (try to) generate the compiled TClass for %s.",classname.c_str());
3844 GenerateTClass_GatherInnerIncludes(
fInterpreter,includes,info);
3850 Error(
"GenerateTClass",
"Even though the dictionary generation for %s seemed successful we can't find the TClass bootstrap!",classname.c_str());
3856 cl =
new TClass(classinfo, version, 0, 0, -1, -1, silent);
3862 cl =
new TClass(classinfo, 1, 0, 0, -1, -1, silent);
3887 if (classes == 0 || classes[0] == 0) {
3891 std::vector<std::string> listClasses;
3893 const char* current = classes, *prev = classes;
3897 if (*current ==
';') {
3898 listClasses.push_back(std::string(prev, current - prev));
3901 else if (*(current + 1) == 0) {
3902 listClasses.push_back(std::string(prev, current + 1 - prev));
3906 std::vector<std::string> listIncludes;
3908 const char* current = includes, *prev = includes;
3912 if (*current ==
';') {
3913 listIncludes.push_back(std::string(prev, current - prev));
3916 else if (*(current + 1) == 0) {
3917 listIncludes.push_back(std::string(prev, current + 1 - prev));
3923 std::vector<std::string>(), std::vector<std::string>());
3944 if (
const ValueDecl* decl = (
const ValueDecl*) d){
3947 if (hasIoName && ioName != name)
return 0;
3965 const clang::Decl* possibleEnum = 0;
3970 const clang::DeclContext* dc = 0;
3971 if (
const clang::Decl* D = cci->
GetDecl()) {
3972 if (!(dc = dyn_cast<clang::NamespaceDecl>(D))) {
3973 dc = dyn_cast<clang::RecordDecl>(D);
3978 possibleEnum = cling::utils::Lookup::Named(&
fInterpreter->getSema(),
name, dc);
3980 Error(
"TCling::GetEnum",
"DeclContext not found for %s .\n", name);
3985 possibleEnum = cling::utils::Lookup::Named(&
fInterpreter->getSema(),
name);
3987 if (possibleEnum && (possibleEnum != (clang::Decl*)-1)
3988 && isa<clang::EnumDecl>(possibleEnum)) {
3989 return possibleEnum;
4001 llvm::StringRef mangled_name = gv->getName();
4016 std::string scopename(demangled_name_c);
4017 free(demangled_name_c);
4023 std::string dataname;
4025 if (!strncmp(scopename.c_str(),
"typeinfo for ",
sizeof(
"typeinfo for ")-1)) {
4026 scopename.erase(0,
sizeof(
"typeinfo for ")-1);
4027 }
else if (!strncmp(scopename.c_str(),
"vtable for ",
sizeof(
"vtable for ")-1)) {
4028 scopename.erase(0,
sizeof(
"vtable for ")-1);
4031 std::string::size_type pos = scopename.rfind(
'(');
4032 if (pos != std::string::npos) {
4036 pos = scopename.rfind(
':');
4037 if (pos != std::string::npos) {
4038 if ((pos != 0) && (scopename[pos-1] ==
':')) {
4039 dataname = scopename.substr(pos+1);
4040 scopename.erase(pos-1);
4044 dataname = scopename;
4052 if (scopename.size()) {
4068 Error(
"GetDataMemberWithValue()",
"not implemented");
4078 Error(
"GetDataMemberAtAddr()",
"not implemented");
4088 const char* params,
Bool_t objectIsConst )
4100 func.
SetFunc(&gcl, method, params, &offset);
4106 return mangled_name;
4121 GetMethod(method, proto, objectIsConst, 0 , mode).GetMangledName();
4133 const char* params,
Bool_t objectIsConst )
4145 func.
SetFunc(&gcl, method, params, &offset);
4174 std::vector<DeclId_t>& res)
const 4177 const clang::Decl* CtxDecl
4179 S.Context.getTranslationUnitDecl();
4180 const clang::DeclContext*
4181 DeclCtx = llvm::dyn_cast<
const clang::RecordDecl>(CtxDecl);
4183 DeclCtx = dyn_cast<clang::NamespaceDecl>(CtxDecl);
4184 if (!DeclCtx)
return;
4185 clang::DeclarationName DName
4186 = &S.Context.Idents.get(funcname);
4187 clang::LookupResult
R(S, DName, clang::SourceLocation(),
4188 Sema::LookupOrdinaryName, clang::Sema::ForRedeclaration);
4189 S.LookupQualifiedName(R, const_cast<DeclContext*>(DeclCtx));
4190 if (R.empty())
return;
4192 res.reserve(res.size() + (R.end() - R.begin()));
4193 for (clang::LookupResult::iterator IR = R.begin(), ER = R.end();
4195 if (
const clang::FunctionDecl* FD
4196 = llvm::dyn_cast<const clang::FunctionDecl>(*IR)) {
4197 if (!FD->getDescribedFunctionTemplate()) {
4341 func.
SetFunc(&cl,
function, params, &offset);
4357 const char* params,
Bool_t objectIsConst,
int* error)
4370 void* address = (
void*)((
Long_t)addr + offset);
4377 const char* params,
int* error)
4379 Execute(obj,cl,method,params,
false,error);
4394 Error(
"Execute",
"No method was defined");
4403 if (argc > nparms) {
4404 Error(
"Execute",
"Too many parameters to call %s, got %d but expected at most %d.",method->
GetName(),argc,nparms);
4407 if (nparms != argc) {
4417 Int_t firstDefault = -1;
4418 for (
Int_t i = 0; i < nparms; i ++) {
4425 if (firstDefault >= 0) {
4426 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);
4428 Error(
"Execute",
"Too few arguments to call %s, got only %d but expected %d.",method->
GetName(),argc,nparms);
4434 const char* listpar =
"";
4435 TString complete(10);
4439 for (
Int_t i = 0; i < argc; i ++) {
4447 TString chpar(
'\"');
4448 chpar += (nxtpar->String()).
ReplaceAll(
"\"",
"\\\"");
4455 complete += nxtpar->String();
4458 listpar = complete.Data();
4476 const CXXMethodDecl * mdecl = dyn_cast<CXXMethodDecl>(minfo->
GetMethodDecl());
4478 void* address = (
void*)((
Long_t)addr + offset);
4485 const void* args[] ,
4490 Error(
"ExecuteWithArgsAndReturn",
"No method was defined");
4496 func.ExecWithArgsAndReturn(address, args, nargs, ret);
4517 Warning(
"GetTopLevelMacroName",
"Must change return type!");
4564 #if defined(R__MUST_REVISIT) 4565 #if R__MUST_REVISIT(6,0) 4566 Warning(
"GetCurrentMacroName",
"Must change return type!");
4579 TTHREAD_TLS(
char*) t = 0;
4580 TTHREAD_TLS(
unsigned int) tlen = 0;
4582 unsigned int dlen = strlen(typeDesc);
4585 t =
new char[dlen + 1];
4588 const char* s, *template_start;
4589 if (!strstr(typeDesc,
"(*)(")) {
4590 s = strchr(typeDesc,
' ');
4591 template_start = strchr(typeDesc,
'<');
4592 if (!strcmp(typeDesc,
"long long")) {
4593 strlcpy(t, typeDesc, dlen + 1);
4595 else if (!strncmp(typeDesc,
"unsigned ", s + 1 - typeDesc)) {
4596 strlcpy(t, typeDesc, dlen + 1);
4602 else if (s && (template_start == 0 || (s < template_start))) {
4603 strlcpy(t, s + 1, dlen + 1);
4606 strlcpy(t, typeDesc, dlen + 1);
4610 strlcpy(t, typeDesc, dlen + 1);
4613 while (l > 0 && (t[l - 1] ==
'*' || t[l - 1] ==
'&')) {
4627 const std::map<char, unsigned int> keyLenMap = {{
'c',6},{
'n',10},{
't',8},{
'h',7},{
'e',5},{
'v',4}};
4629 if (rootmapfile && *rootmapfile) {
4633 std::ifstream
file(rootmapfile);
4634 std::string
line; line.reserve(200);
4635 std::string lib_name; line.reserve(100);
4636 bool newFormat=
false;
4637 while (getline(file, line,
'\n')) {
4639 (strstr(line.c_str(),
"Library.")!=
nullptr || strstr(line.c_str(),
"Declare.")!=
nullptr)) {
4645 if (line.compare(0, 9,
"{ decls }") == 0) {
4648 while (getline(file, line,
'\n')) {
4649 if (line[0] ==
'[')
break;
4650 uniqueString->
Append(line);
4653 const char firstChar=line[0];
4654 if (firstChar ==
'[') {
4656 auto brpos = line.find(
']');
4657 if (brpos == string::npos)
continue;
4658 lib_name = line.substr(1, brpos-1);
4660 while( lib_name[nspaces] ==
' ' ) ++nspaces;
4661 if (nspaces) lib_name.replace(0, nspaces,
"");
4663 TString lib_nameTstr(lib_name.c_str());
4664 TObjArray* tokens = lib_nameTstr.Tokenize(
" ");
4668 Info(
"ReadRootmapFile",
"new section for %s", lib_nameTstr.Data());
4671 Info(
"ReadRootmapFile",
"section for %s (library does not exist)", lib_nameTstr.Data());
4678 auto keyLenIt = keyLenMap.find(firstChar);
4679 if (keyLenIt == keyLenMap.end())
continue;
4680 unsigned int keyLen = keyLenIt->second;
4682 const char *keyname = line.c_str()+keyLen;
4684 Info(
"ReadRootmapFile",
"class %s in %s", keyname, lib_name.c_str());
4687 if(lib_name != isThere->GetValue()){
4688 if (firstChar ==
'n') {
4690 Info(
"ReadRootmapFile",
"namespace %s found in %s is already in %s",
4691 keyname, lib_name.c_str(), isThere->GetValue());
4692 }
else if (firstChar ==
'h'){
4694 lib_name+=isThere->GetValue();
4698 Warning(
"ReadRootmapFile",
"%s %s found in %s is already in %s", line.substr(0, keyLen).c_str(),
4699 keyname, lib_name.c_str(), isThere->GetValue());
4703 Info(
"ReadRootmapFile",
"Key %s was already defined for %s", keyname, lib_name.c_str());
4733 TString
sname =
"system";
4744 #if defined(R__MACOSX) && (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR) 4776 using namespace clang;
4778 class ExtVisibleStorageAdder:
public RecursiveASTVisitor<ExtVisibleStorageAdder>{
4784 ExtVisibleStorageAdder(std::unordered_set<const NamespaceDecl*>& nsSet): fNSSet(nsSet) {};
4785 bool VisitNamespaceDecl(NamespaceDecl* nsDecl) {
4789 nsDecl->setHasExternalVisibleStorage();
4790 fNSSet.insert(nsDecl);
4794 std::unordered_set<const NamespaceDecl*>& fNSSet;
4831 TObjArray* paths = ldpath.Tokenize(
";");
4833 TObjArray* paths = ldpath.Tokenize(
":");
4840 for (
Int_t j = 0; j < i; j++) {
4841 TString pd = ((
TObjString *)paths->
At(j))->GetString();
4851 Info(
"LoadLibraryMap",
"%s", d.Data());
4856 if (f.EndsWith(
".rootmap")) {
4862 Info(
"LoadLibraryMap",
" rootmap file: %s", p.Data());
4879 if (f.BeginsWith(
"rootmap")) {
4884 Warning(
"LoadLibraryMap",
"please rename %s to end with \".rootmap\"", p.Data());
4897 if (rootmapfile && *rootmapfile) {
4904 else if (res == -3) {
4914 while ((rec = (
TEnvRec*) next())) {
4916 if (!strncmp(cls.Data(),
"Library.", 8) && cls.Length() > 8) {
4923 TObjArray* tokens = libs.Tokenize(delim);
4928 cls.ReplaceAll(
"@@",
"::");
4931 cls.ReplaceAll(
"-",
" ");
4935 Info(
"LoadLibraryMap",
"class %s in %s", cls.Data(), wlib);
4938 Info(
"LoadLibraryMap",
"class %s in %s (library does not exist)", cls.Data(), lib);
4953 else if (!strncmp(cls.Data(),
"Declare.", 8) && cls.Length() > 8) {
4957 cls.ReplaceAll(
"-",
" ");
4963 cling::Transaction*
T =
nullptr;
4965 assert(cling::Interpreter::kSuccess == compRes &&
"A declaration in a rootmap could not be compiled");
4967 if (compRes!=cling::Interpreter::kSuccess){
4969 "Problems in %s declaring '%s' were encountered.", rootmapfile, uniqueString.
Data()) ;
4974 for (
auto declIt = T->decls_begin(); declIt < T->decls_end(); ++declIt) {
4975 if (declIt->m_DGR.isSingleDecl()) {
4976 if (Decl* D = declIt->m_DGR.getSingleDecl()) {
4977 if (NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(D)) {
4978 evsAdder.TraverseDecl(NSD);
5011 const TObjArray* sharedLibL = sharedLibLStr.Tokenize(
" ");
5013 for (
Int_t ilib = 0; ilib < nrSharedLibs; ilib++) {
5014 const TString sharedLibStr = ((
TObjString*)sharedLibL->
At(ilib))->GetString();
5020 TString rootMapBaseStr = sharedLibBaseStr;
5021 if (sharedLibBaseStr.EndsWith(
".dll")) {
5022 rootMapBaseStr.ReplaceAll(
".dll",
"");
5024 else if (sharedLibBaseStr.EndsWith(
".DLL")) {
5025 rootMapBaseStr.ReplaceAll(
".DLL",
"");
5027 else if (sharedLibBaseStr.EndsWith(
".so")) {
5028 rootMapBaseStr.ReplaceAll(
".so",
"");
5030 else if (sharedLibBaseStr.EndsWith(
".sl")) {
5031 rootMapBaseStr.ReplaceAll(
".sl",
"");
5033 else if (sharedLibBaseStr.EndsWith(
".dl")) {
5034 rootMapBaseStr.ReplaceAll(
".dl",
"");
5036 else if (sharedLibBaseStr.EndsWith(
".a")) {
5037 rootMapBaseStr.ReplaceAll(
".a",
"");
5040 Error(
"ReloadAllSharedLibraryMaps",
"Unknown library type %s", sharedLibBaseStr.Data());
5044 rootMapBaseStr +=
".rootmap";
5047 Error(
"ReloadAllSharedLibraryMaps",
"Could not find rootmap %s in path", rootMap);
5054 Error(
"ReloadAllSharedLibraryMaps",
"Error loading map %s", rootMap);
5072 const TObjArray* sharedLibL = sharedLibLStr.Tokenize(
" ");
5074 const TString sharedLibStr = ((
TObjString*)sharedLibL->
At(ilib))->GetString();
5089 if (!
fMapfile || !library || !*library) {
5092 TString libname(library);
5093 Ssiz_t idx = libname.Last(
'.');
5095 libname.Remove(idx);
5097 size_t len = libname.Length();
5102 while ((rec = (
TEnvRec *) next())) {
5104 if (cls.Length() > 2) {
5111 TObjArray* tokens = libs.Tokenize(delim);
5113 if (!strncmp(cls.Data(),
"Library.", 8) && cls.Length() > 8) {
5117 cls.ReplaceAll(
"@@",
"::");
5120 cls.ReplaceAll(
"-",
" ");
5122 if (!strncmp(lib, libname.Data(), len)) {
5124 Error(
"UnloadLibraryMap",
"entry for <%s, %s> not found in library map table", cls.Data(), lib);
5132 TString library_rootmap(library);
5133 if (!library_rootmap.EndsWith(
".rootmap"))
5134 library_rootmap.Append(
".rootmap");
5154 TString key = TString(
"Library.") + cls;
5157 key.ReplaceAll(
"::",
"@@");
5160 key.ReplaceAll(
" ",
"-");
5189 free(demangled_name);
5205 std::string demangled_name(demangled_name_c);
5206 free(demangled_name_c);
5219 result =
AutoLoad(demangled_name.c_str(), knowDictNotLoaded);
5244 Info(
"TCling::AutoLoad",
5245 "Trying to autoload for %s", cls);
5251 Info(
"TCling::AutoLoad",
5252 "Disabled due to gROOT or gInterpreter being invalid/not ready (the class name is %s)", cls);
5259 Info(
"TCling::AutoLoad",
5260 "Explicitly disabled (the class name is %s)", cls);
5276 if (!deplibs.IsNull()) {
5278 TObjArray* tokens = deplibs.Tokenize(delim);
5281 if (
gROOT->LoadClass(cls, deplib) == 0) {
5283 Info(
"TCling::AutoLoad",
5284 "loaded dependent library %s for %s", deplib, cls);
5288 Error(
"TCling::AutoLoad",
5289 "failure loading dependent library %s for %s",
5294 if (lib && lib[0]) {
5295 if (
gROOT->LoadClass(cls, lib) == 0) {
5297 Info(
"TCling::AutoLoad",
5298 "loaded library %s for %s", lib, cls);
5303 Error(
"TCling::AutoLoad",
5304 "failure loading library %s for %s", lib, cls);
5319 cling::Interpreter *interpreter)
5321 std::string code = gNonInterpreterClassDef ;
5328 code += (
"#include \"");
5332 code += (
"#ifdef __ROOTCLING__\n" 5333 "#undef __ROOTCLING__\n" 5334 + gInterpreterClassDef +
5337 cling::Interpreter::CompilationResult cr;
5343 Sema &SemaR = interpreter->getSema();
5345 clangDiagSuppr diagSuppr(SemaR.getDiagnostics());
5347 #if defined(R__MUST_REVISIT) 5348 #if R__MUST_REVISIT(6,2) 5349 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
5353 cr = interpreter->parseForModule(code);
5371 Int_t nHheadersParsed = 0;
5374 bool skipFirstEntry =
false;
5375 std::vector<std::string> autoparseKeys;
5376 if (strchr(cls,
'<')) {
5382 if (!autoparseKeys.empty()){
5383 TString templateName(autoparseKeys[0]);
5384 auto tokens = templateName.Tokenize(
"::");
5385 clang::NamedDecl* previousScopeAsNamedDecl =
nullptr;
5386 clang::DeclContext* previousScopeAsContext =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
5388 previousScopeAsContext =
fInterpreter->getSema().getStdNamespace();
5389 for (
auto const scopeObj : *tokens){
5390 auto scopeName = ((
TObjString*) scopeObj)->String().Data();
5391 previousScopeAsNamedDecl = cling::utils::Lookup::Named(&
fInterpreter->getSema(), scopeName, previousScopeAsContext);
5393 if ((clang::NamedDecl*)-1 == previousScopeAsNamedDecl)
break;
5394 previousScopeAsContext = llvm::dyn_cast_or_null<clang::DeclContext>(previousScopeAsNamedDecl);
5395 if (!previousScopeAsContext)
break;
5399 if ((clang::NamedDecl*)-1 != previousScopeAsNamedDecl) {
5400 if (
auto templateDecl = llvm::dyn_cast_or_null<clang::ClassTemplateDecl>(previousScopeAsNamedDecl)) {
5401 if (
auto templatedDecl = templateDecl->getTemplatedDecl()) {
5402 skipFirstEntry =
nullptr != templatedDecl->getDefinition();
5409 if (topLevel) autoparseKeys.emplace_back(cls);
5411 for (
const auto & apKeyStr : autoparseKeys) {
5412 if (skipFirstEntry) {
5413 skipFirstEntry=
false;
5416 if (apKeyStr.empty())
continue;
5417 const char *apKey = apKeyStr.c_str();
5421 Info(
"TCling::AutoParse",
5422 "Starting autoparse for %s\n", apKey);
5427 const cling::Transaction *
T =
fInterpreter->getCurrentTransaction();
5429 auto const &hNamesPtrs = iter->second;
5431 Info(
"TCling::AutoParse",
5432 "We can proceed for %s. We have %s headers.", apKey, std::to_string(hNamesPtrs.size()).c_str());
5434 for (
auto & hName : hNamesPtrs) {
5436 if (0 !=
fPayloads.count(normNameHash)) {
5437 float initRSSval=0.f, initVSIZEval=0.f;
5439 (
void) initVSIZEval;
5442 "Parsing full payload for %s", apKey);
5449 if (cRes != cling::Interpreter::kSuccess) {
5450 if (hName[0] ==
'\n')
5451 Error(
"AutoParse",
"Error parsing payload code for class %s with content:\n%s", apKey, hName);
5460 Info(
"Autoparse",
">>> RSS key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initRSSval, endRSSval, endRSSval-initRSSval);
5461 Info(
"Autoparse",
">>> VSIZE key %s - before %.3f MB - after %.3f MB - delta %.3f MB", apKey, initVSIZEval, endVSIZEval, endVSIZEval-initVSIZEval);
5467 "Parsing single header %s", hName);
5470 if (cRes != cling::Interpreter::kSuccess) {
5471 Error(
"AutoParse",
"Error parsing headerfile %s for class %s.", hName, apKey);
5483 if (strchr(apKey,
'<')) {
5490 return nHheadersParsed;
5511 Info(
"TCling::AutoParse",
5512 "Trying to autoparse for %s", cls);
5532 if (nHheadersParsed != 0) {
5551 return nHheadersParsed > 0 ? 1 : 0;
5564 mangled_name.c_str())) {
5575 std::string
name(demangled_name_c);
5576 free(demangled_name_c);
5584 if (!strncmp(name.c_str(),
"typeinfo for ",
sizeof(
"typeinfo for ")-1)) {
5585 name.erase(0,
sizeof(
"typeinfo for ")-1);
5586 }
else if (!strncmp(name.c_str(),
"vtable for ",
sizeof(
"vtable for ")-1)) {
5587 name.erase(0,
sizeof(
"vtable for ")-1);
5588 }
else if (!strncmp(name.c_str(),
"operator",
sizeof(
"operator")-1)
5589 && !isalnum(name[
sizeof(
"operator")])) {
5591 name.erase(0,
sizeof(
"operator")-1);
5592 std::string::size_type pos = name.rfind(
'(');
5593 if (pos != std::string::npos) {
5594 name.erase(0, pos + 1);
5595 pos = name.find(
",");
5596 if (pos != std::string::npos) {
5600 pos = name.rfind(
" const");
5601 if (pos != std::string::npos) {
5602 name.erase(pos, strlen(
" const"));
5604 while (!name.empty() && strchr(
"&*", name.back()))
5605 name.erase(name.length() - 1);
5609 std::string::size_type pos = name.rfind(
'(');
5610 if (pos != std::string::npos) {
5614 pos = name.rfind(
':');
5615 if (pos != std::string::npos) {
5616 if ((pos != 0) && (name[pos-1] ==
':')) {
5624 if (libs.IsNull()) {
5633 while (libs.Tokenize(lib, posLib)) {
5643 void* addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(mangled_name.c_str());
5670 const NamedDecl* ND =
static_cast<const NamedDecl*
>(vTD);
5671 const TagDecl* td = dyn_cast<TagDecl>(ND);
5675 tdDef = td->getDefinition();
5681 if (llvm::isa<clang::FunctionDecl>(td->getDeclContext())) {
5685 clang::QualType
type( td->getTypeForDecl(), 0 );
5687 auto declName=ND->getNameAsString();
5695 name = ND->getNameAsString();
5710 const TagDecl* tdOld = llvm::dyn_cast_or_null<TagDecl>(cci->
GetDecl());
5711 if (!tdOld || (tdDef && tdDef != tdOld)) {
5768 std::set<TClass*> modifiedTClasses;
5773 bool isTUTransaction =
false;
5774 if (!T.empty() && T.decls_begin() + 1 == T.decls_end() && !T.hasNestedTransactions()) {
5775 clang::Decl* FirstDecl = *(T.decls_begin()->m_DGR.begin());
5776 if (llvm::isa<clang::TranslationUnitDecl>(FirstDecl)) {
5779 isTUTransaction =
true;
5783 std::set<const void*> TransactionDeclSet;
5784 if (!isTUTransaction && T.decls_end() - T.decls_begin()) {
5785 const clang::Decl* WrapperFD = T.getWrapperFD();
5786 for (cling::Transaction::const_iterator
I = T.decls_begin(),
E = T.decls_end();
5788 if (
I->m_Call != cling::Transaction::kCCIHandleTopLevelDecl
5789 &&
I->m_Call != cling::Transaction::kCCIHandleTagDeclDefinition)
5792 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
5793 DE =
I->m_DGR.end(); DI != DE; ++DI) {
5794 if (*DI == WrapperFD)
5796 TransactionDeclSet.insert(*DI);
5797 ((
TCling*)
gCling)->HandleNewDecl(*DI,
false, modifiedTClasses);
5804 for (cling::Transaction::const_iterator
I = T.deserialized_decls_begin(),
5805 E = T.deserialized_decls_end();
I !=
E; ++
I) {
5806 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
5807 DE =
I->m_DGR.end(); DI != DE; ++DI)
5808 if (TransactionDeclSet.find(*DI) == TransactionDeclSet.end()) {
5824 std::vector<TClass*> modifiedTClassesDiff(modifiedTClasses.size());
5825 std::vector<TClass*>::iterator it;
5826 it = set_difference(modifiedTClasses.begin(), modifiedTClasses.end(),
5829 modifiedTClassesDiff.begin());
5830 modifiedTClassesDiff.resize(it - modifiedTClassesDiff.begin());
5833 ((
TCling*)
gCling)->GetModTClasses().insert(modifiedTClassesDiff.begin(),
5834 modifiedTClassesDiff.end());
5835 for (std::vector<TClass*>::const_iterator
I = modifiedTClassesDiff.begin(),
5836 E = modifiedTClassesDiff.end();
I !=
E; ++
I) {
5838 if (!
gROOT->GetListOfClasses()->FindObject(*
I)) {
5842 cling::Interpreter::PushTransactionRAII RAII(
fInterpreter);
5862 for (DeclContext::decl_iterator RI = DC->decls_begin(), RE = DC->decls_end(); RI != RE; ++RI) {
5863 if (isa<VarDecl>(*RI) || isa<FieldDecl>(*RI)) {
5864 const clang::ValueDecl* VD = dyn_cast<ValueDecl>(*RI);
5868 datamembers->
Unload(var);
5871 }
else if (
const FunctionDecl* FD = dyn_cast<FunctionDecl>(*RI)) {
5874 functions->
Unload(
function);
5875 function->Update(0);
5877 }
else if (
const EnumDecl* ED = dyn_cast<EnumDecl>(*RI)) {
5885 if (enumConst && enumConst->IsValid()) {
5886 datamembers->
Unload(enumConst);
5887 enumConst->Update(0);
5893 }
else if (
const FunctionTemplateDecl* FTD = dyn_cast<FunctionTemplateDecl>(*RI)) {
5895 if (functiontemplate) {
5896 functiontemplates->
Unload(functiontemplate);
5897 functiontemplate->
Update(0);
5914 cling::Transaction::const_nested_iterator iNested = T.nested_begin();
5915 for(cling::Transaction::const_iterator
I = T.decls_begin(),
E = T.decls_end();
5917 if (
I->m_Call == cling::Transaction::kCCIHandleVTable)
5920 if (
I->m_Call == cling::Transaction::kCCINone) {
5926 for (DeclGroupRef::const_iterator DI =
I->m_DGR.begin(),
5927 DE =
I->m_DGR.end(); DI != DE; ++DI) {
5931 if ( (*DI)->isFromASTFile() )
5935 if (isa<VarDecl>(*DI) || isa<EnumConstantDecl>(*DI)) {
5953 }
else if (
const FunctionDecl* FD = dyn_cast<FunctionDecl>(*DI)) {
5955 if (
function && function->IsValid()) {
5956 functions->
Unload(
function);
5957 function->Update(0);
5960 }
else if (
const FunctionTemplateDecl* FTD = dyn_cast<FunctionTemplateDecl>(*DI)) {
5962 if (functiontemplate) {
5963 functiontemplates->
Unload(functiontemplate);
5964 functiontemplate->
Update(0);
5967 }
else if (
const EnumDecl* ED = dyn_cast<EnumDecl>(*DI)) {
5970 TIter iEnumConst(
e->GetConstants());
5976 globals->
Unload(enumConst);
5977 enumConst->Update(0);
5985 }
else if (
const clang::RecordDecl* RD = dyn_cast<RecordDecl>(*DI)) {
5986 std::vector<TClass*> vectTClass;
5988 if (RD->isCompleteDefinition()) {
5990 for (std::vector<TClass*>::iterator CI = vectTClass.begin(), CE = vectTClass.end();
5993 (*CI)->ResetClassInfo();
5998 }
else if (
const clang::NamespaceDecl* ND = dyn_cast<NamespaceDecl>(*DI)) {
5999 std::vector<TClass*> vectTClass;
6001 for (std::vector<TClass*>::iterator CI = vectTClass.begin(), CE = vectTClass.end();
6004 if (ND->isOriginalNamespace()) {
6005 (*CI)->ResetClassInfo();
6021 std::size_t normNameHash = triter->second;
6027 auto const &hNamesPtrs = iter->second;
6028 for (
auto &hName : hNamesPtrs) {
6030 Info(
"TransactionRollback",
6031 "Restoring ability to autoaparse: %s", hName);
6070 if (!cls || !*cls) {
6078 const char* libs = libs_record->
GetValue();
6079 return (*libs) ? libs : 0;
6083 TString
c = TString(
"Library.") + cls;
6086 c.ReplaceAll(
"::",
"@@");
6089 c.ReplaceAll(
" ",
"-");
6096 const char* libs = libs_record->
GetValue();
6097 return (*libs) ? libs : 0;
6112 if (!
fMapfile || !lib || !lib[0]) {
6115 TString libname(lib);
6116 Ssiz_t idx = libname.Last(
'.');
6118 libname.Remove(idx);
6122 size_t len = libname.Length();
6123 while ((rec = (
TEnvRec*) next())) {
6124 const char* libs = rec->
GetValue();
6125 if (!strncmp(libs, libname.Data(), len) && strlen(libs) >= len
6126 && (!libs[len] || libs[len] ==
' ' || libs[len] ==
'.')) {
6139 #if defined(R__MUST_REVISIT) 6140 #if R__MUST_REVISIT(6,2) 6141 Warning(
"IsErrorMessagesEnabled",
"Interface not available yet.");
6153 #if defined(R__MUST_REVISIT) 6154 #if R__MUST_REVISIT(6,2) 6155 Warning(
"SetErrorMessages",
"Interface not available yet.");
6171 llvm::SmallVector<std::string, 10> includePaths;
6173 fInterpreter->GetIncludePaths(includePaths,
false,
true);
6174 if (
const size_t nPaths = includePaths.size()) {
6175 assert(!(nPaths & 1) &&
"GetIncludePath, number of paths and options is not equal");
6177 for (
size_t i = 0; i < nPaths; i += 2) {
6182 if (includePaths[i] !=
"-I")
6185 fIncludePath.Append(includePaths[i + 1], includePaths[i + 1].length());
6216 assert(fout != 0 &&
"DisplayIncludePath, 'fout' parameter is null");
6218 llvm::SmallVector<std::string, 10> includePaths;
6220 fInterpreter->GetIncludePaths(includePaths,
false,
true);
6221 if (
const size_t nPaths = includePaths.size()) {
6222 assert(!(nPaths & 1) &&
"DisplayIncludePath, number of paths and options is not equal");
6224 std::string allIncludes(
"include path:");
6225 for (
size_t i = 0; i < nPaths; i += 2) {
6227 allIncludes += includePaths[i];
6229 if (includePaths[i] !=
"-I")
6231 allIncludes += includePaths[i + 1];
6234 fprintf(fout,
"%s\n", allIncludes.c_str());
6253 #if defined(R__MUST_REVISIT) 6254 #if R__MUST_REVISIT(6,2) 6255 Warning(
"GenericError",
"Interface not available yet.");
6285 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.");
6293 Error(
"Getp2f2funcname",
"Will not be implemented: " 6294 "all function pointers are compiled!");
6303 #if defined(R__MUST_REVISIT) 6304 #if R__MUST_REVISIT(6,2) 6305 Warning(
"GetSecurityError",
"Interface not available yet.");
6316 cling::Interpreter::CompilationResult compRes;
6317 cling::MetaProcessor::MaybeRedirectOutputRAII RAII(
fMetaProcessor);
6319 return compRes == cling::Interpreter::kFailure;
6330 return (
fInterpreter->declare(text) == cling::Interpreter::kSuccess);
6338 TTHREAD_TLS_DECL(std::string,buffer);
6340 return buffer.c_str();
6406 #if defined(R__MUST_REVISIT) 6407 #if R__MUST_REVISIT(6,2) 6408 Warning(
"SetErrmsgcallback",
"Interface not available yet.");
6420 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.");
6428 Error(
"SetRTLD_NOW()",
"Will never be implemented! Don't use!");
6435 Error(
"SetRTLD_LAZY()",
"Will never be implemented! Don't use!");
6450 cling::DynamicLibraryManager* DLM =
fInterpreter->getDynamicLibraryManager();
6451 std::string canonical = DLM->lookupLibrary(path);
6452 if (canonical.empty()) {
6456 cling::Interpreter::CompilationResult compRes;
6457 cling::MetaProcessor::MaybeRedirectOutputRAII RAII(
fMetaProcessor);
6459 return compRes == cling::Interpreter::kFailure;
6475 std::vector<std::string>& completions)
6486 auto compRes = interpreter->evaluate(code, *V);
6487 return compRes!=cling::Interpreter::kSuccess ? 0 : 1 ;
6494 using namespace cling;
6508 if (value.isValid() && value.needsManagedAllocation()) {
6521 cling::Interpreter *interpreter = ((
TCling*)
gCling)->GetInterpreter();
6531 auto iSpecObj = iSpecObjMap->second.find(Name);
6532 if (iSpecObj != iSpecObjMap->second.end()) {
6534 return iSpecObj->second;
6540 Sema &SemaR = interpreter->getSema();
6541 ASTContext&
C = SemaR.getASTContext();
6542 Preprocessor &PP = SemaR.getPreprocessor();
6543 Parser&
P =
const_cast<Parser&
>(interpreter->getParser());
6544 Preprocessor::CleanupAndRestoreCacheRAII cleanupRAII(PP);
6545 Parser::ParserCurTokRestoreRAII savedCurToken(P);
6548 Token& Tok =
const_cast<Token&
>(P.getCurToken());
6549 Tok.setKind(tok::semi);
6555 Sema::ContextAndScopeRAII pushedDCAndS(SemaR, C.getTranslationUnitDecl(),
6558 TObject* specObj =
gROOT->FindSpecialObject(Name, LookupCtx);
6561 Error(
"GetObjectAddress",
"Got a special object without LookupCtx!");
6575 clang::CXXRecordDecl* klass)
const 6577 using namespace clang;
6578 ASTContext& Ctx = klass->getASTContext();
6579 FriendDecl::FriendUnion friendUnion(
function);
6582 FriendDecl* friendDecl = FriendDecl::Create(Ctx, klass, sl, friendUnion, sl);
6583 klass->pushFriendDecl(friendDecl);
6597 if (func)
return ((
TClingCallFunc*)func)->GetDecl()->getCanonicalDecl();
6668 f->
Exec(address, &val);
6682 const void* args[] ,
6849 f->
SetFunc(ci, method, params, offset);
6858 f->
SetFunc(ci, method, params, objectIsConst, offset);
6886 f->
SetFuncProto(ci, method, proto, objectIsConst, offset, mode);
6896 llvm::SmallVector<clang::QualType, 4> funcProto;
6897 for (std::vector<TypeInfo_t*>::const_iterator iter = proto.begin(), end = proto.end();
6898 iter != end; ++iter) {
6899 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
6911 llvm::SmallVector<clang::QualType, 4> funcProto;
6912 for (std::vector<TypeInfo_t*>::const_iterator iter = proto.begin(), end = proto.end();
6913 iter != end; ++iter) {
6914 funcProto.push_back( ((
TClingTypeInfo*)(*iter))->GetQualType() );
6916 f->
SetFuncProto(ci, method, funcProto, objectIsConst, offset, mode);
6931 if (!declid)
return kFALSE;
6933 const clang::Decl *scope;
6935 else scope =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
6937 const clang::Decl *decl =
reinterpret_cast<const clang::Decl*
>(declid);
6938 const clang::DeclContext *ctxt = clang::Decl::castToDeclContext(scope);
6939 if (!decl || !ctxt)
return kFALSE;
6940 if (decl->getDeclContext()->Equals(ctxt))
6942 else if (decl->getDeclContext()->isTransparentContext() &&
6943 decl->getDeclContext()->getParent()->Equals(ctxt))
7015 return TClinginfo->
GetMethodNArg(method, proto, objectIsConst, mode);
7040 TClinginfo->
Init(name);
7049 TClinginfo->
Init(tagnum);
7057 return TClinginfo->
IsBase(name);
7088 return TClinginfo->
IsValidMethod(method, proto,
false, offset, mode);
7096 return TClinginfo->
IsValidMethod(method, proto, objectIsConst, offset, mode);
7104 return TClinginfo->
Next();
7152 return TClinginfo->
Size();
7160 return TClinginfo->
Tagnum();
7176 TTHREAD_TLS_DECL(std::string,
output);
7186 return TClinginfo->
Name();
7194 return TClinginfo->
Title();
7231 ClassInfo_t* base)
const 7244 return TClinginfo->
Next();
7252 return TClinginfo->
Next(onlyDirect);
7260 return TClinginfo->
Offset(address, isDerivedObject);
7273 return TClinginfo->
GetBaseOffset(TClinginfoBase, address, isDerivedObject);
7289 return (ClassInfo_t *)TClinginfo->
GetBase();
7297 return TClinginfo->
Tagnum();
7305 TTHREAD_TLS_DECL(std::string,
output);
7315 return TClinginfo->
Name();
7360 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
7361 const clang::ValueDecl* vd = llvm::dyn_cast_or_null<clang::ValueDecl>(decl);
7394 return TClinginfo->
Next();
7402 return TClinginfo->
Offset();
7450 return TClinginfo->
Name();
7458 return TClinginfo->
Title();
7465 TTHREAD_TLS_DECL(std::string,
result);
7476 Decl* decl =
static_cast<Decl*
>(
const_cast<void*
>(declId));
7477 ASTContext &
C = decl->getASTContext();
7478 SourceRange commentRange;
7479 decl->addAttr(
new (C) AnnotateAttr( commentRange, C, attribute, 0 ) );
7490 cling::Interpreter &interp,
7493 const clang::TypeDecl* td = llvm::dyn_cast<clang::TypeDecl>(decl->getDeclContext());
7496 clang::QualType qualType(td->getTypeForDecl(),0);
7498 unsigned int level = 0;
7499 for(
size_t cursor = name.length()-1; cursor != 0; --cursor) {
7500 if (name[cursor] ==
'>') ++level;
7501 else if (name[cursor] ==
'<' && level) --level;
7502 else if (level == 0 && name[cursor] ==
':') {
7503 name.erase(0,cursor+1);
7514 if (llvm::isa<clang::CXXConstructorDecl>(decl))
7518 }
else if (llvm::isa<clang::CXXDestructorDecl>(decl))
7521 output.insert(output.begin(),
'~');
7523 llvm::raw_string_ostream stream(output);
7524 auto printPolicy = decl->getASTContext().getPrintingPolicy();
7526 printPolicy.AnonymousTagLocations =
false;
7527 decl->getNameForDiagnostic(stream, printPolicy,
false);
7557 return (FuncTempInfo_t*)
const_cast<void*
>(declid);
7568 return (FuncTempInfo_t*)ft_info;
7588 if (!ft_info)
return 0;
7589 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
7590 return ft->getTemplateParameters()->size();
7599 if (!ft_info)
return 0;
7600 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
7601 return ft->getTemplateParameters()->getMinRequiredArguments();
7609 if (!ft_info)
return 0;
7614 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
7616 switch (ft->getAccess()) {
7617 case clang::AS_public:
7620 case clang::AS_protected:
7623 case clang::AS_private:
7626 case clang::AS_none:
7627 if (ft->getDeclContext()->isNamespace())
7635 const clang::FunctionDecl *fd = ft->getTemplatedDecl();
7636 if (
const clang::CXXMethodDecl *md =
7637 llvm::dyn_cast<clang::CXXMethodDecl>(fd)) {
7638 if (md->getTypeQualifiers() & clang::Qualifiers::Const) {
7641 if (md->isVirtual()) {
7647 if (
const clang::CXXConstructorDecl *cd =
7648 llvm::dyn_cast<clang::CXXConstructorDecl>(md)) {
7649 if (cd->isExplicit()) {
7653 else if (
const clang::CXXConversionDecl *cd =
7654 llvm::dyn_cast<clang::CXXConversionDecl>(md)) {
7655 if (cd->isExplicit()) {
7669 if (!ft_info)
return;
7670 const clang::FunctionTemplateDecl *ft = (clang::FunctionTemplateDecl*)ft_info;
7682 if (!ft_info)
return;
7683 const clang::FunctionTemplateDecl *ft = (
const clang::FunctionTemplateDecl*)ft_info;
7687 if (
const RedeclarableTemplateDecl *AnnotFD
7689 if (AnnotateAttr *
A = AnnotFD->getAttr<AnnotateAttr>()) {
7690 output =
A->getAnnotation().str();
7694 if (!ft->isFromASTFile()) {
7744 const clang::Decl* decl =
reinterpret_cast<const clang::Decl*
>(declid);
7746 const clang::FunctionDecl* fd = llvm::dyn_cast_or_null<clang::FunctionDecl>(decl);
7778 return info->
NArg();
7794 return info->
Next();
7818 return (TypeInfo_t*)info->
Type();
7826 TTHREAD_TLS_DECL(TString, mangled_name);
7828 return mangled_name;
7871 return info->
Title();
7890 if (info && info->
IsValid()) {
7892 clang::QualType QT( typeinfo->
GetQualType().getCanonicalType() );
7893 if (QT->isEnumeralType()) {
7895 }
else if (QT->isPointerType()) {
7897 QT = llvm::cast<clang::PointerType>(QT)->getPointeeType();
7898 if ( QT->isCharType() ) {
7903 }
else if ( QT->isFloatingType() ) {
7904 int sz = typeinfo->
Size();
7905 if (sz == 4 || sz == 8) {
7911 }
else if ( QT->isIntegerType() ) {
7912 int sz = typeinfo->
Size();
7965 return (MethodArgInfo_t*)
7982 return info->
Next();
8006 return info->
Name();
8066 TClinginfo->
Init(name);
8082 return TClinginfo->
Name();
8106 return TClinginfo->
Size();
8156 const char*
name)
const 8160 TClinginfo->
Init(name);
8176 return TClinginfo->
Next();
8192 return TClinginfo->
Size();
8208 return TClinginfo->
Name();
8216 return TClinginfo->
Title();
int TCling__AutoLoadCallback(const char *className)
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 TypeInfo_t * TypeInfo_Factory() const
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual const char * GetName() const
Returns name of object.
const TClingTypeInfo * Type() const
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
const clang::FunctionTemplateDecl * GetFunctionTemplate(const char *fname) const
virtual const char * TypeInfo_Name(TypeInfo_t *) const
virtual Bool_t FuncTempInfo_IsValid(FuncTempInfo_t *) const
Check validity of a FuncTempInfo_t.
virtual void SetRcName(const char *name)
ETupleOrdering
Check in what order the member of a tuple are layout.
virtual DeclId_t GetDataMemberAtAddr(const void *addr) const
Return pointer to cling DeclId for a data member with a given name.
TObject * GetObjectAddress(const char *Name, void *&LookupCtx)
If the interpreter encounters Name, check whether that is an object ROOT could retrieve.
virtual Long_t ClassInfo_Tagnum(ClassInfo_t *info) const
virtual int DataMemberInfo_ArrayDim(DataMemberInfo_t *dminfo) const
A collection of TDataMember objects designed for fast access given a DeclId_t and for keep track of T...
The TEnum class implements the enum type.
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)
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 * MethodInfo_InterfaceMethod(MethodInfo_t *minfo) const
const char * TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Return the normalized name of the type (i.e.
virtual const char * ClassInfo_FullName(ClassInfo_t *info) const
int Size() const
Return the size in bytes of the underlying type of the current typedef.
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 void Info(const char *method, const char *msgfmt,...) const
Issue info message.
virtual TVirtualMutex * Factory(Bool_t=kFALSE)=0
virtual const char * BaseClassInfo_FullName(BaseClassInfo_t *bcinfo) 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...
bool LoadPCM(TString pcmFileName, const char **headers, void(*triggerFunc)()) const
Tries to load a PCM; returns true on success.
virtual void LoadEnums(TListOfEnums &cl) const
Create list of pointers to enums for TClass cl.
void TCling__UpdateListsOnCommitted(const cling::Transaction &T, cling::Interpreter *)
virtual std::string MethodInfo_TypeNormalizedName(MethodInfo_t *minfo) const
virtual void PostLoadCheck()
Do the initialization that can only be done after the CINT dictionary has been fully populated and ca...
DeclId_t GetDeclId(const llvm::GlobalValue *gv) const
Return pointer to cling DeclId for a global value.
virtual Long_t DataMemberInfo_Offset(DataMemberInfo_t *dminfo) const
const char * GetDeclFileName() const
virtual Double_t CallFunc_ExecDouble(CallFunc_t *func, void *address) const
virtual void CallFunc_ResetArg(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 Long_t MethodInfo_ExtraProperty(MethodInfo_t *minfo) const
virtual const char * WorkingDirectory()
Return working directory.
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
virtual void StackTrace()
Print a stack trace.
std::map< SpecialObjectLookupCtx_t, SpecialObjectMap_t > fSpecialObjectMaps
virtual int UnloadFile(const char *path) const
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 RegisterLoadedSharedLibrary(const char *name)
Register a new shared library name with the interpreter; add it to fSharedLibs.
Collectable string class.
clang::QualType GetQualType() const
static void AddClassToDeclIdMap(TDictionary::DeclId_t id, TClass *cl)
static: Add a TClass* to the map of classes.
R__EXTERN TClassTable * gClassTable
void UpdateListsOnCommitted(const cling::Transaction &T)
TDictionary::DeclId_t DeclId_t
const char * TmpltName() const
RooArgList L(const RooAbsArg &v1)
void * llvmLazyFunctionCreator(const std::string &mangled_name)
Autoload a library provided the mangled name of a missing symbol.
Dictionary for function template This class describes one single function template.
const clang::Decl * GetDecl() const
const char * TypeName() const
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)]...
double ExecDouble(void *address)
void Init(const char *name)
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.
static TProtoClass * GetProtoNorm(const char *cname)
Given the class normalized name returns the TClassProto object for the class.
virtual void ClassInfo_Init(ClassInfo_t *info, const char *funcname) const
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
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...
virtual DataMemberInfo_t * DataMemberInfo_Factory(ClassInfo_t *clinfo=0) const
const char * Name() const
TList * GetListOfEnums(Bool_t load=kTRUE)
Return a list containing the TEnums of a class.
virtual bool ClassInfo_HasDefaultConstructor(ClassInfo_t *info) const
void Init(const char *name)
Lookup named typedef and reset the iterator to point to it.
std::atomic< TListOfEnums * > fEnums
llvm::StringRef ValidArrayIndex() const
virtual const char * MethodArgInfo_DefaultValue(MethodArgInfo_t *marginfo) 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.
TClingMethodInfo GetMethod(const char *fname) const
Bool_t TestBit(UInt_t f) const
void SetFunc(const TClingClassInfo *info, const char *method, const char *arglist, long *poffset)
void SetArgArray(long *argArr, int narg)
cling::MetaProcessor * fMetaProcessor
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
const char * Name() const
Get the name of the current typedef.
Persistent version of a TClass.
Emulation of the CINT DataMemberInfo class.
virtual UInt_t FuncTempInfo_TemplateMinReqArgs(FuncTempInfo_t *) const
Return the number of required template arguments of the function template described by ft_info...
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.)
void CreateListOfBaseClasses(TClass *cl) const
Create list of pointers to base class(es) for TClass cl.
TClass * GenerateTClass(const char *classname, Bool_t emulation, Bool_t silent=kFALSE)
Generate a TClass for the given class.
void UpdateListOfGlobals()
No op: see TClingCallbacks (used to update the list of globals)
virtual MethodInfo_t * MethodInfo_FactoryCopy(MethodInfo_t *minfo) const
virtual Int_t GetEntries() const
void UpdateListOfGlobalFunctions()
No op: see TClingCallbacks (used to update the list of global functions)
virtual int SetClassAutoloading(int) const
Enable/Disable the Autoloading of libraries.
Emulation of the CINT MethodInfo class.
ptrdiff_t GetBaseOffset(TClingClassInfo *toBase, void *address, bool isDerivedObject)
void SaveContext()
Save the current Cling state.
virtual const char * MethodInfo_Name(MethodInfo_t *minfo) const
cling::Interpreter * fInterpreter
virtual bool ClassInfo_IsValid(ClassInfo_t *info) const
virtual const char * HomeDirectory(const char *userName=0)
Return the user's home directory.
static void RemoveClassDeclId(TDictionary::DeclId_t id)
const char * GetClassSharedLibs(const char *cls)
Get the list of shared libraries containing the code for class cls.
virtual FuncTempInfo_t * FuncTempInfo_Factory(DeclId_t declid) const
Construct a FuncTempInfo_t.
void TCling__DEBUG__dump(clang::DeclContext *DC)
const char * DefaultValue() const
long ClassProperty() 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_t IsErrorMessagesEnabled() const
If error messages are disabled, the interpreter should suppress its failures and warning messages fro...
bool HasDefaultConstructor() const
TFunction * Find(DeclId_t id) const
Return the TMethod or TFunction describing the function corresponding to the Decl 'id'...
virtual Bool_t IsTreatingNonAccessibleTypes()
virtual int TypedefInfo_Next(TypedefInfo_t *tinfo) const
virtual const char * MapCppName(const char *) const
Interface to cling function.
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.
virtual Long_t ClassInfo_Property(ClassInfo_t *info) const
void * InterfaceMethod(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
The TEnv class reads config files, by default named .rootrc.
std::string InsertStd(const char *tname)
clang::DeclContext * TCling__DEBUG__getDeclContext(clang::Decl *D)
virtual int MethodInfo_NDefaultArg(MethodInfo_t *minfo) const
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
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 *)
const char * GetValue() const
virtual const char * MethodArgInfo_TypeName(MethodArgInfo_t *marginfo) const
virtual TApplicationImp * GetApplicationImp()
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
virtual void CallFunc_SetArgArray(CallFunc_t *func, Long_t *paramArr, Int_t nparam) const
std::vector< std::pair< std::string, int > > FwdDeclArgsToKeepCollection_t
virtual Long_t TypeInfo_Property(TypeInfo_t *tinfo) const
void * fPrevLoadedDynLibInfo
virtual void GenericError(const char *error) const
Let the interpreter issue a generic error, and set its error state.
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual const char * ClassInfo_Title(ClassInfo_t *info) const
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.
virtual void TypeInfo_Delete(TypeInfo_t *tinfo) const
Each ROOT method (see TMethod) has a linked list of its arguments.
virtual void SetTempLevel(int val) const
Create / close a scope for temporaries.
const char * TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Get the name of the underlying type of the current typedef.
virtual bool ClassInfo_HasMethod(ClassInfo_t *info, const char *name) const
Int_t DeleteVariable(const char *name)
Undeclare obj called name.
virtual int SetClassAutoparsing(int)
Enable/Disable the Autoparsing of headers.
virtual ClassInfo_t * ClassInfo_Factory(Bool_t all=kTRUE) const
virtual bool DataMemberInfo_IsValid(DataMemberInfo_t *dminfo) const
void SetAutoParsingSuspended(bool val=true)
R__EXTERN TApplication * gApplication
Abstract base class for accessing the data-members of a class.
TObject * At(Int_t idx) const
Bool_t IsLoaded(const char *filename) const
Return true if the file has already been loaded by cint.
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 void MethodInfo_CreateSignature(MethodInfo_t *minfo, TString &signature) const
virtual ~TCling()
Destroy the interpreter interface.
virtual void FuncTempInfo_Delete(FuncTempInfo_t *) const
Delete the FuncTempInfo_t.
TObject * FindObject(const char *name) const
Find object using its name.
std::string GetMangledName() const
const char * GetFullTypeName() const
Get full type description of method argument, e.g.: "class TDirectory*".
virtual const char * TypeInfo_TrueName(TypeInfo_t *tinfo) const
virtual bool Update(FuncTempInfo_t *info)
Update the TFunctionTemplate to reflect the new info.
void Delete(void *arena, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
const TSeqCollection * GetConstants() const
Emulation of the CINT CallFunc class.
virtual BaseClassInfo_t * BaseClassInfo_Factory(ClassInfo_t *info) const
const char * TypeTrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
RAII used to store Parser, Sema, Preprocessor state for recursive parsing.
Bool_t R_ISREG(Int_t mode)
DeclId_t GetDeclId() const
virtual const char * TypedefInfo_TrueName(TypedefInfo_t *tinfo) const
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 const char * TypedefInfo_Title(TypedefInfo_t *tinfo) const
virtual void BaseClassInfo_Delete(BaseClassInfo_t *bcinfo) 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.
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...
const char * GetSharedLibDeps(const char *lib)
Get the list a libraries on which the specified lib depends.
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'...
static const char * GetMacroPath()
Get macro search path. Static utility function.
virtual bool ClassInfo_IsLoaded(ClassInfo_t *info) const
virtual TypeInfo_t * MethodInfo_Type(MethodInfo_t *minfo) const
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.
virtual Long_t BaseClassInfo_Property(BaseClassInfo_t *bcinfo) const
std::set< size_t > fPayloads
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 const char * DataMemberInfo_Title(DataMemberInfo_t *dminfo) 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 void SetAllocunlockfunc(void(*)()) const
[Place holder for Mutex Unlock] Provide the interpreter with a way to release a lock used to protect ...
virtual int TypeInfo_Size(TypeInfo_t *tinfo) const
virtual int DataMemberInfo_TypeSize(DataMemberInfo_t *dminfo) const
virtual TypedefInfo_t * TypedefInfo_FactoryCopy(TypedefInfo_t *tinfo) const
virtual Long64_t CallFunc_ExecInt64(CallFunc_t *func, void *address) const
void TCling__DEBUG__decl_dump(void *D)
Int_t UnloadLibraryMap(const char *library)
Unload library map entries coming from the specified library.
void ExecuteWithArgsAndReturn(TMethod *method, void *address, const void *args[]=0, int nargs=0, void *ret=0) const
virtual void SetErrmsgcallback(void *p) const
Set a callback to receive error messages.
void ClearStack()
Delete existing temporary values.
virtual Long_t DataMemberInfo_Property(DataMemberInfo_t *dminfo) const
long Property() const
Return a bit mask of metadata about the current typedef.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
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.
virtual bool MethodArgInfo_IsValid(MethodArgInfo_t *marginfo) 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...
virtual MethodArgInfo_t * MethodArgInfo_FactoryCopy(MethodArgInfo_t *marginfo) const
THashTable implements a hash table to store TObject's.
const char * TCling__GetClassSharedLibs(const char *className)
clang::NamespaceDecl * TCling__DEBUG__DCtoNamespace(clang::DeclContext *DC)
virtual TEnum * CreateEnum(void *VD, TClass *cl) const
virtual bool TypeInfo_IsValid(TypeInfo_t *tinfo) const
virtual const char * DataMemberInfo_TypeName(DataMemberInfo_t *dminfo) const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
bool IsBase(const char *name) 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
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 void MethodArgInfo_Delete(MethodArgInfo_t *marginfo) const
virtual Long_t MethodArgInfo_Property(MethodArgInfo_t *marginfo) const
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.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
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 SetObjectValidity(EObjectPointerState val)
virtual void TypedefInfo_Init(TypedefInfo_t *tinfo, const char *name) const
virtual DataMemberInfo_t * DataMemberInfo_FactoryCopy(DataMemberInfo_t *dminfo) const
void SetArgs(const char *args)
virtual Long_t MethodInfo_Property(MethodInfo_t *minfo) const
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...
int MaxIndex(int dim) const
virtual ClassInfo_t * BaseClassInfo_ClassInfo(BaseClassInfo_t *) const
void CreateSignature(TString &signature) 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...
TClass * GetClass() const
void Init(TClassEdit::TInterpreterLookupHelper *helper)
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.
virtual const char * GetDynamicPath()
Return the dynamic path (used to find shared libraries).
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
const char * TypeName() const
virtual Bool_t Declare(const char *code)=0
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 * Getenv(const char *env)
Get environment variable.
virtual Long_t BaseClassInfo_Tagnum(BaseClassInfo_t *bcinfo) const
virtual Long_t TypedefInfo_Property(TypedefInfo_t *tinfo) const
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.
ULong64_t fTransactionCount
ClassInfo_t * GetClassInfo() const
TClass * GetClass() const
char * DemangleTypeIdName(const std::type_info &ti, int &errorCode)
Demangle in a portable way the type id name.
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 DisplayClass(FILE *fout, const char *name, int base, int start) const
void UpdateListOfMethods(TClass *cl) const
Update the list of pointers to method for TClass cl This is now a nop.
Long_t ProcessLine(const char *line, EErrorCode *error=0)
virtual bool Update(DataMemberInfo_t *info)
Update the TFunction to reflect the new info.
virtual int DataMemberInfo_MaxIndex(DataMemberInfo_t *dminfo, Int_t dim) const
Emulation of the CINT TypeInfo class.
bool IsStdArray(std::string_view name)
cling::Interpreter * GetInterpreter()
Book space in a file, create I/O buffers, to fill them, (un)compress them.
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.
TClass *(* DictFuncPtr_t)()
bool HasMethod(const char *name) const
virtual const char * DataMemberInfo_Name(DataMemberInfo_t *dminfo) const
virtual int GetSecurityError() const
Interface to cling function.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
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> (...
virtual Long_t CallFunc_ExecInt(CallFunc_t *func, void *address) const
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.
long ExtraProperty() const
const clang::FunctionDecl * GetMethodDecl() const
static void TCling__UpdateClassInfo(const NamedDecl *TD)
Update TClingClassInfo for a class (e.g. upon seeing a definition).
const char * GetPrototype(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
void TCling__DEBUG__printName(clang::Decl *D)
EComplexType GetComplexType(const char *)
virtual const char * TypedefInfo_Name(TypedefInfo_t *tinfo) const
virtual void CallFunc_SetArg(CallFunc_t *func, Long_t param) const
TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
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 DeclId_t GetDataMemberWithValue(const void *ptrvalue) const
NOT IMPLEMENTED.
virtual Bool_t IsCmdThread()
const char * Name() const
void PrintIntro()
No-op; see TRint instead.
const clang::ValueDecl * GetDataMember(const char *name) const
virtual const char * DataMemberInfo_TypeTrueName(DataMemberInfo_t *dminfo) const
R__EXTERN TVirtualMutex * gGlobalMutex
virtual bool ClassInfo_IsBase(ClassInfo_t *info, const char *name) const
virtual TypedefInfo_t * TypedefInfo_Factory() const
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 TObject * FindObject(const TObject *obj) const
Find object using its hash value (returned by its Hash() member).
const char * TmpltName() const
RooArgSet S(const RooAbsArg &v1)
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 Bool_t LoadText(const char *text) const
Load the declarations from text into the interpreter.
void Init(const char *name)
virtual int BaseClassInfo_Next(BaseClassInfo_t *bcinfo) const
bool TCling__TEST_isInvalidDecl(clang::Decl *D)
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...
void TCling__SplitAclicMode(const char *fileName, string &mode, string &args, string &io, string &fname)
std::vector< std::string > fElements
void DeleteArray(void *arena, bool dtorOnly, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Emulation of the CINT BaseClassInfo class.
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
virtual bool MethodInfo_IsValid(MethodInfo_t *minfo) const
virtual TypeInfo_t * TypeInfo_FactoryCopy(TypeInfo_t *) const
TClingMethodInfo * FactoryMethod() const
R__EXTERN TSystem * gSystem
if object ctor succeeded but object should not be used
virtual const char * MethodInfo_GetPrototype(MethodInfo_t *minfo) const
virtual const char * GetTopLevelMacroName() const
Return the file name of the current un-included interpreted file.
int GetMethodNArg(const char *method, const char *proto, Bool_t objectIsConst, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
virtual MethodArgInfo_t * MethodArgInfo_Factory() 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)
std::set< TClass * > & GetModTClasses()
THashList * GetTable() const
virtual void CallFunc_SetFunc(CallFunc_t *func, ClassInfo_t *info, const char *method, const char *params, Long_t *Offset) const
virtual CallFunc_t * CallFunc_FactoryCopy(CallFunc_t *func) const
virtual const char * BaseClassInfo_TmpltName(BaseClassInfo_t *bcinfo) const
const char * TypeName() const
virtual Long_t ClassInfo_ClassProperty(ClassInfo_t *info) const
static void UpdateAllCanvases()
Update all canvases at end the terminal input command.
virtual const char * MethodInfo_GetMangledName(MethodInfo_t *minfo) const
virtual void * FindSym(const char *entry) const
Interface to cling function.
const char * GetName() const
Returns name of object.
virtual int MethodInfo_NArg(MethodInfo_t *minfo) 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.
virtual const char * GetSTLIncludePath() const
Return the directory containing CINT's stl cintdlls.
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)
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.
TDictionary::DeclId_t GetDeclId() const
TDictionary::DeclId_t GetDeclId() const
virtual Bool_t IsValid()
Return true if this global object is pointing to a currently loaded global.
virtual Long_t BaseClassInfo_Offset(BaseClassInfo_t *toBaseClassInfo, void *address, bool isDerivedObject) const
Int_t GetEntriesFast() const
std::string NormalizedName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Return the normalized name of the type (i.e.
void UpdateListOfLoadedSharedLibraries()
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
char * Form(const char *fmt,...)
Int_t Size() const
Return size of object of this class.
virtual Long_t ClassInfo_GetBaseOffset(ClassInfo_t *fromDerived, ClassInfo_t *toBase, void *address, bool isDerivedObject) 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.
The TEnumConstant class implements the constants of the enum type.
virtual MethodInfo_t * MethodInfo_Factory() const
The ROOT global object gROOT contains a list of all defined classes.
virtual Long_t FuncTempInfo_Property(FuncTempInfo_t *) const
Return the property of the function template.
void TCling__PrintStackTrace()
Print a StackTrace!
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Global variables class (global variables are obtained from CINT).
void * LazyFunctionCreatorAutoload(const std::string &mangled_name)
Autoload a library based on a missing symbol.
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)
virtual const char * ClassInfo_TmpltName(ClassInfo_t *info) const
virtual const char * Getp2f2funcname(void *receiver) const
Long_t Property() const
Set TObject::fBits and fStreamerType to cache information about the class.
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
virtual void FreeDirectory(void *dirp)
Free a directory.
TObject * TCling__GetObjectAddress(const char *Name, void *&LookupCtx)
virtual int ClassInfo_Size(ClassInfo_t *info) const
virtual bool TypedefInfo_IsValid(TypedefInfo_t *tinfo) const
Each class (see TClass) has a linked list of its base class(es).
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)
virtual void UpdateEnumConstants(TEnum *enumObj, TClass *cl) 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...
bool IsAutoloadingEnabled()
TDictionary::DeclId_t DeclId_t
virtual Long_t GetExecByteCode() const
This routines used to return the address of the internal wrapper function (of the interpreter) that w...
#define R__LOCKGUARD2(mutex)
virtual int LoadFile(const char *path) const
Load a source file or library called path into the interpreter.
std::unordered_set< const clang::NamespaceDecl * > fNSFromRootmaps
void TCling__GetNormalizedContext(const ROOT::TMetaUtils::TNormalizedCtxt *&normCtxt)
void UpdateListOfDataMembers(TClass *cl) const
Update the list of pointers to data members for TClass cl This is now a nop.
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.
virtual int MethodArgInfo_Next(MethodArgInfo_t *marginfo) const
void SetClassInfo(TClass *cl, Bool_t reload=kFALSE)
Set pointer to the TClingClassInfo in TClass.
virtual void FuncTempInfo_Title(FuncTempInfo_t *, TString &name) const
Return the comments associates with this function template.
Emulation of the CINT TypedefInfo class.
void * New(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
virtual void LoadFunctionTemplates(TClass *cl) const
Create list of pointers to function templates for TClass cl.
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
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.
Version_t GetClassVersion() const
int(* AutoLoadCallBack_t)(const char *)
virtual const char * GetIncludePath()
Get the list of include path.
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 CreateListOfDataMembers(TClass *cl) const
Create list of pointers to data members for TClass cl.
void UpdateListsOnUnloaded(const cling::Transaction &T)
virtual const char * DataMemberInfo_ValidArrayIndex(DataMemberInfo_t *dminfo) const
TObjArray * fStreamerInfo
void CreateListOfMethods(TClass *cl) const
Create list of pointers to methods for TClass cl.
virtual const char * BaseClassInfo_Name(BaseClassInfo_t *bcinfo) const
std::set< size_t > fLookedUpClasses
virtual void TypedefInfo_Delete(TypedefInfo_t *tinfo) const
bool IsValidMethod(const char *method, const char *proto, Bool_t objectIsConst, long *offset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) const
TClingClassInfo * GetBase() 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.
virtual void SetRTLD_NOW() const
bool IsValid() const
Return true if the current iterator position is valid.
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
virtual int MethodInfo_Next(MethodInfo_t *minfo) const
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
void Unload()
Mark 'all func' as being unloaded.
virtual int ClassInfo_GetMethodNArg(ClassInfo_t *info, const char *method, const char *proto, Bool_t objectIsConst=false, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) 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)
TDictionary::DeclId_t DeclId_t
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
Print a TSeq at the prompt:
virtual CallFuncIFacePtr_t CallFunc_IFacePtr(CallFunc_t *func) const
DeclId_t GetFunctionTemplate(ClassInfo_t *cl, const char *funcname)
Return pointer to cling interface function for a method of a class with a certain name...
const char * GetParent() const
void Reset()
Pressing Ctrl+C should forward here.
Int_t LoadLibraryMap(const char *rootmapfile=0)
Load map between class and library.
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
virtual void CallFunc_SetArgs(CallFunc_t *func, const char *param) const
TClingCallbacks * fClingCallbacks
Int_t AutoLoad(const char *classname, Bool_t knowDictNotLoaded=kFALSE)
Load library containing the specified class.
EObjectPointerState GetObjectValidity() const
Emulation of the CINT ClassInfo class.
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
#define R__LOCKGUARD(mutex)
void InspectMember(const T &obj, const char *name, Bool_t isTransient)
virtual void Add(TObject *obj)=0
void SetGetline(const char *(*getlineFunc)(const char *prompt), void(*histaddFunc)(const char *line))
Set a getline function to call when input is needed.
virtual void CallFunc_IgnoreExtraArgs(CallFunc_t *func, bool ignore) const
virtual EReturnType MethodCallReturnType(TFunction *func) 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.
ptrdiff_t Offset(void *address=0, bool isDerivedObject=true) const
virtual bool ClassInfo_IsEnum(const char *name) 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...
void GetFunctionOverloads(ClassInfo_t *cl, const char *funcname, std::vector< DeclId_t > &res) const
Insert overloads of name in cl to res.
static TClass * LoadClass(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
Bool_t IsPersistent() const
void HandleNewDecl(const void *DV, bool isDeserialized, std::set< TClass *> &modifiedClasses)
void RecursiveRemove(TObject *obj)
Delete object from cling symbol table so it can not be used anymore.
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 bool DiagnoseIfInterpreterException(const std::exception &e) const
Mother of all ROOT objects.
void TCling__LibraryUnloadedRTTI(const void *dyLibHandle, const char *canonicalName)
void RegisterTemporary(const TInterpreterValue &value)
virtual FuncTempInfo_t * FuncTempInfo_FactoryCopy(FuncTempInfo_t *) const
Construct a FuncTempInfo_t.
Global functions class (global functions are obtained from CINT).
virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr)
virtual const char * GetCurrentMacroName() const
Return the file name of the currently interpreted file, included or not.
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 (...
virtual const char * MethodArgInfo_Name(MethodArgInfo_t *marginfo) const
TClassRef is used to implement a permanent reference to a TClass object.
virtual const char * GetTitle() const
Returns title of object.
typedef void((*Func_t)())
void Unload()
Mark 'all func' as being unloaded.
const char * GetFullTypeName() const
Get full type description of typedef, e,g.: "class TDirectory*".
const char * GetDefault() const
Get default value of method argument.
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
void SetAutoloadingEnabled(bool val=true)
virtual int DataMemberInfo_Next(DataMemberInfo_t *dminfo) const
Bridge between cling::Value and ROOT.
virtual void TypeInfo_Init(TypeInfo_t *tinfo, const char *funcname) const
void AddFriendToClass(clang::FunctionDecl *, clang::CXXRecordDecl *) const
Inject function as a friend into klass.
virtual bool ClassInfo_IsValidMethod(ClassInfo_t *info, const char *method, const char *proto, Long_t *offset, ROOT::EFunctionMatchMode=ROOT::kConversionMatch) const
const char * GetUnqualifiedName(const char *name)
Return the start of the unqualified name include in 'original'.
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)
virtual void ClassInfo_DeleteArray(ClassInfo_t *info, void *arena, bool dtorOnly) const
virtual const char * MethodInfo_Title(MethodInfo_t *minfo) const
virtual std::string MethodArgInfo_TypeNormalizedName(MethodArgInfo_t *marginfo) const
R__EXTERN const char * gRootDir
Bool_t fHeaderParsingOnDemand
virtual int ClassInfo_Next(ClassInfo_t *info) const
virtual void CallFunc_Init(CallFunc_t *func) const
virtual void * ClassInfo_New(ClassInfo_t *info) const
const char * Name() 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 Long_t DataMemberInfo_TypeProperty(DataMemberInfo_t *dminfo) const
virtual void CallFunc_ExecWithArgsAndReturn(CallFunc_t *func, void *address, const void *args[]=0, int nargs=0, void *ret=0) const
static void * fgSetOfSpecials
virtual int GetProcInfo(ProcInfo_t *info) const
Returns cpu and memory used by this process into the ProcInfo_t structure.
TDictionary * Find(DeclId_t id) const
Return (after creating it if necessary) the TDataMember describing the data member corresponding to t...
virtual EReturnType MethodInfo_MethodCallReturnType(MethodInfo_t *minfo) const
void Destruct(void *arena, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
const char * Name() const
static void SetFactory(TVirtualStreamerInfo *factory)
static function: Set the StreamerInfo factory
long ExecInt(void *address)
virtual Long_t Getgvp() const
Interface to the CINT global object pointer which was controlling the behavior of the wrapper around ...
virtual void SetRTLD_LAZY() const
Int_t SetClassSharedLibs(const char *cls, const char *libs)
Register the autoloading information for a class.
Int_t GetEntries() const
Return the number of objects in array (i.e.
virtual UInt_t FuncTempInfo_TemplateNargs(FuncTempInfo_t *) const
Return the maximum number of template arguments of the function template described by ft_info...
virtual void GetFunctionName(const clang::FunctionDecl *decl, std::string &name) const
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
virtual void MethodInfo_Delete(MethodInfo_t *minfo) const
Interface to cling function.
TClingTypeInfo * Type() const
Bool_t SetSuspendAutoParsing(Bool_t value)
Suspend the Autoparsing of headers.
virtual void CallFunc_Exec(CallFunc_t *func, void *address) const
virtual int Evaluate(const char *, TInterpreterValue &)
Get the interpreter value corresponding to the statement.
virtual void ClassInfo_Destruct(ClassInfo_t *info, void *arena) const
static bool R__InitStreamerInfoFactory()
Helper to initialize TVirtualStreamerInfo's factor early.
virtual void CallFunc_Delete(CallFunc_t *func) const
void IgnoreExtraArgs(bool ignore)
virtual int TypedefInfo_Size(TypedefInfo_t *tinfo) const
Bool_t fIsAutoParsingSuspended
TDataMember * GetDataMember(const char *datamember) const
Return pointer to datamember object with name "datamember".
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.
virtual void SetAlloclockfunc(void(*)()) const
[Place holder for Mutex Lock] Provide the interpreter with a way to acquire a lock used to protect cr...
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.
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
std::hash< std::string > fStringHashFunction
virtual const char * ClassInfo_Name(ClassInfo_t *info) const
const char * GetSharedLibs()
Return the list of shared libraries loaded into the process.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
static const char * FindLibraryName(void(*func)())
Wrapper around dladdr (and friends)
R__EXTERN TInterpreter * gCling
R__DLLEXPORT TInterpreter * CreateInterpreter(void *interpLibHandle)
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.
virtual bool CallFunc_IsValid(CallFunc_t *func) const
Long_t ProcessLineAsynch(const char *line, EErrorCode *error=0)
Let cling process a command line asynch.
virtual DeclId_t GetEnum(TClass *cl, const char *name) const
Return pointer to cling Decl of global/static variable that is located at the address given by addr...
void TCling__TransactionRollback(const cling::Transaction &T)
virtual void FuncTempInfo_Name(FuncTempInfo_t *, TString &name) const
Return the name of this function template.
virtual const char * MethodInfo_TypeName(MethodInfo_t *minfo) const
const char * Name() const
TList * GetListOfMethods(Bool_t load=kTRUE)
Return list containing the TMethods of a class.
virtual int DisplayIncludePath(FILE *fout) const
Interface to cling function.
virtual const char * ClassInfo_FileName(ClassInfo_t *info) const
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.
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 MethodInfo_t * CallFunc_FactoryMethod(CallFunc_t *func) const
static char * skip(char **buf, const char *delimiters)
void LibraryUnloaded(const void *dyLibHandle, const char *canonicalName)
const char * Name(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
void RewindDictionary()
Rewind Cling dictionary to the point where it was before executing the current macro.
virtual CallFunc_t * CallFunc_Factory() const
void AddIncludePath(const char *path)
Add the given path to the list of directories in which the interpreter looks for include files...
Int_t DeleteGlobal(void *obj)
Delete obj from Cling symbol table so it cannot be accessed anymore.
TEnum * Find(DeclId_t id) const
Return the TEnum corresponding to the Decl 'id' or NULL if it does not exist.
void ResetGlobals()
Reset in Cling the list of global variables to the state saved by the last call to TCling::SaveGlobal...
virtual int TypeInfo_RefType(TypeInfo_t *) const
virtual void CallFunc_ExecWithReturn(CallFunc_t *func, void *address, void *ret) const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
void ExecWithArgsAndReturn(void *address, const void *args[]=0, int nargs=0, void *ret=0)
if(line.BeginsWith("/*"))
const clang::Type * GetType() const
void CreateListOfMethodArgs(TFunction *m) const
Create list of pointers to method arguments for TMethod m.
virtual void Setgvp(Long_t) const
Interface to the cling global object pointer which was controlling the behavior of the wrapper around...
void ExecWithReturn(void *address, void *ret=0)
virtual void ClassInfo_Delete(ClassInfo_t *info) const
long TypeProperty() 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 void DataMemberInfo_Delete(DataMemberInfo_t *dminfo) const
TList * GetListOfFunctionTemplates(Bool_t load=kTRUE)
Return list containing the TEnums of a class.
virtual const char * GetClassSharedLibs(const char *cls)=0
TClingMethodInfo GetMethodWithArgs(const char *fname, const char *arglist, long *poffset, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch, EInheritanceMode imode=kWithInheritance) const
long long ExecInt64(void *address)