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" 
   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" 
   38#include "llvm/ExecutionEngine/Orc/Core.h" 
   40#include "llvm/Support/Error.h" 
   41#include "llvm/Support/FileSystem.h" 
   42#include "llvm/Support/Path.h" 
   43#include "llvm/Support/Process.h" 
   73                  std::string &args, std::string &
io, std::string &
fname);
 
   99   void materialize(std::unique_ptr<llvm::orc::MaterializationResponsibility> 
R)
 override 
  102         R->failMaterialization();
 
  115         void *
addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(
nameForDlsym);
 
  132               llvm::JITEvaluatedSymbol(llvm::pointerToJITTargetAddress(
addr), llvm::JITSymbolFlags::Exported);
 
  144            (*failingMR)->failMaterialization();
 
  150         llvm::cantFail(
R->notifyEmitted());
 
 
  154   void discard(
const llvm::orc::JITDylib &
JD, 
const llvm::orc::SymbolStringPtr &Name)
 override {}
 
  159      llvm::orc::SymbolFlagsMap map;
 
  161         map[
symbolName] = llvm::JITSymbolFlags::Exported;
 
 
 
  173   llvm::Error 
tryToGenerate(llvm::orc::LookupState &
LS, llvm::orc::LookupKind K, llvm::orc::JITDylib &
JD,
 
  175                             const llvm::orc::SymbolLookupSet &
Symbols)
 override 
  178         llvm::Error::success();
 
  184      std::unordered_map<std::string, llvm::orc::SymbolNameVector> found;
 
  185      llvm::orc::SymbolNameSet 
missing;
 
  191         llvm::orc::SymbolStringPtr 
name = 
KV.first;
 
  193         const cling::DynamicLibraryManager &
DLM = *
fInterpreter->getDynamicLibraryManager();
 
  195         std::string 
