[PATCH] D145773: [clangd] UnusedIncludes: Strict config now uses the include-cleaner-library implementation.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 10 01:36:13 PST 2023
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
This is the first step to deprecate the orginal clangd-own
implementation (the removal/cleanup will be in a followup patch).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145773
Files:
clang-tools-extra/clangd/Config.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -697,7 +697,7 @@
void foo() {}
)cpp");
Config Cfg;
- Cfg.Diagnostics.UnusedIncludes = Config::IncludesPolicy::Experiment;
+ Cfg.Diagnostics.UnusedIncludes = Config::IncludesPolicy::Strict;
WithContextValue Ctx(Config::Key, std::move(Cfg));
ParsedAST AST = TU.build();
Index: clang-tools-extra/clangd/Preamble.cpp
===================================================================
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -128,7 +128,7 @@
SourceMgr = &CI.getSourceManager();
Includes.collect(CI);
if (Config::current().Diagnostics.UnusedIncludes ==
- Config::IncludesPolicy::Experiment ||
+ Config::IncludesPolicy::Strict ||
Config::current().Diagnostics.MissingIncludes ==
Config::IncludesPolicy::Strict)
Pragmas.record(CI);
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===================================================================
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -758,17 +758,13 @@
const Config &Cfg = Config::current();
IncludeCleanerFindings Findings;
if (Cfg.Diagnostics.MissingIncludes == Config::IncludesPolicy::Strict ||
- Cfg.Diagnostics.UnusedIncludes == Config::IncludesPolicy::Experiment) {
+ Cfg.Diagnostics.UnusedIncludes == Config::IncludesPolicy::Strict) {
// will need include-cleaner results, call it once
Findings = computeIncludeCleanerFindings(AST);
}
std::vector<Diag> Result = generateUnusedIncludeDiagnostics(
- AST.tuPath(),
- Cfg.Diagnostics.UnusedIncludes == Config::IncludesPolicy::Strict
- ? computeUnusedIncludes(AST)
- : Findings.UnusedIncludes,
- Code);
+ AST.tuPath(), Findings.UnusedIncludes, Code);
llvm::move(
generateMissingIncludeDiagnostics(AST, Findings.MissingIncludes, Code),
std::back_inserter(Result));
Index: clang-tools-extra/clangd/ConfigFragment.h
===================================================================
--- clang-tools-extra/clangd/ConfigFragment.h
+++ clang-tools-extra/clangd/ConfigFragment.h
@@ -232,7 +232,6 @@
///
/// Valid values are:
/// - Strict
- /// - Experiment
/// - None
std::optional<Located<std::string>> UnusedIncludes;
Index: clang-tools-extra/clangd/ConfigCompile.cpp
===================================================================
--- clang-tools-extra/clangd/ConfigCompile.cpp
+++ clang-tools-extra/clangd/ConfigCompile.cpp
@@ -434,7 +434,9 @@
if (auto Val = compileEnum<Config::IncludesPolicy>("UnusedIncludes",
**F.UnusedIncludes)
.map("Strict", Config::IncludesPolicy::Strict)
- .map("Experiment", Config::IncludesPolicy::Experiment)
+ .map("Experiment",
+ Config::IncludesPolicy::Strict) // for backward
+ // compatibility
.map("None", Config::IncludesPolicy::None)
.value())
Out.Apply.push_back([Val](const Params &, Config &C) {
Index: clang-tools-extra/clangd/Config.h
===================================================================
--- clang-tools-extra/clangd/Config.h
+++ clang-tools-extra/clangd/Config.h
@@ -92,9 +92,6 @@
/// Diagnose missing and unused includes.
Strict,
None,
- /// The same as Strict, but using the include-cleaner library for
- /// unused includes.
- Experiment,
};
/// Controls warnings and errors when parsing code.
struct {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145773.504055.patch
Type: text/x-patch
Size: 3980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230310/e40d1019/attachment-0001.bin>
More information about the cfe-commits
mailing list