[PATCH] D155385: [clangd] enable unused-include warnings for standard library headers
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 15 16:52:56 PDT 2023
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
Other <angle-quoted> headers are still excluded.
Repository:
rG LLVM Github Monorepo
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"
@@ -54,10 +53,6 @@
#include <vector>
namespace clang::clangd {
-
-static bool AnalyzeStdlib = false;
-void setIncludeCleanerAnalyzesStdlib(bool B) { AnalyzeStdlib = B; }
-
namespace {
bool isIgnored(llvm::StringRef HeaderPath, HeaderFilter IgnoreHeaders) {
@@ -77,7 +72,7 @@
// 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))
+ if (tooling::stdlib::Header::named(Inc.Written))
return true;
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155385.540751.patch
Type: text/x-patch
Size: 2839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230715/0cfbad0b/attachment-0001.bin>
More information about the cfe-commits
mailing list