From c05dde2f969a1a9012c192ccda332dd093606fef Mon Sep 17 00:00:00 2001 From: Vassil Vassilev <vasil.georgiev.vasilev@cern.ch> Date: Thu, 25 Oct 2012 09:17:45 +0000 Subject: [PATCH] Add a way to disable the complaints of HandleMissing symbol, when it is ok for the symbol to be missing. git-svn-id: http://root.cern.ch/svn/root/trunk@46795 27541ba8-7e3a-0410-8455-c3a389f83636 --- interpreter/cling/include/cling/Interpreter/Interpreter.h | 2 ++ interpreter/cling/lib/Interpreter/ExecutionContext.cpp | 5 +++++ interpreter/cling/lib/Interpreter/ExecutionContext.h | 6 ++++++ interpreter/cling/lib/Interpreter/Interpreter.cpp | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/interpreter/cling/include/cling/Interpreter/Interpreter.h b/interpreter/cling/include/cling/Interpreter/Interpreter.h index 549d9e225d6..b724432485a 100644 --- a/interpreter/cling/include/cling/Interpreter/Interpreter.h +++ b/interpreter/cling/include/cling/Interpreter/Interpreter.h @@ -403,7 +403,9 @@ namespace cling { llvm::Module* getModule() const; + //FIXME: This must be in InterpreterCallbacks. void installLazyFunctionCreator(void* (*fp)(const std::string&)); + void enableLazyFunctionCreator(bool enable = true); //FIXME: Terrible hack to let the IncrementalParser run static inits on // transaction completed. diff --git a/interpreter/cling/lib/Interpreter/ExecutionContext.cpp b/interpreter/cling/lib/Interpreter/ExecutionContext.cpp index 75085208c9f..838e4f812d2 100644 --- a/interpreter/cling/lib/Interpreter/ExecutionContext.cpp +++ b/interpreter/cling/lib/Interpreter/ExecutionContext.cpp @@ -58,6 +58,8 @@ std::set<std::string> ExecutionContext::m_unresolvedSymbols; std::vector<ExecutionContext::LazyFunctionCreatorFunc_t> ExecutionContext::m_lazyFuncCreator; +bool ExecutionContext::m_LazyFuncCreatorEnabled = true; + ExecutionContext::ExecutionContext(): m_engine(0), m_RunningStaticInits(false), @@ -115,6 +117,9 @@ void* ExecutionContext::HandleMissingFunction(const std::string& mangled_name) void* ExecutionContext::NotifyLazyFunctionCreators(const std::string& mangled_name) { + if (!m_LazyFuncCreatorEnabled) + return 0; + for (std::vector<LazyFunctionCreatorFunc_t>::iterator it = m_lazyFuncCreator.begin(), et = m_lazyFuncCreator.end(); it != et; ++it) { diff --git a/interpreter/cling/lib/Interpreter/ExecutionContext.h b/interpreter/cling/lib/Interpreter/ExecutionContext.h index 3356d08d646..d64c3a17e3e 100644 --- a/interpreter/cling/lib/Interpreter/ExecutionContext.h +++ b/interpreter/cling/lib/Interpreter/ExecutionContext.h @@ -35,6 +35,9 @@ namespace cling { ~ExecutionContext(); void installLazyFunctionCreator(LazyFunctionCreatorFunc_t fp); + void enableLazyFunctionCreator(bool enabled = true) { + m_LazyFuncCreatorEnabled = enabled; + } void runStaticInitializersOnce(llvm::Module* m); void runStaticDestructorsOnce(llvm::Module* m); @@ -83,6 +86,9 @@ namespace cling { static std::set<std::string> m_unresolvedSymbols; static std::vector<LazyFunctionCreatorFunc_t> m_lazyFuncCreator; + ///\ Whether or not the function creator to be queried. + static bool m_LazyFuncCreatorEnabled; + llvm::ExecutionEngine* m_engine; // Owned by JIT /// \brief prevent the recursive run of the static inits diff --git a/interpreter/cling/lib/Interpreter/Interpreter.cpp b/interpreter/cling/lib/Interpreter/Interpreter.cpp index f85ddf2afee..9c6ca25b926 100644 --- a/interpreter/cling/lib/Interpreter/Interpreter.cpp +++ b/interpreter/cling/lib/Interpreter/Interpreter.cpp @@ -595,6 +595,10 @@ namespace cling { m_ExecutionContext->installLazyFunctionCreator(fp); } + void Interpreter::enableLazyFunctionCreator(bool enabled /*= true*/) { + m_ExecutionContext->enableLazyFunctionCreator(enabled); + } + StoredValueRef Interpreter::Evaluate(const char* expr, DeclContext* DC, bool ValuePrinterReq) { Sema& TheSema = getCI()->getSema(); -- GitLab