diff --git a/clang/lib/Interpreter/CodeCompletion.cpp b/clang/lib/Interpreter/CodeCompletion.cpp --- a/clang/lib/Interpreter/CodeCompletion.cpp +++ b/clang/lib/Interpreter/CodeCompletion.cpp @@ -81,8 +81,6 @@ return Comps; } - std::string AllCodeText = "void __dummy(){\n" + Buffer.str(); - // We need to wrap our input because we need `Sema::CodeCompleteOrdinaryName` // to work on code from the REPL in a statement completion context. By // default, `Sema::CodeCompleteOrdinaryName` thinks the input is a regular c++ @@ -102,6 +100,7 @@ // Since top-level expressions are not supported, `foo` should not be an // option. But in a REPL session, we should be allowed to use `foo` to make a // statement like `foo + 84;`. + std::string AllCodeText = "void __dummy(){\n" + Buffer.str(); auto Lines = std::count(AllCodeText.begin(), AllCodeText.end(), '\n') + 1;