[PATCH] D82548: [CodeComplete] Add code completion for `delete` and `default` specifier.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 30 03:46:34 PDT 2020


sammccall added inline comments.


================
Comment at: clang/include/clang/Sema/Sema.h:11968
                                     bool AfterAmpersand);
+  void CodeCompleteFunctionDeleteAndDefaultSpecifier();
 
----------------
nit: "specifier" isn't an accurate term here. I don't know that there is one, and it seems better to name the method after the situation rather than the concrete completions it might offer.

Maybe just CodeCompleteAfterFunctionEquals?


================
Comment at: clang/lib/Sema/SemaCodeComplete.cpp:6274
+  // special functions.
+  Results.AddResult("default");
+  // FIXME(liuhui): Ideally, we should only provide `delete` completion for the
----------------
I'm not sure offering default whether it's valid or not is an improvement over never offering it.

I think the following checks are easy to implement based on the `Declarator` and "good enough":
 - offered for destructors
 - offered for operator= (regardless of signature)
 - offered for constructors with 0 or 1 arguments (regardless of type)
 - optional: offered for operator<, operator>, operator==, operator<=> (if C++20 is enabled, even if this is not a member function!)

In particular, we shouldn't offer =default for arbitrary methods (consider `= 0` on a virtual method), and we shouldn't offer it for non-members (I think currently it will be offered outside class context)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82548





More information about the cfe-commits mailing list