Logo ROOT  
Reference Guide
TClingCallbacks.h
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-2013, 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 "cling/Interpreter/InterpreterCallbacks.h"
13
14#include <stack>
15
16namespace clang {
17 class Decl;
18 class DeclarationName;
19 class LookupResult;
20 class NamespaceDecl;
21 class Scope;
22 class TagDecl;
23 class Token;
24 class FileEntry;
25 class Module;
26}
27
28namespace cling {
29 class Interpreter;
30 class Transaction;
31}
32
33namespace llvm {
34 class StringRef;
35}
36
37// The callbacks are used to update the list of globals in ROOT.
38//
39class TClingCallbacks : public cling::InterpreterCallbacks {
40private:
41 void *fLastLookupCtx = nullptr;
42 clang::NamespaceDecl *fROOTSpecialNamespace = nullptr;
43 bool fFirstRun = true;
44 bool fIsAutoLoading = false;
47 bool fPPOldFlag = false;
48 bool fPPChanged = false;
49 bool fIsCodeGening = false;
50 bool fIsLoadingModule = false;
51
52public:
53 TClingCallbacks(cling::Interpreter* interp, bool hasCodeGen);
54
56
57 void Initialize();
58
59 void SetAutoLoadingEnabled(bool val = true) { fIsAutoLoading = val; }
61
62 void SetAutoParsingSuspended(bool val = true) { fIsAutoParsingSuspended = val; }
64
65 bool LibraryLoadingFailed(const std::string &, const std::string &, bool, bool) override;
66
67 void InclusionDirective(clang::SourceLocation /*HashLoc*/, const clang::Token & /*IncludeTok*/,
68 llvm::StringRef FileName, bool /*IsAngled*/, clang::CharSourceRange /*FilenameRange*/,
69 const clang::FileEntry * /*File*/, llvm::StringRef /*SearchPath*/,
70 llvm::StringRef /*RelativePath*/, const clang::Module * /*Imported*/) override;
71
72 // Preprocessor callbacks used to handle special cases like for example:
73 // #include "myMacro.C+"
74 //
75 bool FileNotFound(llvm::StringRef FileName, llvm::SmallVectorImpl<char> &RecoveryPath) override;
76
77 bool LookupObject(clang::LookupResult &R, clang::Scope *S) override;
78 bool LookupObject(const clang::DeclContext *DC, clang::DeclarationName Name) override;
79 bool LookupObject(clang::TagDecl *Tag) override;
80
81 // The callback is used to update the list of globals in ROOT.
82 //
83 void TransactionCommitted(const cling::Transaction &T) override;
84
85 // The callback is used to inform ROOT when cling started code generation.
86 //
87 void TransactionCodeGenStarted(const cling::Transaction &T) override
88 {
89 assert(!fIsCodeGening);
90 fIsCodeGening = true;
91 }
92
93 // The callback is used to inform ROOT when cling finished code generation.
94 //
95 void TransactionCodeGenFinished(const cling::Transaction &T) override
96 {
97 assert(fIsCodeGening);
98 fIsCodeGening = false;
99 }
100
101 // The callback is used to update the list of globals in ROOT.
102 //
103 void TransactionUnloaded(const cling::Transaction &T) override;
104
105 // The callback is used to clear the autoparsing caches.
106 //
107 void TransactionRollback(const cling::Transaction &T) override;
108
109 ///\brief A previous definition has been shadowed; invalidate TCling' stored
110 /// data about the old (global) decl.
111 void DefinitionShadowed(const clang::NamedDecl *D) override;
112
113 // Used to inform client about a new decl read by the ASTReader.
114 //
115 void DeclDeserialized(const clang::Decl *D) override;
116
117 void LibraryLoaded(const void *dyLibHandle, llvm::StringRef canonicalName) override;
118 void LibraryUnloaded(const void *dyLibHandle, llvm::StringRef canonicalName) override;
119
120 void PrintStackTrace() override;
121
122 void *EnteringUserCode() override;
123 void ReturnedFromUserCode(void *stateInfo) override;
125 void UnlockCompilationDuringUserCodeExecution(void *StateInfo) override;
126
127private:
128 bool tryAutoParseInternal(llvm::StringRef Name, clang::LookupResult &R,
129 clang::Scope *S, const clang::FileEntry* FE = 0);
130 bool tryFindROOTSpecialInternal(clang::LookupResult &R, clang::Scope *S);
131 bool tryResolveAtRuntimeInternal(clang::LookupResult &R, clang::Scope *S);
132 bool shouldResolveAtRuntime(clang::LookupResult &R, clang::Scope *S);
133 bool tryInjectImplicitAutoKeyword(clang::LookupResult &R, clang::Scope *S);
134 bool findInGlobalModuleIndex(clang::DeclarationName Name, bool loadFirstMatchOnly = true);
135};
void TransactionCodeGenFinished(const cling::Transaction &T) override
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 fIsAutoParsingSuspended
bool IsAutoParsingSuspended()
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)
bool IsAutoLoadingEnabled()
clang::NamespaceDecl * fROOTSpecialNamespace
void TransactionRollback(const cling::Transaction &T) override
void TransactionCommitted(const cling::Transaction &T) override
TClingCallbacks(cling::Interpreter *interp, bool hasCodeGen)
void DeclDeserialized(const clang::Decl *D) 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
bool fIsAutoLoadingRecursively
void UnlockCompilationDuringUserCodeExecution(void *StateInfo) override
void SetAutoParsingSuspended(bool val=true)
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
void SetAutoLoadingEnabled(bool val=true)
bool shouldResolveAtRuntime(clang::LookupResult &R, clang::Scope *S)
bool LookupObject(const clang::DeclContext *DC, clang::DeclarationName Name) override
void TransactionUnloaded(const cling::Transaction &T) override
void TransactionCodeGenStarted(const cling::Transaction &T) override
void InclusionDirective(clang::SourceLocation, const clang::Token &, llvm::StringRef FileName, bool, clang::CharSourceRange, const clang::FileEntry *, llvm::StringRef, llvm::StringRef, const clang::Module *) override
double T(double x)
Definition: ChebyshevPol.h:34
RooArgSet S(const RooAbsArg &v1)
Definition: TString.h:845
const char * Name
Definition: TXMLSetup.cxx:66