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