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