[all-commits] [llvm/llvm-project] 79af92: Reland "[clang-repl] support code completion at a ...
Fred Fu via All-commits
all-commits at lists.llvm.org
Mon Aug 28 13:12:21 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 79af92bb99dd86cc36d6a81066063fb9cd77c78a
https://github.com/llvm/llvm-project/commit/79af92bb99dd86cc36d6a81066063fb9cd77c78a
Author: Fred Fu <moonsolo at gmail.com>
Date: 2023-08-28 (Mon, 28 Aug 2023)
Changed paths:
M clang-tools-extra/clangd/CodeComplete.cpp
M clang/include/clang/Frontend/ASTUnit.h
A clang/include/clang/Interpreter/CodeCompletion.h
M clang/include/clang/Sema/CodeCompleteConsumer.h
M clang/include/clang/Sema/Sema.h
M clang/lib/Frontend/ASTUnit.cpp
M clang/lib/Interpreter/CMakeLists.txt
A clang/lib/Interpreter/CodeCompletion.cpp
M clang/lib/Interpreter/IncrementalParser.cpp
M clang/lib/Interpreter/IncrementalParser.h
M clang/lib/Interpreter/Interpreter.cpp
M clang/lib/Parse/ParseDecl.cpp
M clang/lib/Parse/Parser.cpp
M clang/lib/Sema/CodeCompleteConsumer.cpp
M clang/lib/Sema/SemaCodeComplete.cpp
A clang/test/CodeCompletion/incrememal-mode-completion-no-error.cpp
A clang/test/CodeCompletion/incremental-top-level.cpp
M clang/tools/clang-repl/ClangRepl.cpp
M clang/tools/libclang/CIndexCodeCompletion.cpp
M clang/unittests/Interpreter/CMakeLists.txt
A clang/unittests/Interpreter/CodeCompletionTest.cpp
Log Message:
-----------
Reland "[clang-repl] support code completion at a REPL."
Original commit message:
"
This patch enabled code completion for ClangREPL. The feature was built upon
three existing Clang components: a list completer for LineEditor, a
CompletionConsumer from SemaCodeCompletion, and the ASTUnit::codeComplete method.
The first component serves as the main entry point of handling interactive inputs.
Because a completion point for a compiler instance has to be unchanged once it
is set, an incremental compiler instance is created for each code
completion. Such a compiler instance carries over AST context source from the
main interpreter compiler in order to obtain declarations or bindings from
previous input in the same REPL session.
The most important API codeComplete in Interpreter/CodeCompletion is a thin
wrapper that calls with ASTUnit::codeComplete with necessary arguments, such as
a code completion point and a ReplCompletionConsumer, which communicates
completion results from SemaCodeCompletion back to the list completer for the
REPL.
In addition, PCC_TopLevelOrExpression and CCC_TopLevelOrExpression` top levels
were added so that SemaCodeCompletion can treat top level statements like
expression statements at the REPL. For example,
clang-repl> int foo = 42;
clang-repl> f<tab>
>From a parser's persective, the cursor is at a top level. If we used code
completion without any changes, PCC_Namespace would be supplied to
Sema::CodeCompleteOrdinaryName, and thus the completion results would not
include foo.
Currently, the way we use PCC_TopLevelOrExpression and
CCC_TopLevelOrExpression is no different from the way we use PCC_Statement
and CCC_Statement respectively.
Differential revision: https://reviews.llvm.org/D154382
"
The new patch also fixes clangd and several memory issues that the bots reported
and upload the missing files.
More information about the All-commits
mailing list