[clang-tools-extra] 7e3fb37 - [include-cleaner] Check emptiness instead of occurences (#79154)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 23 22:26:03 PST 2024
Author: kadir çetinkaya
Date: 2024-01-24T07:26:00+01:00
New Revision: 7e3fb372b0e8899958ec7e9241797e7e136a7a23
URL: https://github.com/llvm/llvm-project/commit/7e3fb372b0e8899958ec7e9241797e7e136a7a23
DIFF: https://github.com/llvm/llvm-project/commit/7e3fb372b0e8899958ec7e9241797e7e136a7a23.diff
LOG: [include-cleaner] Check emptiness instead of occurences (#79154)
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.
Added:
Modified:
clang-tools-extra/include-cleaner/test/tool.cpp
clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
Removed:
################################################################################
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;
};
More information about the cfe-commits
mailing list