libName = 
DLM.searchLibrariesForSymbol((*name).str(),
 
  199         assert(
libName.find(
"/libNew.") == std::string::npos && 
"We must not autoload libNew!");
 
  205         assert(
libName.find(
"/libCling.") == std::string::npos && 
"Must not autoload libCling!");
 
  213      for (
auto &&
KV : found) {
 
  214         auto MU = std::make_unique<AutoloadLibraryMU>(
fCallbacks, 
KV.first, std::move(
KV.second));
 
  220         return llvm::make_error<llvm::orc::SymbolsNotFound>(
 
  221            JD.getExecutionSession().getSymbolStringPool(), std::move(
missing));
 
  223      return llvm::Error::success();
 
 
 
  231      m_Interpreter->declare(
"namespace __ROOT_SpecialObjects{}", &T);
 
  234      interp->addGenerator(std::make_unique<AutoloadLibraryGenerator>(
interp, *
this));
 
 
  242                                         const clang::Token &,
 
  243                                         llvm::StringRef FileName,
 
  245                                         clang::CharSourceRange ,
 
  246                                         clang::OptionalFileEntryRef 
FE,
 
  250                                         clang::SrcMgr::CharacteristicKind 
FileType) {
 
  257                                "Module %s resolved but not visible!", 
Imported->Name.c_str());
 
  273   bool isHeaderFile = FileName.endswith(
".h") || FileName.endswith(
".hxx") || FileName.endswith(
".hpp");
 
 
  305   std::string 
filename(FileName.str().substr(0,FileName.str().find_last_of(
'"')));
 
  309   if (
mode.length() > 0) {
 
  310      if (llvm::sys::fs::exists(
fname)) {
 
  312         std::string options = 
"k";
 
  313         if (
mode.find(
"++") != std::string::npos) options += 
"f";
 
  314         if (
mode.find(
"g")  != std::string::npos) options += 
"g";
 
  315         if (
mode.find(
"O")  != std::string::npos) options += 
"O";
 
  321         clang::Parser::ParserCurTokRestoreRAII fSavedCurToken(P);
 
  326         Tok.setKind(tok::semi);
 
 
  390   if (
m_Interpreter->getSema().getDiagnostics().hasErrorOccurred())
 
  428   std::optional<std::string> 
envUseGMI = llvm::sys::Process::GetEnv(
"ROOT_USE_GMI");
 
  451   if (
SemaR.InstantiatingSpecializations.size() > 0)
 
  464   if (Index->lookupIdentifier(Name.getAsString(), 
FoundModules)) {
 
  471               llvm::errs() << 
"Module '" << 
ModuleName << 
"' already loaded" 
  472                            << 
" for '" << Name.getAsString() << 
"'\n";
 
  478            llvm::errs() << 
"Loading '" << 
ModuleName << 
"' on demand" 
  479                         << 
" for '" << Name.getAsString() << 
"'\n";
 
 
  504   if (
Name.getNameKind() != DeclarationName::Identifier)
 
  510   if (
Loc.isValid() && 
SemaR.getSourceManager().isInSystemHeader(
Loc)) {
 
  535   R.suppressDiagnostics();
 
  538      = 
NSD->getQualifiedNameAsString() + 
"::" + 
Name.getAsString();
 
  544   clang::Scope 
S(
SemaR.TUScope, clang::Scope::DeclScope, 
SemaR.getDiagnostics());
 
  576   if (
SemaR.getSourceManager().isInSystemHeader(
Loc)) {
 
  582   for (
auto ReRD: Tag->redecls()) {
 
  584      if (
ReRD->isBeingDefined())
 
  600                                          C.getTypeDeclType(
RD),
 
  606         Tag->setHasExternalLexicalStorage(
false);
 
 
  622                                           Scope *S, clang::OptionalFileEntryRef 
FE) {
 
  637     Sema::LookupNameKind kind = 
R.getLookupKind();
 
  638     if (!(kind == Sema::LookupTagName || kind == Sema::LookupOrdinaryName
 
  639           || kind == Sema::LookupNestedNameSpecifierName
 
  640           || kind == Sema::LookupNamespaceName))
 
  647     Parser &P = 
const_cast<Parser &
>(
m_Interpreter->getParser());
 
  656           if (
R.isSingleResult()) {
 
  671        raii.fPushedDCAndS.pop();
 
  672        raii.fCleanupRAII.pop();
 
  679        std::string 
incl = 
"#include \"";
 
 
  718   if (
R.isForRedeclaration())
 
  723   const Sema::LookupNameKind 
LookupKind = 
R.getLookupKind();
 
  747#if defined(R__MUST_REVISIT) 
  748#if R__MUST_REVISIT(6,2) 
  753      if (!fgSetOfSpecials) {
 
  754         fgSetOfSpecials = 
new std::set<TObject*>;
 
  756      ((std::set<TObject*>*)fgSetOfSpecials)->insert((
TObject*)*obj);
 
  770         Expr* 
newInit = utils::Synthesize::IntegerLiteralExpr(C, (uint64_t)obj);
 
  789           = utils::Synthesize::CStyleCastPtrExpr(&
SemaR, 
QT, (uint64_t)obj);
 
  794         cling::CompilationOptions 
CO;
 
  795         CO.DeclarationExtraction = 0;
 
  796         CO.ValuePrinting = CompilationOptions::VPDisabled;
 
  797         CO.ResultEvaluation = 0;
 
  798         CO.DynamicScoping = 0;
 
  800         CO.CodeGeneration = 1;
 
  802         cling::Transaction* T = 
new cling::Transaction(
CO, 
SemaR);
 
  804         T->setState(cling::Transaction::kCompleted);
 
 
  834   clang::FunctionDecl* 
Wrapper = 
nullptr;
 
  842         if (utils::Analyze::IsWrapper(
Wrapper)) {
 
  868   Wrapper->addAttr(AnnotateAttr::CreateImplicit(C, 
"__ResolveAtRuntime"));
 
 
  883   if (
R.getLookupKind() != Sema::LookupOrdinaryName)
 
  886   if (
R.isForRedeclaration())
 
  895   const cling::CompilationOptions& 
COpts = T->getCompilationOpts();
 
  896   if (!
COpts.DynamicScoping)
 
  899   auto &
PP = 
R.getSema().PP;
 
  927         if (!
Ctx->isDependentContext())
 
 
  947   if (
R.isForRedeclaration())
 
  950   if (
R.getLookupKind() != Sema::LookupOrdinaryName)
 
  968      if (!
FD || !utils::Analyze::IsWrapper(
FD))
 
  981   if (
PP.LookAhead(0).isNot(tok::equal)) {
 
  991                                     C.getAutoType(QualType(),
 
  992                                                   clang::AutoTypeKeyword::Auto,
 
  998                              "Cannot create VarDecl");
 
 1005   Result->addAttr(AnnotateAttr::CreateImplicit(C, 
"__Auto"));
 
 1010   SemaRef.getDiagnostics().setSeverity(diag::warn_deprecated_message, diag::Severity::Warning, 
SourceLocation());
 
 1011   SemaRef.Diag(
Loc, diag::warn_deprecated_message)
 
 1012      << 
"declaration without the 'auto' keyword" << 
DC << 
Loc << FixItHint::CreateInsertion(
Loc, 
"auto ");
 
 
 1023      cling::Transaction 
TPrev((cling::CompilationOptions(), 
SemaR));
 
 1024      TPrev.append(
SemaR.getASTContext().getTranslationUnitDecl());
 
 
The file contains utilities which are foundational and could be used across the core component of ROO...
 
#define R(a, b, c, d, e, f, g, h, i)
 
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...
 
void * TCling__LockCompilationDuringUserCodeExecution()
Lock the interpreter.
 
int TCling__LoadLibrary(const char *library)
Load a library.
 
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)
 
void TCling__TransactionRollback(const cling::Transaction &)
 
const char * TCling__GetClassSharedLibs(const char *className)
 
int TCling__AutoParseCallback(const char *className)
 
Decl * TCling__GetObjectDecl(TObject *obj)
 
void TCling__GetNormalizedContext(const ROOT::TMetaUtils::TNormalizedCtxt *&)
 
void TCling__RestoreInterpreterMutex(void *state)
Re-apply the lock count delta that TCling__ResetInterpreterMutex() caused.
 
int TCling__CompileMacro(const char *fileName, const char *options)
 
void * TCling__ResetInterpreterMutex()
Reset the interpreter lock to the state it had before interpreter-related calls happened.
 
int TCling__AutoLoadCallback(const char *className)
 
void TCling__LibraryUnloadedRTTI(const void *dyLibHandle, llvm::StringRef canonicalName)
 
void TCling__PrintStackTrace()
Print a StackTrace!
 
int TCling__IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *name)
 
void TCling__UpdateListsOnUnloaded(const cling::Transaction &)
 
void TCling__UnlockCompilationDuringUserCodeExecution(void *state)
Unlock the interpreter.
 
static bool topmostDCIsFunction(Scope *S)
 
void TCling__InvalidateGlobal(const clang::Decl *)
 
void TCling__LibraryLoadedRTTI(const void *dyLibHandle, llvm::StringRef canonicalName)
 
TObject * TCling__GetObjectAddress(const char *Name, void *&LookupCtx)
 
void TCling__RestoreInterpreterMutex(void *delta)
Re-apply the lock count delta that TCling__ResetInterpreterMutex() caused.
 
void TCling__TransactionRollback(const cling::Transaction &T)
 
void TCling__InvalidateGlobal(const clang::Decl *D)
 
void * TCling__LockCompilationDuringUserCodeExecution()
Lock the interpreter.
 
void TCling__UpdateListsOnUnloaded(const cling::Transaction &T)
 
void TCling__GetNormalizedContext(const ROOT::TMetaUtils::TNormalizedCtxt *&normCtxt)
 
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...
 
void TCling__UnlockCompilationDuringUserCodeExecution(void *)
Unlock the interpreter.
 
const char * TCling__GetClassSharedLibs(const char *className)
 
int TCling__AutoParseCallback(const char *className)
 
void TCling__LibraryUnloadedRTTI(const void *dyLibHandle, const char *canonicalName)
 
void TCling__UpdateListsOnCommitted(const cling::Transaction &T, cling::Interpreter *)
 
const Decl * TCling__GetObjectDecl(TObject *obj)
 
int TCling__CompileMacro(const char *fileName, const char *options)
 
void * TCling__ResetInterpreterMutex()
Reset the interpreter lock to the state it had before interpreter-related calls happened.
 
int TCling__AutoLoadCallback(const char *className)
 
void TCling__PrintStackTrace()
Print a StackTrace!
 
void TCling__LibraryLoadedRTTI(const void *dyLibHandle, const char *canonicalName)
 
TObject * TCling__GetObjectAddress(const char *Name, void *&LookupCtx)
 
int TCling__IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl *nsDecl)
 
void TCling__SplitAclicMode(const char *fileName, string &mode, string &args, string &io, string &fname)
 
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
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
 
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 fIsAutoParsingSuspended
 
bool tryResolveAtRuntimeInternal(clang::LookupResult &R, clang::Scope *S)
 
bool findInGlobalModuleIndex(clang::DeclarationName Name, bool loadFirstMatchOnly=true)
 
bool tryAutoParseInternal(llvm::StringRef Name, clang::LookupResult &R, clang::Scope *S, clang::OptionalFileEntryRef FE=std::nullopt)
 
void PrintStackTrace() override
 
bool tryInjectImplicitAutoKeyword(clang::LookupResult &R, clang::Scope *S)
 
clang::NamespaceDecl * fROOTSpecialNamespace
 
void TransactionRollback(const cling::Transaction &T) override
 
void TransactionCommitted(const cling::Transaction &T) override
 
bool FileNotFound(llvm::StringRef FileName) override
 
TClingCallbacks(cling::Interpreter *interp, bool hasCodeGen)
 
llvm::DenseMap< llvm::StringRef, clang::DeclarationName > m_LoadedModuleFiles
 
void DeclDeserialized(const clang::Decl *D) override
 
bool IsAutoLoadingEnabled() const
 
void DefinitionShadowed(const clang::NamedDecl *D) override
A previous definition has been shadowed; invalidate TCling' stored data about the old (global) decl.
 
void * EnteringUserCode() override
 
bool fIsAutoLoadingRecursively
 
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.
 
bool ConvertEnvValueToBool(const std::string &value)
 
RooArgSet S(Args_t &&... args)
 
constexpr Double_t E()
Base of natural log: .
 
RAII used to store Parser, Sema, Preprocessor state for recursive parsing.