diff --git a/interpreter/cling/include/cling/Interpreter/Interpreter.h b/interpreter/cling/include/cling/Interpreter/Interpreter.h index f8a5d14ef75c7..668389928c519 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 5ebe4cbc5462a..4a3e2914a8758 100644 --- a/interpreter/cling/lib/Interpreter/Interpreter.cpp +++ b/interpreter/cling/lib/Interpreter/Interpreter.cpp @@ -1020,7 +1020,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 @@ -1109,7 +1110,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; @@ -1154,15 +1155,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;