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