Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TClingCallbacks.cxx
Go to the documentation of this file.
1// @(#)root/core/meta:$Id$
2// Author: Vassil Vassilev 7/10/2012
3
4/*************************************************************************
5 * Copyright (C) 1995-2012, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TClingCallbacks.h"
13
15
16#include "cling/Interpreter/DynamicLibraryManager.h"
17#include "cling/Interpreter/Interpreter.h"
18#include "cling/Interpreter/InterpreterCallbacks.h"
19#include "cling/Interpreter/Transaction.h"
20#include "cling/Utils/AST.h"
21
22#include "clang/AST/ASTConsumer.h"
23#include "clang/AST/ASTContext.h"
24#include "clang/AST/DeclBase.h"
25#include "clang/AST/DeclTemplate.h"
26#include "clang/AST/GlobalDecl.h"
27#include "clang/Frontend/CompilerInstance.h"
28#include "clang/Lex/HeaderSearch.h"
29#include "clang/Lex/PPCallbacks.h"
30#include "clang/Lex/Preprocessor.h"
31#include "clang/Parse/Parser.h"
32#include "clang/Sema/Lookup.h"
33#include "clang/Sema/Scope.h"
34#include "clang/Serialization/ASTReader.h"
35#include "clang/Serialization/GlobalModuleIndex.h"
36
37#include "llvm/ExecutionEngine/Orc/Core.h"
38
39#include "llvm/Support/Error.h"
40#include "llvm/Support/FileSystem.h"
41#include "llvm/Support/Path.h"
42#include "llvm/Support/Process.h"
43
44#include "TClingUtils.h"
45#include "ClingRAII.h"
46
47using namespace clang;
48using namespace cling;
49using namespace ROOT::Internal;
50
52class TObject;
53
54// Functions used to forward calls from code compiled with no-rtti to code
55// compiled with rtti.
56extern "C" {
57 void TCling__UpdateListsOnCommitted(const cling::Transaction&, Interpreter*);
58 void TCling__UpdateListsOnUnloaded(const cling::Transaction&);
59 void TCling__InvalidateGlobal(const clang::Decl*);
60 void TCling__TransactionRollback(const cling::Transaction&);
62 TObject* TCling__GetObjectAddress(const char *Name, void *&LookupCtx);
64 int TCling__AutoLoadCallback(const char* className);
65 int TCling__AutoParseCallback(const char* className);
66 const char* TCling__GetClassSharedLibs(const char* className);
67 int TCling__IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl* name);
68 int TCling__CompileMacro(const char *fileName, const char *options);
69 void TCling__SplitAclicMode(const char* fileName, std::string &mode,
70 std::string &args, std::string &io, std::string &fname);
71 int TCling__LoadLibrary(const char *library);
72 bool TCling__LibraryLoadingFailed(const std::string&, const std::string&, bool, bool);
73 void TCling__LibraryLoadedRTTI(const void* dyLibHandle,
74 llvm::StringRef canonicalName);
75 void TCling__LibraryUnloadedRTTI(const void* dyLibHandle,
76 llvm::StringRef canonicalName);
79 void TCling__RestoreInterpreterMutex(void *state);
82}
83
85public:
86 AutoloadLibraryMU(const std::string &Library, const llvm::orc::SymbolNameVector &Symbols)
87 : MaterializationUnit(getSymbolFlagsMap(Symbols), nullptr), fLibrary(Library), fSymbols(Symbols)
88 {
89 }
90
91 StringRef getName() const override { return "<Symbols from Autoloaded Library>"; }
92
93 void materialize(std::unique_ptr<llvm::orc::MaterializationResponsibility> R) override
94 {
95 llvm::orc::SymbolMap loadedSymbols;
96 llvm::orc::SymbolNameSet failedSymbols;
97 bool loadedLibrary = false;
98
99 for (auto symbol : fSymbols) {
100 std::string symbolStr = (*symbol).str();
101 std::string nameForDlsym = ROOT::TMetaUtils::DemangleNameForDlsym(symbolStr);
102
103 // Check if the symbol is available without loading the library.
104 void *addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(nameForDlsym);
105
106 if (!addr && !loadedLibrary) {
107 // Try to load the library which should provide the symbol definition.
108 // TODO: Should this interface with the DynamicLibraryManager directly?
109 if (TCling__LoadLibrary(fLibrary.c_str()) < 0) {
110 ROOT::TMetaUtils::Error("AutoloadLibraryMU", "Failed to load library %s", fLibrary.c_str());
111 }
112
113 // Only try loading the library once.
114 loadedLibrary = true;
115
116 addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(nameForDlsym);
117 }
118
119 if (addr) {
120 loadedSymbols[symbol] =
121 llvm::JITEvaluatedSymbol(llvm::pointerToJITTargetAddress(addr), llvm::JITSymbolFlags::Exported);
122 } else {
123 // Collect all failing symbols, delegate their responsibility and then
124 // fail their materialization. R->defineNonExistent() sounds like it
125 // should do that, but it's not implemented?!
126 failedSymbols.insert(symbol);
127 }
128 }
129
130 if (!failedSymbols.empty()) {
131 auto failingMR = R->delegate(failedSymbols);
132 if (failingMR) {
133 (*failingMR)->failMaterialization();
134 }
135 }
136
137 if (!loadedSymbols.empty()) {
138 llvm::cantFail(R->notifyResolved(loadedSymbols));
139 llvm::cantFail(R->notifyEmitted());
140 }
141 }
142
143 void discard(const llvm::orc::JITDylib &JD, const llvm::orc::SymbolStringPtr &Name) override {}
144
145private:
146 static llvm::orc::SymbolFlagsMap getSymbolFlagsMap(const llvm::orc::SymbolNameVector &Symbols)
147 {
148 llvm::orc::SymbolFlagsMap map;
149 for (auto symbolName : Symbols)
150 map[symbolName] = llvm::JITSymbolFlags::Exported;
151 return map;
152 }
153
154 std::string fLibrary;
155 llvm::orc::SymbolNameVector fSymbols;
156};
157
159public:
160 AutoloadLibraryGenerator(cling::Interpreter *interp) : fInterpreter(interp) {}
161
162 llvm::Error tryToGenerate(llvm::orc::LookupState &LS, llvm::orc::LookupKind K, llvm::orc::JITDylib &JD,
163 llvm::orc::JITDylibLookupFlags JDLookupFlags,
164 const llvm::orc::SymbolLookupSet &Symbols) override
165 {
166 // If we get here, the symbols have not been found in the current process,
167 // so no need to check that again. Instead search for the library that
168 // provides the symbol and create one MaterializationUnit per library to
169 // actually load it if needed.
170 std::unordered_map<std::string, llvm::orc::SymbolNameVector> found;
171 llvm::orc::SymbolNameSet missing;
172
173 // TODO: Do we need to take gInterpreterMutex?
174 // R__LOCKGUARD(gInterpreterMutex);
175
176 for (auto &&KV : Symbols) {
177 llvm::orc::SymbolStringPtr name = KV.first;
178
179 const cling::DynamicLibraryManager &DLM = *fInterpreter->getDynamicLibraryManager();
180
181 std::string libName = DLM.searchLibrariesForSymbol((*name).str(),
182 /*searchSystem=*/true);
183
184 // libNew overrides memory management functions; must never autoload that.
185 assert(libName.find("/libNew.") == std::string::npos && "We must not autoload libNew!");
186
187 // libCling symbols are intentionally hidden from the process, and libCling must not be
188 // dlopened. Instead, symbols must be resolved by specifically querying the dynlib handle of
189 // libCling, which by definition is loaded - else we could not call this code. The handle
190 // is made available as argument to `CreateInterpreter`.
191 assert(libName.find("/libCling.") == std::string::npos && "Must not autoload libCling!");
192
193 if (libName.empty())
194 missing.insert(name);
195 else
196 found[libName].push_back(name);
197 }
198
199 for (auto &&KV : found) {
200 auto MU = std::make_unique<AutoloadLibraryMU>(KV.first, std::move(KV.second));
201 if (auto Err = JD.define(MU))
202 return Err;
203 }
204
205 if (!missing.empty())
206 return llvm::make_error<llvm::orc::SymbolsNotFound>(std::move(missing));
207
208 return llvm::Error::success();
209 }
210
211private:
212 cling::Interpreter *fInterpreter;
213};
214
215TClingCallbacks::TClingCallbacks(cling::Interpreter *interp, bool hasCodeGen) : InterpreterCallbacks(interp)
216{
217 if (hasCodeGen) {
218 Transaction* T = nullptr;
219 m_Interpreter->declare("namespace __ROOT_SpecialObjects{}", &T);
220 fROOTSpecialNamespace = dyn_cast<NamespaceDecl>(T->getFirstDecl().getSingleDecl());
221
222 interp->addGenerator(std::make_unique<AutoloadLibraryGenerator>(interp));
223 }
224}
225
226//pin the vtable here
228
229void TClingCallbacks::InclusionDirective(clang::SourceLocation sLoc/*HashLoc*/,
230 const clang::Token &/*IncludeTok*/,
231 llvm::StringRef FileName,
232 bool /*IsAngled*/,
233 clang::CharSourceRange /*FilenameRange*/,
234 const clang::FileEntry *FE,
235 llvm::StringRef /*SearchPath*/,
236 llvm::StringRef /*RelativePath*/,
237 const clang::Module * Imported,
238 clang::SrcMgr::CharacteristicKind FileType) {
239 // We found a module. Do not try to do anything else.
240 Sema &SemaR = m_Interpreter->getSema();
241 if (Imported) {
242 // FIXME: We should make the module visible at that point.
243 if (!SemaR.isModuleVisible(Imported))
244 ROOT::TMetaUtils::Info("TClingCallbacks::InclusionDirective",
245 "Module %s resolved but not visible!", Imported->Name.c_str());
246 else
247 return;
248 }
249
250 // Method called via Callbacks->InclusionDirective()
251 // in Preprocessor::HandleIncludeDirective(), invoked whenever an
252 // inclusion directive has been processed, and allowing us to try
253 // to autoload libraries using their header file name.
254 // Two strategies are tried:
255 // 1) The header name is looked for in the list of autoload keys
256 // 2) Heurists are applied to the header name to distill a classname.
257 // For example try to autoload TGClient (libGui) when seeing #include "TGClient.h"
258 // or TH1F in presence of TH1F.h.
259 // Strategy 2) is tried only if 1) fails.
260
261 bool isHeaderFile = FileName.endswith(".h") || FileName.endswith(".hxx") || FileName.endswith(".hpp");
262 if (!IsAutoLoadingEnabled() || fIsAutoLoadingRecursively || !isHeaderFile)
263 return;
264
265 std::string localString(FileName.str());
266
267 DeclarationName Name = &SemaR.getASTContext().Idents.get(localString.c_str());
268 LookupResult RHeader(SemaR, Name, sLoc, Sema::LookupOrdinaryName);
269
270 tryAutoParseInternal(localString, RHeader, SemaR.getCurScope(), FE);
271}
272
273// TCling__LibraryLoadingFailed is a function in TCling which handles errmessage
274bool TClingCallbacks::LibraryLoadingFailed(const std::string& errmessage, const std::string& libStem,
275 bool permanent, bool resolved) {
276 return TCling__LibraryLoadingFailed(errmessage, libStem, permanent, resolved);
277}
278
279// Preprocessor callbacks used to handle special cases like for example:
280// #include "myMacro.C+"
281//
282bool TClingCallbacks::FileNotFound(llvm::StringRef FileName,
283 llvm::SmallVectorImpl<char> &RecoveryPath) {
284 // Method called via Callbacks->FileNotFound(Filename, RecoveryPath)
285 // in Preprocessor::HandleIncludeDirective(), initially allowing to
286 // change the include path, and allowing us to compile code via ACLiC
287 // when specifying #include "myfile.C+", and suppressing the preprocessor
288 // error message:
289 // input_line_23:1:10: fatal error: 'myfile.C+' file not found
290
291 Preprocessor& PP = m_Interpreter->getCI()->getPreprocessor();
292
293 // remove any trailing "\n
294 std::string filename(FileName.str().substr(0,FileName.str().find_last_of('"')));
295 std::string fname, mode, arguments, io;
296 // extract the filename and ACliC mode
297 TCling__SplitAclicMode(filename.c_str(), mode, arguments, io, fname);
298 if (mode.length() > 0) {
299 if (llvm::sys::fs::exists(fname)) {
300 // format the CompileMacro() option string
301 std::string options = "k";
302 if (mode.find("++") != std::string::npos) options += "f";
303 if (mode.find("g") != std::string::npos) options += "g";
304 if (mode.find("O") != std::string::npos) options += "O";
305
306 // Save state of the preprocessor
307 Preprocessor::CleanupAndRestoreCacheRAII cleanupRAII(PP);
308 Parser& P = const_cast<Parser&>(m_Interpreter->getParser());
309 // We parsed 'include' token. Store it.
310 clang::Parser::ParserCurTokRestoreRAII fSavedCurToken(P);
311 // We provide our own way of handling the entire #include "file.c+"
312 // After we have saved the token reset the current one to
313 // something which is safe (semi colon usually means empty decl)
314 Token& Tok = const_cast<Token&>(P.getCurToken());
315 Tok.setKind(tok::semi);
316 // We can't PushDeclContext, because we go up and the routine that pops
317 // the DeclContext assumes that we drill down always.
318 // We have to be on the global context. At that point we are in a
319 // wrapper function so the parent context must be the global.
320 // This is needed to solve potential issues when using #include "myFile.C+"
321 // after a scope declaration like:
322 // void Check(TObject* obj) {
323 // if (obj) cout << "Found the referenced object\n";
324 // else cout << "Error: Could not find the referenced object\n";
325 // }
326 // #include "A.C+"
327 Sema& SemaR = m_Interpreter->getSema();
328 ASTContext& C = SemaR.getASTContext();
329 Sema::ContextAndScopeRAII pushedDCAndS(SemaR, C.getTranslationUnitDecl(),
330 SemaR.TUScope);
331 int retcode = TCling__CompileMacro(fname.c_str(), options.c_str());
332 if (retcode) {
333 // compilation was successful, let's remember the original
334 // preprocessor "include not found" error suppression flag
335 if (!fPPChanged)
336 fPPOldFlag = PP.GetSuppressIncludeNotFoundError();
337 PP.SetSuppressIncludeNotFoundError(true);
338 fPPChanged = true;
339 }
340 return false;
341 }
342 }
343 if (fPPChanged) {
344 // restore the original preprocessor "include not found" error
345 // suppression flag
346 PP.SetSuppressIncludeNotFoundError(fPPOldFlag);
347 fPPChanged = false;
348 }
349 return false;
350}
351
352
353static bool topmostDCIsFunction(Scope* S) {
354 if (!S)
355 return false;
356
357 DeclContext* DC = S->getEntity();
358 // For DeclContext-less scopes like if (dyn_expr) {}
359 // Find the DC enclosing S.
360 while (!DC) {
361 S = S->getParent();
362 DC = S->getEntity();
363 }
364
365 // DynamicLookup only happens inside topmost functions:
366 clang::DeclContext* MaybeTU = DC;
367 while (MaybeTU && !isa<TranslationUnitDecl>(MaybeTU)) {
368 DC = MaybeTU;
369 MaybeTU = MaybeTU->getParent();
370 }
371 return isa<FunctionDecl>(DC);
372}
373
374// On a failed lookup we have to try to more things before issuing an error.
375// The symbol might need to be loaded by ROOT's AutoLoading mechanism or
376// it might be a ROOT special object.
377//
378// Try those first and if still failing issue the diagnostics.
379//
380// returns true when a declaration is found and no error should be emitted.
381//
382bool TClingCallbacks::LookupObject(LookupResult &R, Scope *S) {
384 // init error or rootcling
385 return false;
386 }
387
388 // Don't do any extra work if an error that is not still recovered occurred.
389 if (m_Interpreter->getSema().getDiagnostics().hasErrorOccurred())
390 return false;
391
392 if (tryAutoParseInternal(R.getLookupName().getAsString(), R, S))
393 return true; // happiness.
394
395 // The remaining lookup routines only work on global scope functions
396 // ("macros"), not in classes, namespaces etc - anything that looks like
397 // it has seen any trace of software development.
398 if (!topmostDCIsFunction(S))
399 return false;
400
401 // If the autoload wasn't successful try ROOT specials.
403 return true;
404
405 // For backward-compatibility with CINT we must support stmts like:
406 // x = 4; y = new MyClass();
407 // I.e we should "inject" a C++11 auto keyword in front of "x" and "y"
408 // This has to have higher precedence than the dynamic scopes. It is claimed
409 // that if one assigns to a name and the lookup of that name fails if *must*
410 // auto keyword must be injected and the stmt evaluation must not be delayed
411 // until runtime.
412 // For now supported only at the prompt.
414 return true;
415 }
416
418 return false;
419
420 // Finally try to resolve this name as a dynamic name, i.e delay its
421 // resolution for runtime.
423}
424
425bool TClingCallbacks::findInGlobalModuleIndex(DeclarationName Name, bool loadFirstMatchOnly /*=true*/)
426{
427 llvm::Optional<std::string> envUseGMI = llvm::sys::Process::GetEnv("ROOT_USE_GMI");
428 if (envUseGMI.hasValue())
429 if (!envUseGMI->empty() && !ROOT::FoundationUtils::ConvertEnvValueToBool(*envUseGMI))
430 return false;
431
432 const CompilerInstance *CI = m_Interpreter->getCI();
433 const LangOptions &LangOpts = CI->getPreprocessor().getLangOpts();
434
435 if (!LangOpts.Modules)
436 return false;
437
438 // We are currently building a module, we should not import .
439 if (LangOpts.isCompilingModule())
440 return false;
441
442 if (fIsCodeGening)
443 return false;
444
445 // We are currently instantiating one (or more) templates. At that point,
446 // all Decls are present in the AST (with possibly deserialization pending),
447 // and we should not load more modules which could find an implicit template
448 // instantiation that is lazily loaded.
449 Sema &SemaR = m_Interpreter->getSema();
450 if (SemaR.InstantiatingSpecializations.size() > 0)
451 return false;
452
453 GlobalModuleIndex *Index = CI->getASTReader()->getGlobalIndex();
454 if (!Index)
455 return false;
456
457 // FIXME: We should load only the first available and rely on other callbacks
458 // such as RequireCompleteType and LookupUnqualified to load all.
459 GlobalModuleIndex::FileNameHitSet FoundModules;
460
461 // Find the modules that reference the identifier.
462 // Note that this only finds top-level modules.
463 if (Index->lookupIdentifier(Name.getAsString(), FoundModules)) {
464 for (llvm::StringRef FileName : FoundModules) {
465 StringRef ModuleName = llvm::sys::path::stem(FileName);
466
467 // Skip to the first not-yet-loaded module.
468 if (m_LoadedModuleFiles.count(FileName)) {
469 if (gDebug > 2)
470 llvm::errs() << "Module '" << ModuleName << "' already loaded"
471 << " for '" << Name.getAsString() << "'\n";
472 continue;
473 }
474
475 fIsLoadingModule = true;
476 if (gDebug > 2)
477 llvm::errs() << "Loading '" << ModuleName << "' on demand"
478 << " for '" << Name.getAsString() << "'\n";
479
480 m_Interpreter->loadModule(ModuleName.str());
481 fIsLoadingModule = false;
482 m_LoadedModuleFiles[FileName] = Name;
483 if (loadFirstMatchOnly)
484 break;
485 }
486 return true;
487 }
488 return false;
489}
490
491bool TClingCallbacks::LookupObject(const DeclContext* DC, DeclarationName Name) {
493 // init error or rootcling
494 return false;
495 }
496
498 return false;
499
501 return false;
502
503 if (Name.getNameKind() != DeclarationName::Identifier)
504 return false;
505
506 Sema &SemaR = m_Interpreter->getSema();
507 auto *D = cast<Decl>(DC);
508 SourceLocation Loc = D->getLocation();
509 if (Loc.isValid() && SemaR.getSourceManager().isInSystemHeader(Loc)) {
510 // This declaration comes from a system module, we do not want to try
511 // autoparsing it and find instantiations in our ROOT modules.
512 return false;
513 }
514
515 // Get the 'lookup' decl context.
516 // We need to cast away the constness because we will lookup items of this
517 // namespace/DeclContext
518 NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(const_cast<DeclContext*>(DC));
519
520 // When GMI is mixed with rootmaps, we might have a name for two different
521 // entities provided by the two systems. In that case check if the rootmaps
522 // registered the enclosing namespace as a rootmap name resolution namespace
523 // and only if that was not the case use the information in the GMI.
524 if (!NSD || !TCling__IsAutoLoadNamespaceCandidate(NSD)) {
525 // After loading modules, we must update the redeclaration chains.
526 return findInGlobalModuleIndex(Name, /*loadFirstMatchOnly*/ false) && D->getMostRecentDecl();
527 }
528
529 const DeclContext* primaryDC = NSD->getPrimaryContext();
530 if (primaryDC != DC)
531 return false;
532
533 LookupResult R(SemaR, Name, SourceLocation(), Sema::LookupOrdinaryName);
534 R.suppressDiagnostics();
535 // We need the qualified name for TCling to find the right library.
536 std::string qualName
537 = NSD->getQualifiedNameAsString() + "::" + Name.getAsString();
538
539
540 // We want to avoid qualified lookups, because they are expensive and
541 // difficult to construct. This is why we *artificially* push a scope and
542 // a decl context, where Sema should do the lookup.
543 clang::Scope S(SemaR.TUScope, clang::Scope::DeclScope, SemaR.getDiagnostics());
544 S.setEntity(const_cast<DeclContext*>(DC));
545 Sema::ContextAndScopeRAII pushedDCAndS(SemaR, const_cast<DeclContext*>(DC), &S);
546
547 if (tryAutoParseInternal(qualName, R, SemaR.getCurScope())) {
548 llvm::SmallVector<NamedDecl*, 4> lookupResults;
549 for(LookupResult::iterator I = R.begin(), E = R.end(); I < E; ++I)
550 lookupResults.push_back(*I);
551 UpdateWithNewDecls(DC, Name, llvm::makeArrayRef(lookupResults.data(),
552 lookupResults.size()));
553 return true;
554 }
555 return false;
556}
557
558bool TClingCallbacks::LookupObject(clang::TagDecl* Tag) {
560 // init error or rootcling
561 return false;
562 }
563
565 return false;
566
567 // Clang needs Tag's complete definition. Can we parse it?
569
570 // if (findInGlobalModuleIndex(Tag->getDeclName(), /*loadFirstMatchOnly*/false))
571 // return true;
572
573 Sema &SemaR = m_Interpreter->getSema();
574
575 SourceLocation Loc = Tag->getLocation();
576 if (SemaR.getSourceManager().isInSystemHeader(Loc)) {
577 // This declaration comes from a system module, we do not want to try
578 // autoparsing it and find instantiations in our ROOT modules.
579 return false;
580 }
581
582 for (auto ReRD: Tag->redecls()) {
583 // Don't autoparse a TagDecl while we are parsing its definition!
584 if (ReRD->isBeingDefined())
585 return false;
586 }
587
588
589 if (RecordDecl* RD = dyn_cast<RecordDecl>(Tag)) {
590 ASTContext& C = SemaR.getASTContext();
591 Parser& P = const_cast<Parser&>(m_Interpreter->getParser());
592
593 ParsingStateRAII raii(P,SemaR);
594
595 // Use the Normalized name for the autoload
596 std::string Name;
597 const ROOT::TMetaUtils::TNormalizedCtxt* tNormCtxt = nullptr;
600 C.getTypeDeclType(RD),
601 *m_Interpreter,
602 *tNormCtxt);
603 // Autoparse implies autoload
604 if (TCling__AutoParseCallback(Name.c_str())) {
605 // We have read it; remember that.
606 Tag->setHasExternalLexicalStorage(false);
607 return true;
608 }
609 }
610 return false;
611}
612
613
614// The symbol might be defined in the ROOT class AutoLoading map so we have to
615// try to autoload it first and do secondary lookup to try to find it.
616//
617// returns true when a declaration is found and no error should be emitted.
618// If FileEntry, this is a reacting on a #include and Name is the included
619// filename.
620//
621bool TClingCallbacks::tryAutoParseInternal(llvm::StringRef Name, LookupResult &R,
622 Scope *S, const FileEntry* FE /*=0*/) {
624 // init error or rootcling
625 return false;
626 }
627
628 Sema &SemaR = m_Interpreter->getSema();
629
630 // Try to autoload first if AutoLoading is enabled
631 if (IsAutoLoadingEnabled()) {
632 // Avoid tail chasing.
634 return false;
635
636 // We should try autoload only for special lookup failures.
637 Sema::LookupNameKind kind = R.getLookupKind();
638 if (!(kind == Sema::LookupTagName || kind == Sema::LookupOrdinaryName
639 || kind == Sema::LookupNestedNameSpecifierName
640 || kind == Sema::LookupNamespaceName))
641 return false;
642
644
645 bool lookupSuccess = false;
646 // Save state of the PP
647 Parser &P = const_cast<Parser &>(m_Interpreter->getParser());
648
649 ParsingStateRAII raii(P, SemaR);
650
651 // First see whether we have a fwd decl of this name.
652 // We shall only do that if lookup makes sense for it (!FE).
653 if (!FE) {
654 lookupSuccess = SemaR.LookupName(R, S);
655 if (lookupSuccess) {
656 if (R.isSingleResult()) {
657 if (isa<clang::RecordDecl>(R.getFoundDecl())) {
658 // Good enough; RequireCompleteType() will tell us if we
659 // need to auto parse.
660 // But we might need to auto-load.
661 TCling__AutoLoadCallback(Name.data());
663 return true;
664 }
665 }
666 }
667 }
668
669 if (TCling__AutoParseCallback(Name.str().c_str())) {
670 // Shouldn't we pop more?
671 raii.fPushedDCAndS.pop();
672 raii.fCleanupRAII.pop();
673 lookupSuccess = FE || SemaR.LookupName(R, S);
674 } else if (FE && TCling__GetClassSharedLibs(Name.str().c_str())) {
675 // We are "autoparsing" a header, and the header was not parsed.
676 // But its library is known - so we do know about that header.
677 // Do the parsing explicitly here, while recursive AutoLoading is
678 // disabled.
679 std::string incl = "#include \"";
680 incl += FE->getName();
681 incl += '"';
682 m_Interpreter->declare(incl);
683 }
684
686
687 if (lookupSuccess)
688 return true;
689 }
690
691 return false;
692}
693
694// If cling cannot find a name it should ask ROOT before it issues an error.
695// If ROOT knows the name then it has to create a new variable with that name
696// and type in dedicated for that namespace (eg. __ROOT_SpecialObjects).
697// For example if the interpreter is looking for h in h-Draw(), this routine
698// will create
699// namespace __ROOT_SpecialObjects {
700// THist* h = (THist*) the_address;
701// }
702//
703// Later if h is called again it again won't be found by the standart lookup
704// because it is in our hidden namespace (nobody should do using namespace
705// __ROOT_SpecialObjects). It caches the variable declarations and their
706// last address. If the newly found decl with the same name (h) has different
707// address than the cached one it goes directly at the address and updates it.
708//
709// returns true when declaration is found and no error should be emitted.
710//
711bool TClingCallbacks::tryFindROOTSpecialInternal(LookupResult &R, Scope *S) {
713 // init error or rootcling
714 return false;
715 }
716
717 // User must be able to redefine the names that come from a file.
718 if (R.isForRedeclaration())
719 return false;
720 // If there is a result abort.
721 if (!R.empty())
722 return false;
723 const Sema::LookupNameKind LookupKind = R.getLookupKind();
724 if (LookupKind != Sema::LookupOrdinaryName)
725 return false;
726
727
728 Sema &SemaR = m_Interpreter->getSema();
729 ASTContext& C = SemaR.getASTContext();
730 Preprocessor &PP = SemaR.getPreprocessor();
731 DeclContext *CurDC = SemaR.CurContext;
732 DeclarationName Name = R.getLookupName();
733
734 // Make sure that the failed lookup comes from a function body.
735 if(!CurDC || !CurDC->isFunctionOrMethod())
736 return false;
737
738 // Save state of the PP, because TCling__GetObjectAddress may induce nested
739 // lookup.
740 Preprocessor::CleanupAndRestoreCacheRAII cleanupPPRAII(PP);
741 TObject *obj = TCling__GetObjectAddress(Name.getAsString().c_str(),
743 cleanupPPRAII.pop(); // force restoring the cache
744
745 if (obj) {
746
747#if defined(R__MUST_REVISIT)
748#if R__MUST_REVISIT(6,2)
749 // Register the address in TCling::fgSetOfSpecials
750 // to speed-up the execution of TCling::RecursiveRemove when
751 // the object is not a special.
752 // See http://root.cern.ch/viewvc/trunk/core/meta/src/TCint.cxx?view=log#rev18109
753 if (!fgSetOfSpecials) {
754 fgSetOfSpecials = new std::set<TObject*>;
755 }
756 ((std::set<TObject*>*)fgSetOfSpecials)->insert((TObject*)*obj);
757#endif
758#endif
759
760 VarDecl *VD = cast_or_null<VarDecl>(utils::Lookup::Named(&SemaR, Name,
762 if (VD) {
763 //TODO: Check for same types.
764 GlobalDecl GD(VD);
765 TObject **address = (TObject**)m_Interpreter->getAddressOfGlobal(GD);
766 // Since code was generated already we cannot rely on the initializer
767 // of the decl in the AST, however we will update that init so that it
768 // will be easier while debugging.
769 CStyleCastExpr *CStyleCast = cast<CStyleCastExpr>(VD->getInit());
770 Expr* newInit = utils::Synthesize::IntegerLiteralExpr(C, (uint64_t)obj);
771 CStyleCast->setSubExpr(newInit);
772
773 // The actual update happens here, directly in memory.
774 *address = obj;
775 }
776 else {
777 // Save state of the PP
778 Preprocessor::CleanupAndRestoreCacheRAII cleanupRAII(PP);
779
780 const Decl *TD = TCling__GetObjectDecl(obj);
781 // We will declare the variable as pointer.
782 QualType QT = C.getPointerType(C.getTypeDeclType(cast<TypeDecl>(TD)));
783
784 VD = VarDecl::Create(C, fROOTSpecialNamespace, SourceLocation(),
785 SourceLocation(), Name.getAsIdentifierInfo(), QT,
786 /*TypeSourceInfo*/nullptr, SC_None);
787 // Build an initializer
788 Expr* Init
789 = utils::Synthesize::CStyleCastPtrExpr(&SemaR, QT, (uint64_t)obj);
790 // Register the decl in our hidden special namespace
791 VD->setInit(Init);
792 fROOTSpecialNamespace->addDecl(VD);
793
794 cling::CompilationOptions CO;
795 CO.DeclarationExtraction = 0;
796 CO.ValuePrinting = CompilationOptions::VPDisabled;
797 CO.ResultEvaluation = 0;
798 CO.DynamicScoping = 0;
799 CO.Debug = 0;
800 CO.CodeGeneration = 1;
801
802 cling::Transaction* T = new cling::Transaction(CO, SemaR);
803 T->append(VD);
804 T->setState(cling::Transaction::kCompleted);
805
806 m_Interpreter->emitAllDecls(T);
807 }
808 assert(VD && "Cannot be null!");
809 R.addDecl(VD);
810 return true;
811 }
812
813 return false;
814}
815
816bool TClingCallbacks::tryResolveAtRuntimeInternal(LookupResult &R, Scope *S) {
818 // init error or rootcling
819 return false;
820 }
821
822 if (!shouldResolveAtRuntime(R, S))
823 return false;
824
825 DeclarationName Name = R.getLookupName();
826 IdentifierInfo* II = Name.getAsIdentifierInfo();
827 SourceLocation Loc = R.getNameLoc();
828 Sema& SemaRef = R.getSema();
829 ASTContext& C = SemaRef.getASTContext();
830 DeclContext* TU = C.getTranslationUnitDecl();
831 assert(TU && "Must not be null.");
832
833 // DynamicLookup only happens inside wrapper functions:
834 clang::FunctionDecl* Wrapper = nullptr;
835 Scope* Cursor = S;
836 do {
837 DeclContext* DCCursor = Cursor->getEntity();
838 if (DCCursor == TU)
839 return false;
840 Wrapper = dyn_cast_or_null<FunctionDecl>(DCCursor);
841 if (Wrapper) {
842 if (utils::Analyze::IsWrapper(Wrapper)) {
843 break;
844 } else {
845 // Can't have a function inside the wrapper:
846 return false;
847 }
848 }
849 } while ((Cursor = Cursor->getParent()));
850
851 if (!Wrapper) {
852 // The parent of S wasn't the TU?!
853 return false;
854 }
855
856 VarDecl* Result = VarDecl::Create(C, TU, Loc, Loc, II, C.DependentTy,
857 /*TypeSourceInfo*/nullptr, SC_None);
858
859 if (!Result) {
860 // We cannot handle the situation. Give up
861 return false;
862 }
863
864 // Annotate the decl to give a hint in cling. FIXME: Current implementation
865 // is a gross hack, because TClingCallbacks shouldn't know about
866 // EvaluateTSynthesizer at all!
867
868 Wrapper->addAttr(AnnotateAttr::CreateImplicit(C, "__ResolveAtRuntime"));
869
870 // Here we have the scope but we cannot do Sema::PushDeclContext, because
871 // on pop it will try to go one level up, which we don't want.
872 Sema::ContextRAII pushedDC(SemaRef, TU);
873 R.addDecl(Result);
874 //SemaRef.PushOnScopeChains(Result, SemaRef.TUScope, /*Add to ctx*/true);
875 // Say that we can handle the situation. Clang should try to recover
876 return true;
877}
878
879bool TClingCallbacks::shouldResolveAtRuntime(LookupResult& R, Scope* S) {
880 if (m_IsRuntime)
881 return false;
882
883 if (R.getLookupKind() != Sema::LookupOrdinaryName)
884 return false;
885
886 if (R.isForRedeclaration())
887 return false;
888
889 if (!R.empty())
890 return false;
891
892 const Transaction* T = getInterpreter()->getCurrentTransaction();
893 if (!T)
894 return false;
895 const cling::CompilationOptions& COpts = T->getCompilationOpts();
896 if (!COpts.DynamicScoping)
897 return false;
898
899 auto &PP = R.getSema().PP;
900 // In `foo bar`, `foo` is certainly a type name and must not be resolved. We
901 // cannot rely on `PP.LookAhead(0)` as the parser might have already consumed
902 // some tokens.
903 SourceLocation LocAfterIdent = PP.getLocForEndOfToken(R.getNameLoc());
904 Token LookAhead0;
905 PP.getRawToken(LocAfterIdent, LookAhead0, /*IgnoreWhiteSpace=*/true);
906 if (LookAhead0.is(tok::raw_identifier))
907 return false;
908
909 // FIXME: Figure out better way to handle:
910 // C++ [basic.lookup.classref]p1:
911 // In a class member access expression (5.2.5), if the . or -> token is
912 // immediately followed by an identifier followed by a <, the
913 // identifier must be looked up to determine whether the < is the
914 // beginning of a template argument list (14.2) or a less-than operator.
915 // The identifier is first looked up in the class of the object
916 // expression. If the identifier is not found, it is then looked up in
917 // the context of the entire postfix-expression and shall name a class
918 // or function template.
919 //
920 // We want to ignore object(.|->)member<template>
921 //if (R.getSema().PP.LookAhead(0).getKind() == tok::less)
922 // TODO: check for . or -> in the cached token stream
923 // return false;
924
925 for (Scope* DepScope = S; DepScope; DepScope = DepScope->getParent()) {
926 if (DeclContext* Ctx = static_cast<DeclContext*>(DepScope->getEntity())) {
927 if (!Ctx->isDependentContext())
928 // For now we support only the prompt.
929 if (isa<FunctionDecl>(Ctx))
930 return true;
931 }
932 }
933
934 return false;
935}
936
939 // init error or rootcling
940 return false;
941 }
942
943 // Should be disabled with the dynamic scopes.
944 if (m_IsRuntime)
945 return false;
946
947 if (R.isForRedeclaration())
948 return false;
949
950 if (R.getLookupKind() != Sema::LookupOrdinaryName)
951 return false;
952
953 if (!isa<FunctionDecl>(R.getSema().CurContext))
954 return false;
955
956 {
957 // ROOT-8538: only top-most (function-level) scope is supported.
958 DeclContext* ScopeDC = S->getEntity();
959 if (!ScopeDC || !llvm::isa<FunctionDecl>(ScopeDC))
960 return false;
961
962 // Make sure that the failed lookup comes the prompt. Currently, we
963 // support only the prompt.
964 Scope* FnScope = S->getFnParent();
965 if (!FnScope)
966 return false;
967 auto FD = dyn_cast_or_null<FunctionDecl>(FnScope->getEntity());
968 if (!FD || !utils::Analyze::IsWrapper(FD))
969 return false;
970 }
971
972 Sema& SemaRef = R.getSema();
973 ASTContext& C = SemaRef.getASTContext();
974 DeclContext* DC = SemaRef.CurContext;
975 assert(DC && "Must not be null.");
976
977
978 Preprocessor& PP = R.getSema().getPreprocessor();
979 //Preprocessor::CleanupAndRestoreCacheRAII cleanupRAII(PP);
980 //PP.EnableBacktrackAtThisPos();
981 if (PP.LookAhead(0).isNot(tok::equal)) {
982 //PP.Backtrack();
983 return false;
984 }
985 //PP.CommitBacktrackedTokens();
986 //cleanupRAII.pop();
987 DeclarationName Name = R.getLookupName();
988 IdentifierInfo* II = Name.getAsIdentifierInfo();
989 SourceLocation Loc = R.getNameLoc();
990 VarDecl* Result = VarDecl::Create(C, DC, Loc, Loc, II,
991 C.getAutoType(QualType(),
992 clang::AutoTypeKeyword::Auto,
993 /*IsDependent*/false),
994 /*TypeSourceInfo*/nullptr, SC_None);
995
996 if (!Result) {
997 ROOT::TMetaUtils::Error("TClingCallbacks::tryInjectImplicitAutoKeyword",
998 "Cannot create VarDecl");
999 return false;
1000 }
1001
1002 // Annotate the decl to give a hint in cling.
1003 // FIXME: We should move this in cling, when we implement turning it on
1004 // and off.
1005 Result->addAttr(AnnotateAttr::CreateImplicit(C, "__Auto"));
1006
1007 R.addDecl(Result);
1008 // Say that we can handle the situation. Clang should try to recover
1009 return true;
1010}
1011
1013 // Replay existing decls from the AST.
1014 if (fFirstRun) {
1015 // Before setting up the callbacks register what cling have seen during init.
1016 Sema& SemaR = m_Interpreter->getSema();
1017 cling::Transaction TPrev((cling::CompilationOptions(), SemaR));
1018 TPrev.append(SemaR.getASTContext().getTranslationUnitDecl());
1019 TCling__UpdateListsOnCommitted(TPrev, m_Interpreter);
1020
1021 fFirstRun = false;
1022 }
1023}
1024
1025// The callback is used to update the list of globals in ROOT.
1026//
1027void TClingCallbacks::TransactionCommitted(const Transaction &T) {
1028 if (fFirstRun && T.empty())
1029 Initialize();
1030
1031 TCling__UpdateListsOnCommitted(T, m_Interpreter);
1032}
1033
1034// The callback is used to update the list of globals in ROOT.
1035//
1036void TClingCallbacks::TransactionUnloaded(const Transaction &T) {
1037 if (T.empty())
1038 return;
1039
1041}
1042
1043// The callback is used to clear the autoparsing caches.
1044//
1045void TClingCallbacks::TransactionRollback(const Transaction &T) {
1046 if (T.empty())
1047 return;
1048
1050}
1051
1052void TClingCallbacks::DefinitionShadowed(const clang::NamedDecl *D) {
1054}
1055
1056void TClingCallbacks::DeclDeserialized(const clang::Decl* D) {
1057 if (const RecordDecl* RD = dyn_cast<RecordDecl>(D)) {
1058 // FIXME: Our AutoLoading doesn't work (load the library) when the looked
1059 // up decl is found in the PCH/PCM. We have to do that extra step, which
1060 // loads the corresponding library when a decl was deserialized.
1061 //
1062 // Unfortunately we cannot do that with the current implementation,
1063 // because the library load will pull in the header files of the library
1064 // as well, even though they are in the PCH/PCM and available.
1065 (void)RD;//TCling__AutoLoadCallback(RD->getNameAsString().c_str());
1066 }
1067}
1068
1069void TClingCallbacks::LibraryLoaded(const void* dyLibHandle,
1070 llvm::StringRef canonicalName) {
1071 TCling__LibraryLoadedRTTI(dyLibHandle, canonicalName);
1072}
1073
1074void TClingCallbacks::LibraryUnloaded(const void* dyLibHandle,
1075 llvm::StringRef canonicalName) {
1076 TCling__LibraryUnloadedRTTI(dyLibHandle, canonicalName);
1077}
1078
1081}
1082
1084{
1085 // We can safely assume that if the lock exist already when we are in Cling code,
1086 // then the lock has (or should been taken) already. Any action (that caused callers
1087 // to take the lock) is halted during ProcessLine. So it is fair to unlock it.
1089}
1090
1092{
1094}
1095
1097{
1099}
1100
1102{
1104}
#define R__EXTERN
Definition DllImport.h:27
The file contains utilities which are foundational and could be used across the core component of ROO...
bool TCling__LibraryLoadingFailed(const std::string &, const std::string &, bool, bool)
Lookup libraries in LD_LIBRARY_PATH and DYLD_LIBRARY_PATH with mangled_name, which is extracted by er...
Definition TCling.cxx:349
void * TCling__LockCompilationDuringUserCodeExecution()
Lock the interpreter.
Definition TCling.cxx:366
int TCling__LoadLibrary(const char *library)
Load a library.
Definition TCling.cxx:331
void TCling__UpdateListsOnCommitted(const cling::Transaction &, Interpreter *)
void TCling__SplitAclicMode(const char *fileName, std::string &mode, std::string &args, std::string &io, std::string &fname)
Definition TCling.cxx:649
void TCling__TransactionRollback(const cling::Transaction &)
Definition TCling.cxx:577
const char * TCling__GetClassSharedLibs(const char *className)
Definition TCling.cxx:631
int TCling__AutoParseCallback(const char *className)
Definition TCling.cxx:626
Decl * TCling__GetObjectDecl(TObject *obj)
Definition TCling.cxx:602
R__EXTERN int gDebug
void TCling__GetNormalizedContext(const ROOT::TMetaUtils::TNormalizedCtxt *&)
Definition TCling.cxx:555
void TCling__RestoreInterpreterMutex(void *state)
Re-apply the lock count delta that TCling__ResetInterpreterMutex() caused.
Definition TCling.cxx:339
int TCling__CompileMacro(const char *fileName, const char *options)
Definition TCling.cxx:642
void * TCling__ResetInterpreterMutex()
Reset the interpreter lock to the state it had before interpreter-related calls happened.
Definition TCling.cxx:358
int TCling__AutoLoadCallback(const char *className)
Definition TCling.cxx:621
void TCling__LibraryUnloadedRTTI(const void *dyLibHandle, llvm::StringRef canonicalName)
void TCling__PrintStackTrace()
Print a StackTrace!
Definition TCling.cxx:324
int TCling__IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *name)
Definition TCling.cxx:637
void TCling__UpdateListsOnUnloaded(const cling::Transaction &)
Definition TCling.cxx:567
void TCling__UnlockCompilationDuringUserCodeExecution(void *state)
Unlock the interpreter.
Definition TCling.cxx:377
static bool topmostDCIsFunction(Scope *S)
void TCling__InvalidateGlobal(const clang::Decl *)
Definition TCling.cxx:572
void TCling__LibraryLoadedRTTI(const void *dyLibHandle, llvm::StringRef canonicalName)
TObject * TCling__GetObjectAddress(const char *Name, void *&LookupCtx)
Definition TCling.cxx:598
void TCling__RestoreInterpreterMutex(void *delta)
Re-apply the lock count delta that TCling__ResetInterpreterMutex() caused.
Definition TCling.cxx:339
void TCling__TransactionRollback(const cling::Transaction &T)
Definition TCling.cxx:577
void TCling__InvalidateGlobal(const clang::Decl *D)
Definition TCling.cxx:572
void * TCling__LockCompilationDuringUserCodeExecution()
Lock the interpreter.
Definition TCling.cxx:366
void TCling__UpdateListsOnUnloaded(const cling::Transaction &T)
Definition TCling.cxx:567
void TCling__GetNormalizedContext(const ROOT::TMetaUtils::TNormalizedCtxt *&normCtxt)
Definition TCling.cxx:555
bool TCling__LibraryLoadingFailed(const std::string &errmessage, const std::string &libStem, bool permanent, bool resolved)
Lookup libraries in LD_LIBRARY_PATH and DYLD_LIBRARY_PATH with mangled_name, which is extracted by er...
Definition TCling.cxx:349
void TCling__UnlockCompilationDuringUserCodeExecution(void *)
Unlock the interpreter.
Definition TCling.cxx:377
const char * TCling__GetClassSharedLibs(const char *className)
Definition TCling.cxx:631
int TCling__AutoParseCallback(const char *className)
Definition TCling.cxx:626
void TCling__LibraryUnloadedRTTI(const void *dyLibHandle, const char *canonicalName)
Definition TCling.cxx:591
void TCling__UpdateListsOnCommitted(const cling::Transaction &T, cling::Interpreter *)
Definition TCling.cxx:562
const Decl * TCling__GetObjectDecl(TObject *obj)
Definition TCling.cxx:602
int TCling__CompileMacro(const char *fileName, const char *options)
Definition TCling.cxx:642
void * TCling__ResetInterpreterMutex()
Reset the interpreter lock to the state it had before interpreter-related calls happened.
Definition TCling.cxx:358
int TCling__AutoLoadCallback(const char *className)
Definition TCling.cxx:621
void TCling__PrintStackTrace()
Print a StackTrace!
Definition TCling.cxx:324
void TCling__LibraryLoadedRTTI(const void *dyLibHandle, const char *canonicalName)
Definition TCling.cxx:581
TObject * TCling__GetObjectAddress(const char *Name, void *&LookupCtx)
Definition TCling.cxx:598
int TCling__IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *nsDecl)
Definition TCling.cxx:637
void TCling__SplitAclicMode(const char *fileName, string &mode, string &args, string &io, string &fname)
Definition TCling.cxx:649
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char mode
char name[80]
Definition TGX11.cxx:110
XID Cursor
Definition TGX11.h:37
Int_t gDebug
Definition TROOT.cxx:595
AutoloadLibraryGenerator(cling::Interpreter *interp)
cling::Interpreter * fInterpreter
llvm::Error tryToGenerate(llvm::orc::LookupState &LS, llvm::orc::LookupKind K, llvm::orc::JITDylib &JD, llvm::orc::JITDylibLookupFlags JDLookupFlags, const llvm::orc::SymbolLookupSet &Symbols) override
void discard(const llvm::orc::JITDylib &JD, const llvm::orc::SymbolStringPtr &Name) override
void materialize(std::unique_ptr< llvm::orc::MaterializationResponsibility > R) override
llvm::orc::SymbolNameVector fSymbols
StringRef getName() const override
static llvm::orc::SymbolFlagsMap getSymbolFlagsMap(const llvm::orc::SymbolNameVector &Symbols)
AutoloadLibraryMU(const std::string &Library, const llvm::orc::SymbolNameVector &Symbols)
void LibraryUnloaded(const void *dyLibHandle, llvm::StringRef canonicalName) override
bool tryAutoParseInternal(llvm::StringRef Name, clang::LookupResult &R, clang::Scope *S, const clang::FileEntry *FE=0)
bool tryFindROOTSpecialInternal(clang::LookupResult &R, clang::Scope *S)
void ReturnedFromUserCode(void *stateInfo) override
bool tryResolveAtRuntimeInternal(clang::LookupResult &R, clang::Scope *S)
bool findInGlobalModuleIndex(clang::DeclarationName Name, bool loadFirstMatchOnly=true)
void PrintStackTrace() override
bool tryInjectImplicitAutoKeyword(clang::LookupResult &R, clang::Scope *S)
bool IsAutoLoadingEnabled()
clang::NamespaceDecl * fROOTSpecialNamespace
void TransactionRollback(const cling::Transaction &T) override
void TransactionCommitted(const cling::Transaction &T) override
TClingCallbacks(cling::Interpreter *interp, bool hasCodeGen)
llvm::DenseMap< llvm::StringRef, clang::DeclarationName > m_LoadedModuleFiles
void DeclDeserialized(const clang::Decl *D) override
void InclusionDirective(clang::SourceLocation, const clang::Token &, llvm::StringRef FileName, bool, clang::CharSourceRange, const clang::FileEntry *, llvm::StringRef, llvm::StringRef, const clang::Module *, clang::SrcMgr::CharacteristicKind) override
void DefinitionShadowed(const clang::NamedDecl *D) override
A previous definition has been shadowed; invalidate TCling' stored data about the old (global) decl.
bool FileNotFound(llvm::StringRef FileName, llvm::SmallVectorImpl< char > &RecoveryPath) override
void * EnteringUserCode() override
void UnlockCompilationDuringUserCodeExecution(void *StateInfo) override
bool LibraryLoadingFailed(const std::string &, const std::string &, bool, bool) override
void * LockCompilationDuringUserCodeExecution() override
bool LookupObject(clang::LookupResult &R, clang::Scope *S) override
void LibraryLoaded(const void *dyLibHandle, llvm::StringRef canonicalName) override
bool shouldResolveAtRuntime(clang::LookupResult &R, clang::Scope *S)
void TransactionUnloaded(const cling::Transaction &T) override
Mother of all ROOT objects.
Definition TObject.h:41
#define I(x, y, z)
bool ConvertEnvValueToBool(const std::string &value)
void Error(const char *location, const char *fmt,...)
void Info(const char *location, const char *fmt,...)
void GetNormalizedName(std::string &norm_name, const clang::QualType &type, const cling::Interpreter &interpreter, const TNormalizedCtxt &normCtxt)
Return the type name normalized for ROOT, keeping only the ROOT opaque typedef (Double32_t,...
static std::string DemangleNameForDlsym(const std::string &name)
RooArgSet S(Args_t &&... args)
Definition RooArgSet.h:232
constexpr Double_t E()
Base of natural log: .
Definition TMath.h:93
const char * Name
Definition TXMLSetup.cxx:67
RAII used to store Parser, Sema, Preprocessor state for recursive parsing.
Definition ClingRAII.h:22
clang::Preprocessor::CleanupAndRestoreCacheRAII fCleanupRAII
Definition ClingRAII.h:60
clang::Sema::ContextAndScopeRAII fPushedDCAndS
Definition ClingRAII.h:73