https://github.com/vvd170501 updated
https://github.com/llvm/llvm-project/pull/87208
>From 35db92dfd0c2b43fc7afde5b093598763c4b8c89 Mon Sep 17 00:00:00 2001
From: Vadim Dudkin
Date: Mon, 1 Apr 2024 02:26:14 +0300
Subject: [PATCH 1/6] Add config option to analyze unused system headers
---
https://github.com/kadircet approved this pull request.
thanks a lot, LGTM!
it'd be great if you can also follow up with a change to
https://github.com/llvm/clangd-www/blob/main/config.md
https://github.com/llvm/llvm-project/pull/87208
___
@@ -68,24 +68,32 @@ bool isIgnored(llvm::StringRef HeaderPath, HeaderFilter
IgnoreHeaders) {
}
bool mayConsiderUnused(const Inclusion , ParsedAST ,
- const include_cleaner::PragmaIncludes *PI) {
+ const
@@ -135,6 +135,21 @@ TEST(IncludeCleaner, GetUnusedHeaders) {
Pointee(writtenInclusion("\"dir/unused.h\"";
}
+TEST(IncludeCleaner, SystemUnusedHeaders) {
+ auto TU = TestTU::withCode(R"cpp(
+#include
+#include
+SystemClass x;
+
@@ -135,6 +135,21 @@ TEST(IncludeCleaner, GetUnusedHeaders) {
Pointee(writtenInclusion("\"dir/unused.h\"";
}
+TEST(IncludeCleaner, SystemUnusedHeaders) {
+ auto TU = TestTU::withCode(R"cpp(
+#include
+#include
+SystemClass x;
+
@@ -572,32 +572,43 @@ struct FragmentCompiler {
#else
static llvm::Regex::RegexFlags Flags = llvm::Regex::NoFlags;
#endif
-auto Filters = std::make_shared>();
-for (auto : F.IgnoreHeader) {
- // Anchor on the right.
- std::string AnchoredPattern = "(" +
@@ -572,32 +572,43 @@ struct FragmentCompiler {
#else
static llvm::Regex::RegexFlags Flags = llvm::Regex::NoFlags;
#endif
-auto Filters = std::make_shared>();
-for (auto : F.IgnoreHeader) {
- // Anchor on the right.
- std::string AnchoredPattern = "(" +
https://github.com/vvd170501 updated
https://github.com/llvm/llvm-project/pull/87208
>From 35db92dfd0c2b43fc7afde5b093598763c4b8c89 Mon Sep 17 00:00:00 2001
From: Vadim Dudkin
Date: Mon, 1 Apr 2024 02:26:14 +0300
Subject: [PATCH 1/4] Add config option to analyze unused system headers
---
@@ -135,6 +135,21 @@ TEST(IncludeCleaner, GetUnusedHeaders) {
Pointee(writtenInclusion("\"dir/unused.h\"";
}
+TEST(IncludeCleaner, SystemUnusedHeaders) {
+ auto TU = TestTU::withCode(R"cpp(
+#include
+#include
+SystemClass x;
+
@@ -135,6 +135,21 @@ TEST(IncludeCleaner, GetUnusedHeaders) {
Pointee(writtenInclusion("\"dir/unused.h\"";
}
+TEST(IncludeCleaner, SystemUnusedHeaders) {
+ auto TU = TestTU::withCode(R"cpp(
+#include
+#include
+SystemClass x;
+
@@ -572,32 +572,43 @@ struct FragmentCompiler {
#else
static llvm::Regex::RegexFlags Flags = llvm::Regex::NoFlags;
#endif
-auto Filters = std::make_shared>();
-for (auto : F.IgnoreHeader) {
- // Anchor on the right.
- std::string AnchoredPattern = "(" +
@@ -572,32 +572,43 @@ struct FragmentCompiler {
#else
static llvm::Regex::RegexFlags Flags = llvm::Regex::NoFlags;
#endif
-auto Filters = std::make_shared>();
-for (auto : F.IgnoreHeader) {
- // Anchor on the right.
- std::string AnchoredPattern = "(" +
kadircet wrote:
thanks for the patch! this definitely LGTM at high level.
as you folks also pointed out we don't want to surface analysis for angled
includes in general, as include-cleaner doesn't have support for system headers
yet (we wanted to have something similar to Stdlib includes,
@@ -135,6 +135,21 @@ TEST(IncludeCleaner, GetUnusedHeaders) {
Pointee(writtenInclusion("\"dir/unused.h\"";
}
+TEST(IncludeCleaner, SystemUnusedHeaders) {
+ auto TU = TestTU::withCode(R"cpp(
+#include
+#include
+SystemClass x;
+
@@ -572,32 +572,43 @@ struct FragmentCompiler {
#else
static llvm::Regex::RegexFlags Flags = llvm::Regex::NoFlags;
#endif
-auto Filters = std::make_shared>();
-for (auto : F.IgnoreHeader) {
- // Anchor on the right.
- std::string AnchoredPattern = "(" +
@@ -62,15 +64,6 @@ issueIncludeCleanerDiagnostics(ParsedAST ,
llvm::StringRef Code,
const ThreadsafeFS ,
HeaderFilter IgnoreHeader = {});
-/// Affects whether standard library includes should be considered for
@@ -114,6 +114,7 @@ struct Config {
/// these regexes.
struct {
std::vector> IgnoreHeader;
+ bool AnalyzeSystemHeaders = false;
kadircet wrote:
can you move the comment about regexes near `IgnoreHeader`.
Also I think
@@ -572,32 +572,43 @@ struct FragmentCompiler {
#else
static llvm::Regex::RegexFlags Flags = llvm::Regex::NoFlags;
#endif
-auto Filters = std::make_shared>();
-for (auto : F.IgnoreHeader) {
- // Anchor on the right.
- std::string AnchoredPattern = "(" +
@@ -254,6 +254,10 @@ struct Fragment {
/// unused or missing. These can match any suffix of the header file in
/// question.
std::vector> IgnoreHeader;
+
+ /// If false (default), unused system headers will be ignored.
+ /// Standard library headers
@@ -135,6 +135,21 @@ TEST(IncludeCleaner, GetUnusedHeaders) {
Pointee(writtenInclusion("\"dir/unused.h\"";
}
+TEST(IncludeCleaner, SystemUnusedHeaders) {
+ auto TU = TestTU::withCode(R"cpp(
+#include
+#include
+SystemClass x;
+
https://github.com/kadircet requested changes to this pull request.
https://github.com/llvm/llvm-project/pull/87208
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/kadircet edited
https://github.com/llvm/llvm-project/pull/87208
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/zyn0217 commented:
I think I'm fine with it as-is, but we probably need include-cleaner folks to
approve it. (That means you probably have to wait a few more weeks for them,
unfortunately.)
https://github.com/llvm/llvm-project/pull/87208
vvd170501 wrote:
Ping
https://github.com/llvm/llvm-project/pull/87208
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
vvd170501 wrote:
Ping. Can anyone review this, please?
https://github.com/llvm/llvm-project/pull/87208
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
HighCommander4 wrote:
> @HighCommander4 Ping. Could you review this PR or suggest other reviewers,
> please?
I'm not very familiar with include-cleaner, but I added some reviewers who are.
https://github.com/llvm/llvm-project/pull/87208
___
vvd170501 wrote:
@HighCommander4 Ping. Could you review this PR or suggest other reviewers,
please?
https://github.com/llvm/llvm-project/pull/87208
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
vvd170501 wrote:
Ping
https://github.com/llvm/llvm-project/pull/87208
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
HighCommander4 wrote:
Related issue: https://github.com/clangd/clangd/issues/1774
https://github.com/llvm/llvm-project/pull/87208
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
llvmbot wrote:
@llvm/pr-subscribers-clangd
Author: Vadim D. (vvd170501)
Changes
This PR adds a new `AnalyzeSystemHeaders` option to `Includes` section of
clangd config. This option will allow to mark all system headers, not just the
ones from standard library, as unused.
Why this
https://github.com/vvd170501 ready_for_review
https://github.com/llvm/llvm-project/pull/87208
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -62,15 +64,6 @@ issueIncludeCleanerDiagnostics(ParsedAST ,
llvm::StringRef Code,
const ThreadsafeFS ,
HeaderFilter IgnoreHeader = {});
-/// Affects whether standard library includes should be considered for
@@ -62,15 +64,6 @@ issueIncludeCleanerDiagnostics(ParsedAST ,
llvm::StringRef Code,
const ThreadsafeFS ,
HeaderFilter IgnoreHeader = {});
-/// Affects whether standard library includes should be considered for
https://github.com/vvd170501 edited
https://github.com/llvm/llvm-project/pull/87208
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
34 matches
Mail list logo