nridge added a comment.

Thanks for the patch!

The test looks good to me.

As for the fix, I wonder if it would make sense to implement it in the Sema 
layer rather than in clangd. For example, we could give 
`clang::CodeCompletionResult` a new flag 
<https://github.com/clangd/vscode-clangd/issues/406> called something like 
`CanBeCall`, which, for a completion result that refers to a function, is set 
to true (by the code that creates the CodeCompletionResult, in 
SemaCodeComplete.cpp) if the use of the function may be a call, and false if it 
cannot.

Then clangd can check this flag, and clear the snippet suffix (or even better, 
not build it in the first place) if the value is false.

I think this approach could have a couple of advantages:

1. By placing the logic into libSema, other consumers of the Sema completion 
layer, besides clangd, could benefit from it as well. (A couple of other 
consumers that I'm aware of are libclang 
<https://clang.llvm.org/doxygen/group__CINDEX__CODE__COMPLET.html> and cling 
<https://root.cern/cling/>.)
2. Because the logic now resides inside `Sema` itself, if we make enhancements 
to the heuristics for computing `CanBeCall` that require additional state 
(besides `CurContext`), we can just use them in place rather than having to 
propagate them into places like clangd's `CodeCompletionBuilder`.

What do you think?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137040/new/

https://reviews.llvm.org/D137040

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to