From 8a646b6dbadaea789d433b2b487298345e495867 Mon Sep 17 00:00:00 2001 From: CristinaCristescu Date: Thu, 7 Jul 2016 09:12:57 +0200 Subject: [PATCH] Pass the parent's interpreter llvmdir to the child interpreter. --- lib/Interpreter/Interpreter.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Interpreter/Interpreter.cpp b/lib/Interpreter/Interpreter.cpp index e54f25b4..9cda15fb 100644 --- a/lib/Interpreter/Interpreter.cpp +++ b/lib/Interpreter/Interpreter.cpp @@ -1444,7 +1444,13 @@ namespace cling { std::vector& DisplayCompletions) const { //Get the results const char * const argV = "cling"; - cling::Interpreter CodeCompletionInterp(*this, 1, &argV); + std::string llvmdir = this->getCI()->getHeaderSearchOpts().ResourceDir; + std::string extra_part = "/lib/clang/3.9.0"; + std::string::size_type i = llvmdir.find(extra_part); + if (i != std::string::npos) + llvmdir.erase(i, extra_part.length()); + + cling::Interpreter CodeCompletionInterp(*this, 1, &argV, llvmdir.c_str()); // Create the CodeCompleteConsumer with InterpreterCallbacks // from the parent interpreter and set the consumer for the child @@ -1463,6 +1469,8 @@ namespace cling { auto Owner = this->getCI()->getSema().getDiagnostics().takeClient(); auto Client = this->getCI()->getSema().getDiagnostics().getClient(); this->getCI()->getSema().getDiagnostics().setClient(ignoringDiagConsumer, false); + // The child will desirialize decls from *this, we need a transaction + PushTransactionRAII RAII(this); CodeCompletionInterp.codeComplete(Line, Cursor); callbacks->GetCompletionResults(&CodeCompletionInterp, DisplayCompletions);