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#include "clang/Basic/DiagnosticSema.h"
37
38#include "llvm/ExecutionEngine/Orc/Core.h"
39
40#include "llvm/Support/Error.h"
41#include "llvm/Support/FileSystem.h"
42#include "llvm/Support/Path.h"
43#include "llvm/Support/Process.h"
44
45#include "TClingUtils.h"
46#include "ClingRAII.h"
47
48#include <optional>
49
50using namespace clang;
51using namespace cling;
52using namespace ROOT::Internal;
53
55class TObject;
56
57// Functions used to forward calls from code compiled with no-rtti to code
58// compiled with rtti.
59extern "C" {
60 void TCling__UpdateListsOnCommitted(const cling::Transaction&, Interpreter*);
61 void TCling__UpdateListsOnUnloaded(const cling::Transaction&);
62 void TCling__InvalidateGlobal(const clang::Decl*);
63 void TCling__TransactionRollback(const cling::Transaction&);
65 TObject* TCling__GetObjectAddress(const char *Name, void *&LookupCtx);
67 int TCling__AutoLoadCallback(const char* className);
68 int TCling__AutoParseCallback(const char* className);
69 const char* TCling__GetClassSharedLibs(const char* className);
70 int TCling__IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl* name);
71 int TCling__CompileMacro(const char *fileName, const char *options);
72 void TCling__SplitAclicMode(const char* fileName, std::string &mode,
73 std::string &args, std::string &io, std::string &fname);
74 int TCling__LoadLibrary(const char *library);
75 bool TCling__LibraryLoadingFailed(const std::string&, const std::string&, bool, bool);
76 void TCling__LibraryLoadedRTTI(const void* dyLibHandle,
77 llvm::StringRef canonicalName);
78 void TCling__LibraryUnloadedRTTI(const void* dyLibHandle,
79 llvm::StringRef canonicalName);
82 void TCling__RestoreInterpreterMutex(void *state);
85}
86
89 std::string fLibrary;
90 llvm::orc::SymbolNameVector fSymbols;
91public:
92 AutoloadLibraryMU(const TClingCallbacks &cb, const std::string &Library, const llvm::orc::SymbolNameVector &Symbols)
93 : MaterializationUnit({getSymbolFlagsMap(Symbols), nullptr}), fCallbacks(cb), fLibrary(Library), fSymbols(Symbols)
94 {
95 }
96
97 StringRef getName() const override { return "<Symbols from Autoloaded Library>"; }
98
99 void materialize(std::unique_ptr<llvm::orc::MaterializationResponsibility> R) override
100 {
102 R->failMaterialization();
103 return;
104 }
105
106 llvm::orc::SymbolMap loadedSymbols;
107 llvm::orc::SymbolNameSet failedSymbols;
108 bool loadedLibrary = false;
109
110 for (auto symbol : fSymbols) {
111 std::string symbolStr = (*symbol).str();
112 std::string nameForDlsym = ROOT::TMetaUtils::DemangleNameForDlsym(symbolStr);
113
114 // Check if the symbol is available without loading the library.
115 void *addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(nameForDlsym);
116
117 if (!addr && !loadedLibrary) {
118 // Try to load the library which should provide the symbol definition.
119 // TODO: Should this interface with the DynamicLibraryManager directly?
120 if (TCling__LoadLibrary(fLibrary.c_str()) < 0) {
121 ROOT::TMetaUtils::Error("AutoloadLibraryMU", "Failed to load library %s", fLibrary.c_str());
122 }
123
124 // Only try loading the library once.
125 loadedLibrary = true;
126
127 addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(nameForDlsym);
128 }
129
130 if (addr) {
131 loadedSymbols[symbol] =
132 llvm::JITEvaluatedSymbol(llvm::pointerToJITTargetAddress(addr), llvm::JITSymbolFlags::Exported);
133 } else {
134 // Collect all failing symbols, delegate their responsibility and then
135 // fail their materialization. R->defineNonExistent() sounds like it
136 // should do that, but it's not implemented?!
137 failedSymbols.insert(symbol);
138 }
139 }
140
141 if (!failedSymbols.empty()) {
142 auto failingMR = R->delegate(failedSymbols);
143 if (failingMR) {
144 (*failingMR)->failMaterialization();
145 }
146 }
147
148 if (!loadedSymbols.empty()) {
149 llvm::cantFail(R->notifyResolved(loadedSymbols));
150 llvm::cantFail(R->notifyEmitted());
151 }
152 }
153
154 void discard(const llvm::orc::JITDylib &JD, const llvm::orc::SymbolStringPtr &Name) override {}
155
156private:
157 static llvm::orc::SymbolFlagsMap getSymbolFlagsMap(const llvm::orc::SymbolNameVector &Symbols)
158 {
159 llvm::orc::SymbolFlagsMap map;
160 for (auto symbolName : Symbols)
161 map[symbolName] = llvm::JITSymbolFlags::Exported;
162 return map;
163 }
164};
165
168 cling::Interpreter *fInterpreter;
169public:
170 AutoloadLibraryGenerator(cling::Interpreter *interp, const TClingCallbacks& cb)
171 : fCallbacks(cb), fInterpreter(interp) {}
172
173 llvm::Error tryToGenerate(llvm::orc::LookupState &LS, llvm::orc::LookupKind K, llvm::orc::JITDylib &JD,
174 llvm::orc::JITDylibLookupFlags JDLookupFlags,
175 const llvm::orc::SymbolLookupSet &Symbols) override
176 {
178 llvm::Error::success();
179
180 // If we get here, the symbols have not been found in the current process,
181 // so no need to check that again. Instead search for the library that
182 // provides the symbol and create one MaterializationUnit per library to
183 // actually load it if needed.
184 std::unordered_map<std::string, llvm::orc::SymbolNameVector> found;
185 llvm::orc::SymbolNameSet missing;
186
187 // TODO: Do we need to take gInterpreterMutex?
188 // R__LOCKGUARD(gInterpreterMutex);
189
190 for (auto &&KV : Symbols) {
191 llvm::orc::SymbolStringPtr name = KV.first;
192
193 const cling::DynamicLibraryManager &DLM = *fInterpreter->getDynamicLibraryManager();
194
195 std::string libName = DLM.searchLibrariesForSymbol((*name).str(),
196 /*searchSystem=*/true);
197
198 // libNew overrides memory management functions; must never autoload that.
199 assert(libName.find("/libNew.") == std::string::npos && "We must not autoload libNew!");
200
201 // libCling symbols are intentionally hidden from the process, and libCling must not be
202 // dlopened. Instead, symbols must be resolved by specifically querying the dynlib handle of
203 // libCling, which by definition is loaded - else we could not call this code. The handle
204 // is made available as argument to `CreateInterpreter`.
205 assert(libName.find("/libCling.") == std::string::npos && "Must not autoload libCling!");
206
207 if (libName.empty())
208 missing.insert(name);
209 else
210 found[libName].push_back(name);
211 }
212
213 for (auto &&KV : found) {
214 auto MU = std::make_unique<AutoloadLibraryMU>(fCallbacks, KV.first, std::move(KV.second));
215 if (auto Err = JD.define(MU))
216 return Err;
217 }
218
219 if (!missing.empty())
220 return llvm::make_error<llvm::orc::SymbolsNotFound>(
221 JD.getExecutionSession().getSymbolStringPool(), std::move(missing));
222
223 return llvm::Error::success();
224 }
225};
226
227TClingCallbacks::TClingCallbacks(cling::Interpreter *interp, bool hasCodeGen) : InterpreterCallbacks(interp)
228{
229 if (hasCodeGen) {
230 Transaction* T = nullptr;
231 m_Interpreter->declare("namespace __ROOT_SpecialObjects{}", &T);
232 fROOTSpecialNamespace = dyn_cast<NamespaceDecl>(T->getFirstDecl().getSingleDecl());
233
234 interp->addGenerator(std::make_unique<AutoloadLibraryGenerator>(interp, *this));
235 }
236}
237
238//pin the vtable here
240
241void TClingCallbacks::InclusionDirective(clang::SourceLocation sLoc/*HashLoc*/,
242 const clang::Token &/*IncludeTok*/,
243 llvm::StringRef FileName,
244 bool /*IsAngled*/,
245 clang::CharSourceRange /*FilenameRange*/,
246 clang::OptionalFileEntryRef FE,
247 llvm::StringRef /*SearchPath*/,
248 llvm::StringRef /*RelativePath*/,
249 const clang::Module * Imported,
250 clang::SrcMgr::CharacteristicKind FileType) {
251 // We found a module. Do not try to do anything else.
252 Sema &SemaR = m_Interpreter->getSema();
253 if (Imported) {
254 // FIXME: We should make the module visible at that point.
255 if (!SemaR.isModuleVisible(Imported))
256 ROOT::TMetaUtils::Info("TClingCallbacks::InclusionDirective",
257 "Module %s resolved but not visible!", Imported->Name.c_str());
258 else
259 return;
260 }
261
262 // Method called via Callbacks->InclusionDirective()
263 // in Preprocessor::HandleIncludeDirective(), invoked whenever an
264 // inclusion directive has been processed, and allowing us to try
265 // to autoload libraries using their header file name.
266 // Two strategies are tried:
267 // 1) The header name is looked for in the list of autoload keys
268 // 2) Heurists are applied to the header name to distill a classname.
269 // For example try to autoload TGClient (libGui) when seeing #include "TGClient.h"
270 // or TH1F in presence of TH1F.h.
271 // Strategy 2) is tried only if 1) fails.
272
273 bool isHeaderFile = FileName.endswith(".h") || FileName.endswith(".hxx") || FileName.endswith(".hpp");
274 if (!IsAutoLoadingEnabled() || fIsAutoLoadingRecursively || !isHeaderFile)
275 return;
276
277 std::string localString(FileName.str());
278
279 DeclarationName Name = &SemaR.getASTContext().Idents.get(localString.c_str());
280 LookupResult RHeader(SemaR, Name, sLoc, Sema::LookupOrdinaryName);
281
282 tryAutoParseInternal(localString, RHeader, SemaR.getCurScope(), FE);
283}
284
285// TCling__LibraryLoadingFailed is a function in TCling which handles errmessage
286bool TClingCallbacks::LibraryLoadingFailed(const std::string& errmessage, const std::string& libStem,
287 bool permanent, bool resolved) {
288 return TCling__LibraryLoadingFailed(errmessage, libStem, permanent, resolved);
289}
290
291// Preprocessor callbacks used to handle special cases like for example:
292// #include "myMacro.C+"
293//
294bool TClingCallbacks::FileNotFound(llvm::StringRef FileName) {
295 // Method called via Callbacks->FileNotFound(Filename)
296 // in Preprocessor::HandleIncludeDirective(), initially allowing to
297 // change the include path, and allowing us to compile code via ACLiC
298 // when specifying #include "myfile.C+", and suppressing the preprocessor
299 // error message:
300 // input_line_23:1:10: fatal error: 'myfile.C+' file not found
301
302 Preprocessor& PP = m_Interpreter->getCI()->getPreprocessor();
303
304 // remove any trailing "\n
305 std::string filename(FileName.str().substr(0,FileName.str().find_last_of('"')));
306 std::string fname, mode, arguments, io;
307 // extract the filename and ACliC mode
308 TCling__SplitAclicMode(filename.c_str(), mode, arguments, io, fname);
309 if (mode.length() > 0) {
310 if (llvm::sys::fs::exists(fname)) {
311 // format the CompileMacro() option string
312 std::string options = "k";
313 if (mode.find("++") != std::string::npos) options += "f";
314 if (mode.find("g") != std::string::npos) options += "g";
315 if (mode.find("O") != std::string::npos) options += "O";
316
317 // Save state of the preprocessor
318 Preprocessor::CleanupAndRestoreCacheRAII cleanupRAII(PP);
319 Parser& P = const_cast<Parser&>(m_Interpreter->getParser());
320 // We parsed 'include' token. Store it.
321 clang::Parser::ParserCurTokRestoreRAII fSavedCurToken(P);
322 // We provide our own way of handling the entire #include "file.c+"
323 // After we have saved the token reset the current one to
324 // something which is safe (semi colon usually means empty decl)
325 Token& Tok = const_cast<Token&>(P.getCurToken());
326 Tok.setKind(tok::semi);
327 // We can't PushDeclContext, because we go up and the routine that pops
328 // the DeclContext assumes that we drill down always.
329 // We have to be on the global context. At that point we are in a
330 // wrapper function so the parent context must be the global.
331 // This is needed to solve potential issues when using #include "myFile.C+"
332 // after a scope declaration like:
333 // void Check(TObject* obj) {
334 // if (obj) cout << "Found the referenced object\n";
335 // else cout << "Error: Could not find the referenced object\n";
336 // }
337 // #include "A.C+"
338 Sema& SemaR = m_Interpreter->getSema();
339 ASTContext& C = SemaR.getASTContext();
340 Sema::ContextAndScopeRAII pushedDCAndS(SemaR, C.getTranslationUnitDecl(),
341 SemaR.TUScope);
342 int retcode = TCling__CompileMacro(fname.c_str(), options.c_str());
343 if (retcode) {
344 // compilation was successful, tell the preprocess to silently
345 // skip the file
346 return true;
347 }
348 }
349 }
350 return false;
351}
352
353
354static bool topmostDCIsFunction(Scope* S) {
355 if (!S)
356 return false;
357
358 DeclContext* DC = S->getEntity();
359 // For DeclContext-less scopes like if (dyn_expr) {}
360 // Find the DC enclosing S.
361 while (!DC) {
362 S = S->getParent();
363 DC = S->getEntity();
364 }
365
366 // DynamicLookup only happens inside topmost functions:
367 clang::DeclContext* MaybeTU = DC;
368 while (MaybeTU && !isa<TranslationUnitDecl>(MaybeTU)) {
369 DC = MaybeTU;
370 MaybeTU = MaybeTU->getParent();
371 }
372 return isa<FunctionDecl>(DC);
373}
374
375// On a failed lookup we have to try to more things before issuing an error.
376// The symbol might need to be loaded by ROOT's AutoLoading mechanism or
377// it might be a ROOT special object.
378//
379// Try those first and if still failing issue the diagnostics.
380//
381// returns true when a declaration is found and no error should be emitted.
382//
383bool TClingCallbacks::LookupObject(LookupResult &R, Scope *S) {
385 // init error or rootcling
386 return false;
387 }
388
389 // Don't do any extra work if an error that is not still recovered occurred.
390 if (m_Interpreter->getSema().getDiagnostics().hasErrorOccurred())
391 return false;
392
393 if (tryAutoParseInternal(R.getLookupName().getAsString(), R, S))
394 return true; // happiness.
395
396 // The remaining lookup routines only work on global scope functions
397 // ("macros"), not in classes, namespaces etc - anything that looks like
398 // it has seen any trace of software development.
399 if (!topmostDCIsFunction(S))
400 return false;
401
402 // If the autoload wasn't successful try ROOT specials.
404 return true;
405
406 // For backward-compatibility with CINT we must support stmts like:
407 // x = 4; y = new MyClass();
408 // I.e we should "inject" a C++11 auto keyword in front of "x" and "y"
409 // This has to have higher precedence than the dynamic scopes. It is claimed
410 // that if one assigns to a name and the lookup of that name fails if *must*
411 // auto keyword must be injected and the stmt evaluation must not be delayed
412 // until runtime.
413 // For now supported only at the prompt.
415 return true;
416 }
417
419 return false;
420
421 // Finally try to resolve this name as a dynamic name, i.e delay its
422 // resolution for runtime.
424}
425
426bool TClingCallbacks::findInGlobalModuleIndex(DeclarationName Name, bool loadFirstMatchOnly /*=true*/)
427{
428 std::optional<std::string> envUseGMI = llvm::sys::Process::GetEnv("ROOT_USE_GMI");
429 if (envUseGMI.has_value())
430 if (!envUseGMI->empty() && !ROOT::FoundationUtils::ConvertEnvValueToBool(*envUseGMI))
431 return false;
432
433 const CompilerInstance *CI = m_Interpreter->getCI();
434 const LangOptions &LangOpts = CI->getPreprocessor().getLangOpts();
435
436 if (!LangOpts.Modules)
437 return false;
438
439 // We are currently building a module, we should not import .
440 if (LangOpts.isCompilingModule())
441 return false;
442
443 if (fIsCodeGening)
444 return false;
445
446 // We are currently instantiating one (or more) templates. At that point,
447 // all Decls are present in the AST (with possibly deserialization pending),
448 // and we should not load more modules which could find an implicit template
449 // instantiation that is lazily loaded.
450 Sema &SemaR = m_Interpreter->getSema();
451 if (SemaR.InstantiatingSpecializations.size() > 0)
452 return false;
453
454 GlobalModuleIndex *Index = CI->getASTReader()->getGlobalIndex();
455 if (!Index)
456 return false;
457
458 // FIXME: We should load only the first available and rely on other callbacks
459 // such as RequireCompleteType and LookupUnqualified to load all.
460 GlobalModuleIndex::FileNameHitSet FoundModules;
461
462 // Find the modules that reference the identifier.
463 // Note that this only finds top-level modules.
464 if (Index->lookupIdentifier(Name.getAsString(), FoundModules)) {
465 for (llvm::StringRef FileName : FoundModules) {
466 StringRef ModuleName = llvm::sys::path::stem(FileName);
467
468 // Skip to the first not-yet-loaded module.
469 if (m_LoadedModuleFiles.count(FileName)) {
470 if (gDebug > 2)
471 llvm::errs() << "Module '" << ModuleName << "' already loaded"
472 << " for '" << Name.getAsString() << "'\n";
473 continue;
474 }
475
476 fIsLoadingModule = true;
477 if (gDebug > 2)
478 llvm::errs() << "Loading '" << ModuleName << "' on demand"
479 << " for '" << Name.getAsString() << "'\n";
480
481 m_Interpreter->loadModule(ModuleName.str());
482 fIsLoadingModule = false;
483 m_LoadedModuleFiles[FileName] = Name;
484 if (loadFirstMatchOnly)
485 break;
486 }
487 return true;
488 }
489 return false;
490}
491
492bool TClingCallbacks::LookupObject(const DeclContext* DC, DeclarationName Name) {
494 // init error or rootcling
495 return false;
496 }
497
499 return false;
500
502 return false;
503
504 if (Name.getNameKind() != DeclarationName::Identifier)
505 return false;
506
507 Sema &SemaR = m_Interpreter->getSema();
508 auto *D = cast<Decl>(DC);
509 SourceLocation Loc = D->getLocation();
510 if (Loc.isValid() && SemaR.getSourceManager().isInSystemHeader(Loc)) {
511 // This declaration comes from a system module, we do not want to try
512 // autoparsing it and find instantiations in our ROOT modules.
513 return false;
514 }
515
516 // Get the 'lookup' decl context.
517 // We need to cast away the constness because we will lookup items of this
518 // namespace/DeclContext
519 NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(const_cast<DeclContext*>(DC));
520
521 // When GMI is mixed with rootmaps, we might have a name for two different
522 // entities provided by the two systems. In that case check if the rootmaps
523 // registered the enclosing namespace as a rootmap name resolution namespace
524 // and only if that was not the case use the information in the GMI.
525 if (!NSD || !TCling__IsAutoLoadNamespaceCandidate(NSD)) {
526 // After loading modules, we must update the redeclaration chains.
527 return findInGlobalModuleIndex(Name, /*loadFirstMatchOnly*/ false) && D->getMostRecentDecl();
528 }
529
530 const DeclContext* primaryDC = NSD->getPrimaryContext();
531 if (primaryDC != DC)
532 return false;
533
534 LookupResult R(SemaR, Name, SourceLocation(), Sema::LookupOrdinaryName);
535 R.suppressDiagnostics();
536 // We need the qualified name for TCling to find the right library.
537 std::string qualName
538 = NSD->getQualifiedNameAsString() + "::" + Name.getAsString();
539
540
541 // We want to avoid qualified lookups, because they are expensive and
542 // difficult to construct. This is why we *artificially* push a scope and
543 // a decl context, where Sema should do the lookup.
544 clang::Scope S(SemaR.TUScope, clang::Scope::DeclScope, SemaR.getDiagnostics());
545 S.setEntity(const_cast<DeclContext*>(DC));
546 Sema::ContextAndScopeRAII pushedDCAndS(SemaR, const_cast<DeclContext*>(DC), &S);
547
548 if (tryAutoParseInternal(qualName, R, SemaR.getCurScope())) {
549 llvm::SmallVector<NamedDecl*, 4> lookupResults;
550 for(LookupResult::iterator I = R.begin(), E = R.end(); I < E; ++I)
551 lookupResults.push_back(*I);
552 UpdateWithNewDecls(DC, Name, llvm::ArrayRef(lookupResults.data(), 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, clang::OptionalFileEntryRef FE) {
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
1009 // Raise a warning when trying to use implicit auto injection feature.
1010 SemaRef.getDiagnostics().setSeverity(diag::warn_deprecated_message, diag::Severity::Warning, SourceLocation());
1011 SemaRef.Diag(Loc, diag::warn_deprecated_message)
1012 << "declaration without the 'auto' keyword" << DC << Loc << FixItHint::CreateInsertion(Loc, "auto ");
1013
1014 // Say that we can handle the situation. Clang should try to recover
1015 return true;
1016}
1017
1019 // Replay existing decls from the AST.
1020 if (fFirstRun) {
1021 // Before setting up the callbacks register what cling have seen during init.
1022 Sema& SemaR = m_Interpreter->getSema();
1023 cling::Transaction TPrev((cling::CompilationOptions(), SemaR));
1024 TPrev.append(SemaR.getASTContext().getTranslationUnitDecl());
1025 TCling__UpdateListsOnCommitted(TPrev, m_Interpreter);
1026
1027 fFirstRun = false;
1028 }
1029}
1030
1031// The callback is used to update the list of globals in ROOT.
1032//
1033void TClingCallbacks::TransactionCommitted(const Transaction &T) {
1034 if (fFirstRun && T.empty())
1035 Initialize();
1036
1037 TCling__UpdateListsOnCommitted(T, m_Interpreter);
1038}
1039
1040// The callback is used to update the list of globals in ROOT.
1041//
1042void TClingCallbacks::TransactionUnloaded(const Transaction &T) {
1043 if (T.empty())
1044 return;
1045
1047}
1048
1049// The callback is used to clear the autoparsing caches.
1050//
1051void TClingCallbacks::TransactionRollback(const Transaction &T) {
1052 if (T.empty())
1053 return;
1054
1056}
1057
1058void TClingCallbacks::DefinitionShadowed(const clang::NamedDecl *D) {
1060}
1061
1062void TClingCallbacks::DeclDeserialized(const clang::Decl* D) {
1063 if (const RecordDecl* RD = dyn_cast<RecordDecl>(D)) {
1064 // FIXME: Our AutoLoading doesn't work (load the library) when the looked
1065 // up decl is found in the PCH/PCM. We have to do that extra step, which
1066 // loads the corresponding library when a decl was deserialized.
1067 //
1068 // Unfortunately we cannot do that with the current implementation,
1069 // because the library load will pull in the header files of the library
1070 // as well, even though they are in the PCH/PCM and available.
1071 (void)RD;//TCling__AutoLoadCallback(RD->getNameAsString().c_str());
1072 }
1073}
1074
1075void TClingCallbacks::LibraryLoaded(const void* dyLibHandle,
1076 llvm::StringRef canonicalName) {
1077 TCling__LibraryLoadedRTTI(dyLibHandle, canonicalName);
1078}
1079
1080void TClingCallbacks::LibraryUnloaded(const void* dyLibHandle,
1081 llvm::StringRef canonicalName) {
1082 TCling__LibraryUnloadedRTTI(dyLibHandle, canonicalName);
1083}
1084
1087}
1088
1090{
1091 // We can safely assume that if the lock exist already when we are in Cling code,
1092 // then the lock has (or should been taken) already. Any action (that caused callers
1093 // to take the lock) is halted during ProcessLine. So it is fair to unlock it.
1095}
1096
1098{
1100}
1101
1103{
1105}
1106
1108{
1110}
#define R__EXTERN
Definition DllImport.h:26
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:351
void * TCling__LockCompilationDuringUserCodeExecution()
Lock the interpreter.
Definition TCling.cxx:368
int TCling__LoadLibrary(const char *library)
Load a library.
Definition TCling.cxx:333
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:651
void TCling__TransactionRollback(const cling::Transaction &)
Definition TCling.cxx:579
const char * TCling__GetClassSharedLibs(const char *className)
int TCling__AutoParseCallback(const char *className)
Definition TCling.cxx:628
Decl * TCling__GetObjectDecl(TObject *obj)
Definition TCling.cxx:604
R__EXTERN int gDebug
void TCling__GetNormalizedContext(const ROOT::TMetaUtils::TNormalizedCtxt *&)
Definition TCling.cxx:557
void TCling__RestoreInterpreterMutex(void *state)
Re-apply the lock count delta that TCling__ResetInterpreterMutex() caused.
Definition TCling.cxx:341
int TCling__CompileMacro(const char *fileName, const char *options)
Definition TCling.cxx:644
void * TCling__ResetInterpreterMutex()
Reset the interpreter lock to the state it had before interpreter-related calls happened.
Definition TCling.cxx:360
int TCling__AutoLoadCallback(const char *className)
Definition TCling.cxx:623
void TCling__LibraryUnloadedRTTI(const void *dyLibHandle, llvm::StringRef canonicalName)
void TCling__PrintStackTrace()
Print a StackTrace!
Definition TCling.cxx:326
int TCling__IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *name)
Definition TCling.cxx:639
void TCling__UpdateListsOnUnloaded(const cling::Transaction &)
Definition TCling.cxx:569
void TCling__UnlockCompilationDuringUserCodeExecution(void *state)
Unlock the interpreter.
Definition TCling.cxx:379
static bool topmostDCIsFunction(Scope *S)
void TCling__InvalidateGlobal(const clang::Decl *)
Definition TCling.cxx:574
void TCling__LibraryLoadedRTTI(const void *dyLibHandle, llvm::StringRef canonicalName)
TObject * TCling__GetObjectAddress(const char *Name, void *&LookupCtx)
Definition TCling.cxx:600
void TCling__RestoreInterpreterMutex(void *delta)
Re-apply the lock count delta that TCling__ResetInterpreterMutex() caused.
Definition TCling.cxx:341
void TCling__TransactionRollback(const cling::Transaction &T)
Definition TCling.cxx:579
void TCling__InvalidateGlobal(const clang::Decl *D)
Definition TCling.cxx:574
void * TCling__LockCompilationDuringUserCodeExecution()
Lock the interpreter.
Definition TCling.cxx:368
void TCling__UpdateListsOnUnloaded(const cling::Transaction &T)
Definition TCling.cxx:569
void TCling__GetNormalizedContext(const ROOT::TMetaUtils::TNormalizedCtxt *&normCtxt)
Definition TCling.cxx:557
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:351
const char * TCling__GetClassSharedLibs(const char *className, bool skipCore)
Definition TCling.cxx:633
void TCling__UnlockCompilationDuringUserCodeExecution(void *)
Unlock the interpreter.
Definition TCling.cxx:379
int TCling__AutoParseCallback(const char *className)
Definition TCling.cxx:628
void TCling__LibraryUnloadedRTTI(const void *dyLibHandle, const char *canonicalName)
Definition TCling.cxx:593
void TCling__UpdateListsOnCommitted(const cling::Transaction &T, cling::Interpreter *)
Definition TCling.cxx:564
const Decl * TCling__GetObjectDecl(TObject *obj)
Definition TCling.cxx:604
int TCling__CompileMacro(const char *fileName, const char *options)
Definition TCling.cxx:644
void * TCling__ResetInterpreterMutex()
Reset the interpreter lock to the state it had before interpreter-related calls happened.
Definition TCling.cxx:360
int TCling__AutoLoadCallback(const char *className)
Definition TCling.cxx:623
void TCling__PrintStackTrace()
Print a StackTrace!
Definition TCling.cxx:326
void TCling__LibraryLoadedRTTI(const void *dyLibHandle, const char *canonicalName)
Definition TCling.cxx:583
TObject * TCling__GetObjectAddress(const char *Name, void *&LookupCtx)
Definition TCling.cxx:600
int TCling__IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *nsDecl)
Definition TCling.cxx:639
void TCling__SplitAclicMode(const char *fileName, string &mode, string &args, string &io, string &fname)
Definition TCling.cxx:651
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:34
Int_t gDebug
Definition TROOT.cxx:595
AutoloadLibraryGenerator(cling::Interpreter *interp, const TClingCallbacks &cb)
const TClingCallbacks & fCallbacks
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
const TClingCallbacks & fCallbacks
static llvm::orc::SymbolFlagsMap getSymbolFlagsMap(const llvm::orc::SymbolNameVector &Symbols)
AutoloadLibraryMU(const TClingCallbacks &cb, const std::string &Library, const llvm::orc::SymbolNameVector &Symbols)
void LibraryUnloaded(const void *dyLibHandle, llvm::StringRef canonicalName) override
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)
bool tryAutoParseInternal(llvm::StringRef Name, clang::LookupResult &R, clang::Scope *S, clang::OptionalFileEntryRef FE=std::nullopt)
void PrintStackTrace() override
bool tryInjectImplicitAutoKeyword(clang::LookupResult &R, clang::Scope *S)
clang::NamespaceDecl * fROOTSpecialNamespace
void TransactionRollback(const cling::Transaction &T) override
void TransactionCommitted(const cling::Transaction &T) override
bool FileNotFound(llvm::StringRef FileName) override
TClingCallbacks(cling::Interpreter *interp, bool hasCodeGen)
llvm::DenseMap< llvm::StringRef, clang::DeclarationName > m_LoadedModuleFiles
void DeclDeserialized(const clang::Decl *D) override
bool IsAutoLoadingEnabled() const
void DefinitionShadowed(const clang::NamedDecl *D) override
A previous definition has been shadowed; invalidate TCling' stored data about the old (global) decl.
void * EnteringUserCode() override
void UnlockCompilationDuringUserCodeExecution(void *StateInfo) override
bool LibraryLoadingFailed(const std::string &, const std::string &, bool, bool) override
void InclusionDirective(clang::SourceLocation, const clang::Token &, llvm::StringRef FileName, bool, clang::CharSourceRange, clang::OptionalFileEntryRef, llvm::StringRef, llvm::StringRef, const clang::Module *, clang::SrcMgr::CharacteristicKind) 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