[clang-tools-extra] issue-63565: community requested small QoL fix for more configurabili… (PR #108005)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 17 15:27:32 PDT 2024


================
@@ -126,11 +126,29 @@ struct Config {
     std::vector<std::string> FullyQualifiedNamespaces;
   } Style;
 
+  /// controls the completion options for argument lists.
+  enum class ArgumentListsOption {
+    /// the default value. This will imply FullPlaceholders unless overridden by
+    /// --function-arg-placeholders=0, in which case Delimiters is used.
+    /// any other use-case of --function-arg-placeholders is ignored
+    UnsetDefault = 0,
----------------
HighCommander4 wrote:

This value isn't necessary.

The way config providers interact, using `BackgroundPolicy` (an existing config option which also exists as a command-line flag) as an example:

 1. A `Config` object is created
 2. `FlagsConfigProvider` runs first. If the relevant command-line flag (`--background-index`) was specified, it [assigns](https://searchfox.org/llvm/rev/87d56c59f52d033cd7c46d769338b9c47fea4929/clang-tools-extra/clangd/tool/ClangdMain.cpp#703) the provided value to the `Index.Background` field of the `Config` object created at step (1). Note, if the flag wasn't provided, this line doesn't run at all.
 3. Then the config provider for the config file runs. The data structure representing data parsed from the file stores everything [using `std::optional`](https://searchfox.org/llvm/rev/87d56c59f52d033cd7c46d769338b9c47fea4929/clang-tools-extra/clangd/ConfigFragment.h#182), which is only populated if the key is present in the config file. That then [overwrites](https://searchfox.org/llvm/rev/87d56c59f52d033cd7c46d769338b9c47fea4929/clang-tools-extra/clangd/ConfigCompile.cpp#333) the `Index.Background` field of the same `Config` object, but once again this line only runs at all if the `optional` was populated.

As a result, no "unset" value is needed; `std::optional` takes care of that. The default value of `Completion::ArgumentLists` below -- used if neither a command-line flag nor a config file key was specified -- should be `FullPlaceholders`.

https://github.com/llvm/llvm-project/pull/108005


More information about the cfe-commits mailing list