diff --git a/interpreter/cling/include/cling/Interpreter/Interpreter.h b/interpreter/cling/include/cling/Interpreter/Interpreter.h index e08c78b72a6a0..96086cdce8679 100644 --- a/interpreter/cling/include/cling/Interpreter/Interpreter.h +++ b/interpreter/cling/include/cling/Interpreter/Interpreter.h @@ -282,9 +282,11 @@ namespace cling { ///\param[in] name - name of the function, used to find its Decl. ///\param[in] code - function definition, starting with 'extern "C"'. ///\param[in] withAccessControl - whether to enforce access restrictions. + ///\param[out] T - The cling::Transaction of the input const clang::FunctionDecl* DeclareCFunction(llvm::StringRef name, llvm::StringRef code, - bool withAccessControl); + bool withAccessControl, + Transaction*& T); ///\brief Initialize runtime and C/C++ level overrides /// diff --git a/interpreter/cling/lib/Interpreter/Interpreter.cpp b/interpreter/cling/lib/Interpreter/Interpreter.cpp index 22016dc626067..2748fdec16d10 100644 --- a/interpreter/cling/lib/Interpreter/Interpreter.cpp +++ b/interpreter/cling/lib/Interpreter/Interpreter.cpp @@ -1003,7 +1003,8 @@ namespace cling { const FunctionDecl* Interpreter::DeclareCFunction(StringRef name, StringRef code, - bool withAccessControl) { + bool withAccessControl, + Transaction*& T) { /* In CallFunc we currently always (intentionally and somewhat necessarily) always fully specify member function template, however this can lead to @@ -1092,7 +1093,7 @@ namespace cling { LangOptions& LO = const_cast(getCI()->getLangOpts()); bool savedAccessControl = LO.AccessControl; LO.AccessControl = withAccessControl; - cling::Transaction* T = 0; + T = nullptr; cling::Interpreter::CompilationResult CR = declare(code, &T); LO.AccessControl = savedAccessControl; @@ -1137,15 +1138,16 @@ namespace cling { } } - const FunctionDecl* FD = DeclareCFunction(name, code, withAccessControl); - if (!FD) + Transaction* T = nullptr; + const FunctionDecl* FD = DeclareCFunction(name, code, withAccessControl, T); + if (!FD || !T) return 0; // // Get the wrapper function pointer // from the ExecutionEngine (the JIT). // if (const llvm::GlobalValue* GV - = getLastTransaction()->getModule()->getNamedValue(name)) + = T->getModule()->getNamedValue(name)) return m_Executor->getPointerToGlobalFromJIT(*GV); return 0;