-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[clangd] --header-insertion
CLI fix
#146235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clangd] --header-insertion
CLI fix
#146235
Conversation
In PR llvm#128503, CLI option overwrites only if it was set to `never`. This commit ensures that CLI options always overwrite any config option.
@llvm/pr-subscribers-clang-tools-extra Author: Mythreya (MythreyaK) ChangesIn PR #128503, CLI option overwrites only if it was set to Thanks to the fix from @HighCommander4 here! Full diff: https://github.com/llvm/llvm-project/pull/146235.diff 1 Files Affected:
diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index b11d194da04db..f287439f10cab 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -668,7 +668,6 @@ class FlagsConfigProvider : public config::Provider {
std::optional<Config::ExternalIndexSpec> IndexSpec;
std::optional<Config::BackgroundPolicy> BGPolicy;
std::optional<Config::ArgumentListsPolicy> ArgumentLists;
- std::optional<Config::HeaderInsertionPolicy> HeaderInsertionPolicy;
// If --compile-commands-dir arg was invoked, check value and override
// default path.
@@ -713,11 +712,6 @@ class FlagsConfigProvider : public config::Provider {
BGPolicy = Config::BackgroundPolicy::Skip;
}
- // If CLI has set never, use that regardless of what the config files have
- if (HeaderInsertion == Config::HeaderInsertionPolicy::NeverInsert) {
- HeaderInsertionPolicy = Config::HeaderInsertionPolicy::NeverInsert;
- }
-
if (std::optional<bool> Enable = shouldEnableFunctionArgSnippets()) {
ArgumentLists = *Enable ? Config::ArgumentListsPolicy::FullPlaceholders
: Config::ArgumentListsPolicy::Delimiters;
@@ -732,8 +726,8 @@ class FlagsConfigProvider : public config::Provider {
C.Index.Background = *BGPolicy;
if (ArgumentLists)
C.Completion.ArgumentLists = *ArgumentLists;
- if (HeaderInsertionPolicy)
- C.Completion.HeaderInsertion = *HeaderInsertionPolicy;
+ if (HeaderInsertion.getNumOccurrences())
+ C.Completion.HeaderInsertion = HeaderInsertion;
if (AllScopesCompletion.getNumOccurrences())
C.Completion.AllScopes = AllScopesCompletion;
|
@llvm/pr-subscribers-clangd Author: Mythreya (MythreyaK) ChangesIn PR #128503, CLI option overwrites only if it was set to Thanks to the fix from @HighCommander4 here! Full diff: https://github.com/llvm/llvm-project/pull/146235.diff 1 Files Affected:
diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index b11d194da04db..f287439f10cab 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -668,7 +668,6 @@ class FlagsConfigProvider : public config::Provider {
std::optional<Config::ExternalIndexSpec> IndexSpec;
std::optional<Config::BackgroundPolicy> BGPolicy;
std::optional<Config::ArgumentListsPolicy> ArgumentLists;
- std::optional<Config::HeaderInsertionPolicy> HeaderInsertionPolicy;
// If --compile-commands-dir arg was invoked, check value and override
// default path.
@@ -713,11 +712,6 @@ class FlagsConfigProvider : public config::Provider {
BGPolicy = Config::BackgroundPolicy::Skip;
}
- // If CLI has set never, use that regardless of what the config files have
- if (HeaderInsertion == Config::HeaderInsertionPolicy::NeverInsert) {
- HeaderInsertionPolicy = Config::HeaderInsertionPolicy::NeverInsert;
- }
-
if (std::optional<bool> Enable = shouldEnableFunctionArgSnippets()) {
ArgumentLists = *Enable ? Config::ArgumentListsPolicy::FullPlaceholders
: Config::ArgumentListsPolicy::Delimiters;
@@ -732,8 +726,8 @@ class FlagsConfigProvider : public config::Provider {
C.Index.Background = *BGPolicy;
if (ArgumentLists)
C.Completion.ArgumentLists = *ArgumentLists;
- if (HeaderInsertionPolicy)
- C.Completion.HeaderInsertion = *HeaderInsertionPolicy;
+ if (HeaderInsertion.getNumOccurrences())
+ C.Completion.HeaderInsertion = HeaderInsertion;
if (AllScopesCompletion.getNumOccurrences())
C.Completion.AllScopes = AllScopesCompletion;
|
I tested these locally and seems to work as expected. Please do double-check, just in case I missed something!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/23/builds/11723 Here is the relevant piece of the build log for the reference
|
…erInsertion` (llvm#146235) In PR llvm#128503, the CLI option would take precedence over the config option only if it was set to `never`. This commit ensures the CLI option always takes precedence over the config option.
…erInsertion` (llvm#146235) In PR llvm#128503, the CLI option would take precedence over the config option only if it was set to `never`. This commit ensures the CLI option always takes precedence over the config option.
In PR #128503, CLI option overwrites only if it was set to
never
. This commit ensures that CLI options always overwrite any config option.Thanks to the fix from @HighCommander4 here!