[PATCH] D107696: [CodeComplete] Basic code completion for attribute names.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 9 08:07:41 PDT 2021


sammccall added inline comments.


================
Comment at: clang/lib/Sema/SemaCodeComplete.cpp:4357
+        continue;
+      llvm::StringRef Name = S.NormalizedFullName;
+      if (Completion == AttributeCompletion::Scope) {
----------------
aaron.ballman wrote:
> Should we also add some special handling for attributes optionally starting with double underscores? e.g., `__attribute__((const))` and `__attribute__((__const__))`` are both equally useful to complete.
> 
> Also, we should add some explicit testing for `omp::sequence` and `omp::directive` as those are handled very specially and won't appear in the parsed attribute map. I think the OpenMP code completion would be super useful, but can be handled in a follow-up if you want.
> Should we also add some special handling for attributes optionally starting with double underscores?

I think so. Two questions:
 - Do I understand right that this is "just" a matter of adding leading/trailing `__` as a second option, for AS_GNU?
 - are there similar rules for other syntaxes I've missed?

Offering both seems potentially confusing for users who don't care (especially in the case of const!). But I guess enough users will care about macros. At least in clangd the underscore versions will get ranked lower for having "internal" names though.

FWIW The no-underscores version appears to be ~3x more common (87k vs 27k hits in third-party code in google's repo). Among headers, no-underscores is "only" 2x more common (40k vs 21k). 

---

> Also, we should add some explicit testing for omp::sequence and omp::directive as those are handled very specially and won't appear in the parsed attribute map. 

Yeah, I punted on these because it seems they will need special case logic, I'll add some tests that they don't do anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107696



More information about the cfe-commits mailing list