[clang-tools-extra] [include-cleaner] Check emptiness instead of occurences (PR #79154)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 23 07:21:34 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tools-extra
Author: kadir çetinkaya (kadircet)
<details>
<summary>Changes</summary>
Our internal integration relies on injecting some default values to ignore/keep
lists. That means we can have filters, despite of not having occurences for the
flag.
---
Full diff: https://github.com/llvm/llvm-project/pull/79154.diff
2 Files Affected:
- (modified) clang-tools-extra/include-cleaner/test/tool.cpp (+8)
- (modified) clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp (+2-2)
``````````diff
diff --git a/clang-tools-extra/include-cleaner/test/tool.cpp b/clang-tools-extra/include-cleaner/test/tool.cpp
index de47b2a3f3778c..2155eec189d186 100644
--- a/clang-tools-extra/include-cleaner/test/tool.cpp
+++ b/clang-tools-extra/include-cleaner/test/tool.cpp
@@ -22,10 +22,18 @@ int x = foo();
// IGNORE2-NOT: - "foobar.h"
// IGNORE2: + "foo.h"
+// RUN: clang-include-cleaner -print=changes %s --ignore-headers= -- -I%S/Inputs/ | FileCheck --allow-empty --check-prefix=IGNORE3 %s
+// IGNORE3: - "foobar.h"
+// IGNORE3: + "foo.h"
+
// RUN: clang-include-cleaner -print=changes %s --only-headers="foo\.h" -- -I%S/Inputs/ | FileCheck --match-full-lines --allow-empty --check-prefix=ONLY %s
// ONLY-NOT: - "foobar.h"
// ONLY: + "foo.h"
+// RUN: clang-include-cleaner -print=changes %s --only-headers= -- -I%S/Inputs/ | FileCheck --allow-empty --check-prefix=ONLY2 %s
+// ONLY2: - "foobar.h"
+// ONLY2: + "foo.h"
+
// RUN: clang-include-cleaner -print %s -- -I%S/Inputs/ | FileCheck --match-full-lines --check-prefix=PRINT %s
// PRINT: #include "foo.h"
// PRINT-NOT: {{^}}#include "foobar.h"{{$}}
diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 132ad25411509d..3bc449b0152bba 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -262,9 +262,9 @@ std::function<bool(llvm::StringRef)> headerFilter() {
return nullptr;
return [OnlyMatches, IgnoreMatches](llvm::StringRef Header) {
- if (OnlyHeaders.getNumOccurrences() && !OnlyMatches(Header))
+ if (!OnlyHeaders.empty() && !OnlyMatches(Header))
return true;
- if (IgnoreHeaders.getNumOccurrences() && IgnoreMatches(Header))
+ if (!IgnoreHeaders.empty() && IgnoreMatches(Header))
return true;
return false;
};
``````````
</details>
https://github.com/llvm/llvm-project/pull/79154
More information about the cfe-commits
mailing list