[PATCH] D131066: [clangd] Add option to disable inlay hints for init lists when building array.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 5 08:05:27 PDT 2022
sammccall added a comment.
We **have** been thinking about problems with inlay hints being verbose, and array initializers that are visible by default are clearly seen as spammy.
Thanks for sending a patch. I filed https://github.com/clangd/clangd/issues/1277 about this just now and added some thoughts.
FWIW when *not* shown by default (VSCode's offUnlessPressed) these don't seem to be spammy.
Adding a new option is always easy, but actually helps relatively few people unless we change the default.
So I think we should change the default behavior, and **consider** making it configurable if we get requests to add it back.
(I have reservations about the details of the config schema in this patch, but we can improve it if needed).
================
Comment at: clang-tools-extra/clangd/InlayHints.cpp:77
+ }
+ return false;
}
----------------
This means that both array-nested-in-struct and struct-nested-in-array will produce no hints at all.
This is probably a rare case, but IMO one that will likely benefit from designators.
The smallest behavior change to address the common case would be to drop designators that only contain a single array index.
I suppose the neatest way to achieve this is to bail out at (old) line 153:
```
if (Fields.isArray() && !BraceElidedSubobject && Prefix.empty())
// Here we'd emit only a trivial array designator.
// This isn't useful: https://github.com/clangd/clangd/issues/1277
continue;
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131066/new/
https://reviews.llvm.org/D131066
More information about the cfe-commits
mailing list