[PATCH] D155385: [clangd] enable unused-include warnings for standard library headers
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 19 14:43:59 PDT 2023
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rGe289ee99cec4: [clangd] enable unused-include warnings for standard library headers (authored by sammccall).
Changed prior to commit:
https://reviews.llvm.org/D155385?vs=540751&id=542204#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155385/new/
https://reviews.llvm.org/D155385
Files:
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/tool/ClangdMain.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
@@ -73,10 +73,6 @@
}
TEST(IncludeCleaner, StdlibUnused) {
- setIncludeCleanerAnalyzesStdlib(true);
- auto Cleanup =
- llvm::make_scope_exit([] { setIncludeCleanerAnalyzesStdlib(false); });
-
auto TU = TestTU::withCode(R"cpp(
#include <list>
#include <queue>
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===================================================================
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -273,15 +273,6 @@
init(CodeCompleteOptions().ImportInsertions),
};
-opt<bool> IncludeCleanerStdlib{
- "include-cleaner-stdlib",
- cat(Features),
- desc("Apply include-cleaner analysis to standard library headers "
- "(immature!)"),
- init(false),
- Hidden,
-};
-
opt<bool> HeaderInsertionDecorators{
"header-insertion-decorators",
cat(Features),
@@ -317,7 +308,7 @@
RetiredFlag<std::string> ClangTidyChecks("clang-tidy-checks");
RetiredFlag<bool> InlayHints("inlay-hints");
RetiredFlag<bool> FoldingRanges("folding-ranges");
-
+RetiredFlag<bool> IncludeCleanerStdlib("include-cleaner-stdlib");
opt<int> LimitResults{
"limit-results",
@@ -968,7 +959,6 @@
};
if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
Opts.Encoding = ForceOffsetEncoding;
- setIncludeCleanerAnalyzesStdlib(IncludeCleanerStdlib);
if (CheckFile.getNumOccurrences()) {
llvm::SmallString<256> Path;
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===================================================================
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -36,7 +36,6 @@
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/GenericUniformityImpl.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
@@ -55,10 +54,6 @@
#include <vector>
namespace clang::clangd {
-
-static bool AnalyzeStdlib = false;
-void setIncludeCleanerAnalyzesStdlib(bool B) { AnalyzeStdlib = B; }
-
namespace {
bool isIgnored(llvm::StringRef HeaderPath, HeaderFilter IgnoreHeaders) {
@@ -78,11 +73,8 @@
// FIXME(kirillbobyrev): We currently do not support the umbrella headers.
// System headers are likely to be standard library headers.
// Until we have good support for umbrella headers, don't warn about them.
- if (Inc.Written.front() == '<') {
- if (AnalyzeStdlib && tooling::stdlib::Header::named(Inc.Written))
- return true;
- return false;
- }
+ if (Inc.Written.front() == '<')
+ return tooling::stdlib::Header::named(Inc.Written).has_value();
assert(Inc.HeaderID);
auto HID = static_cast<IncludeStructure::HeaderID>(*Inc.HeaderID);
auto FE = AST.getSourceManager().getFileManager().getFileRef(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155385.542204.patch
Type: text/x-patch
Size: 3128 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230719/e8bd1541/attachment-0001.bin>
More information about the cfe-commits
mailing list