[PATCH] D155370: [CodeComplete] Don't emit parameters when not FunctionCanBeCall
Younan Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 15 17:42:24 PDT 2023
zyounan created this revision.
zyounan added reviewers: nridge, tom-anders, sammccall.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
zyounan added a comment.
zyounan updated this revision to Diff 540687.
zyounan published this revision for review.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.
Changing the code completion string to `RK_Pattern` makes the completion clearer, in a way that showing candidates with signatures in the completion items if `FunctionCanBeCall` while a mere name otherwise.
F28256820: image.png <https://reviews.llvm.org/F28256820>
F28256841: image.png <https://reviews.llvm.org/F28256841>
(Comparing to that we always show signatures even if no parameters are produced when hit the item.)
F28256859: image.png <https://reviews.llvm.org/F28256859> -> F28256863: image.png <https://reviews.llvm.org/F28256863>
---
P.S. Despite the fact that I changed many associated tests, I still hope people don't rely on the former behavior so that this patch could be marked as NFC. :D
I discovered that patch when trying to figure out why clangd doesn't complete function parameters for members in global scope while it produces parameters when I'm inside a call expression. Regard to the heuristic itself, it's currently a bit inconvenient that I have to switch headers and sources back and forth and do copy-pastes when I'm writing member function definitions outside of a class. I think we could be more lenient here e.g., don't set the flag on if we're in the global scope. What do you guys think? (I'm working on another follow-up patch to address this, although it is not strightforward to tell which scope the building Declarator is in inside Sema. )
zyounan added a comment.
Format
This tries to avoid extra calculations in D137040 <https://reviews.llvm.org/D137040>.
In that patch the extra completion strings were dropped at the client
site, after function parameters became available, to implement the
heuristic. However, we can make the process a bit more terse. In the
context where a call isn't required, we could teach the Sema to emit
the completion string without additional parameters by changing the Decl
to a Pattern with the function name.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155370
Files:
clang-tools-extra/clangd/CodeComplete.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/member-access.cpp
clang/test/Index/complete-qualified.cpp
clang/unittests/Sema/CodeCompleteTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155370.540687.patch
Type: text/x-patch
Size: 4973 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230716/3e632857/attachment.bin>
More information about the cfe-commits
mailing list