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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 9 10:57:59 PDT 2021


aaron.ballman added a comment.

In D107696#2934881 <https://reviews.llvm.org/D107696#2934881>, @sammccall wrote:

> Thanks, I know what to do next!
>
> While I have you here, any thoughts on future patches:
>
>> Only the bare name is completed, with no args.
>> For args to be useful we need arg names. These *are* in the tablegen but
>> not currently emitted in usable form, so left this as future work.
>
> How do you feel about this plan:
>
> - add an `ArrayRef<const char*>` to `ParsedAttrInfo` for this purpose? (Or a null-terminated `char**` if we're worried about sizeof).
> - It'd be populated by the names of the tablegen `Args`.
> - If empty, completions render as now. If nonempty they render as `foo(bar, baz)` where `bar` and `baz` are placeholders - just like function args but without types.

I think args may be... interesting. Many attributes have arguments that can't really be completed because they're an integer, a string literal, whatever. But there are still quite a few that accept an enumeration, and those enumeration values would be super useful to autocomplete. And still others have arbitrary expressions where autocompletion would be fantastic (like `diagnose_if`).

I'm not certain that an `ArrayRef` would be sufficient to the task, but I do think we could probably generate something out of ClangAttrEmitter.cpp to help on an attribute-by-attribute basis.

>> There's also no filtering by langopts: this is because currently the
>> only way of checking is to try to produce diagnostics, which requires a
>> valid ParsedAttr which is hard to get.
>
> And for this, WDYT about making `diagLangOpts` non-virtual and moving the attr-specific test into a `virtual bool supportsLangOpts()` function with no side-effects?

I think that'd work fine -- it'll break plugin authors, but that should hopefully be a loud break when they go to recompile their plugin.


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