[clang-tidy] Ignore all spaces in the list of checks
authorDmitry Polukhin <dmitry.polukhin@gmail.com>
Tue, 23 Mar 2021 12:26:21 +0000 (05:26 -0700)
committerDmitry Polukhin <dmitry.polukhin@gmail.com>
Wed, 24 Mar 2021 13:43:13 +0000 (06:43 -0700)
This diff patch fixes issue with new line character after check name and before comma. Also ignores all other types of spaces like TAB.

Test Plan: ninja check-clang-tools

Differential Revision: https://reviews.llvm.org/D99180

clang-tools-extra/clang-tidy/GlobList.cpp
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file-spaces [new file with mode: 0644]
clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp

index 43945fc..863bb46 100644 (file)
@@ -15,7 +15,7 @@ using namespace tidy;
 // Returns true if GlobList starts with the negative indicator ('-'), removes it
 // from the GlobList.
 static bool consumeNegativeIndicator(StringRef &GlobList) {
-  GlobList = GlobList.trim(" \r\n");
+  GlobList = GlobList.trim();
   if (GlobList.startswith("-")) {
     GlobList = GlobList.substr(1);
     return true;
@@ -27,7 +27,7 @@ static bool consumeNegativeIndicator(StringRef &GlobList) {
 // removes it and the trailing comma from the GlobList.
 static llvm::Regex consumeGlob(StringRef &GlobList) {
   StringRef UntrimmedGlob = GlobList.substr(0, GlobList.find(','));
-  StringRef Glob = UntrimmedGlob.trim(' ');
+  StringRef Glob = UntrimmedGlob.trim();
   GlobList = GlobList.substr(UntrimmedGlob.size() + 1);
   SmallString<128> RegexText("^");
   StringRef MetaChars("()^$|*+?.[]\\{}");
diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file-spaces b/clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file-spaces
new file mode 100644 (file)
index 0000000..4aa1f84
--- /dev/null
@@ -0,0 +1,9 @@
+Checks: "
+  -*
+  ,
+  hicpp-uppercase-literal-suffix
+  ,hicpp-use-auto
+
+
+  ,  hicpp-use-emplace
+"
index 49028d1..16b216a 100644 (file)
@@ -1,2 +1,8 @@
 // RUN: clang-tidy -config-file=%S/Inputs/config-file/config-file -dump-config -- | FileCheck %s -check-prefix=CHECK-BASE
 // CHECK-BASE: Checks: {{.*}}hicpp-uppercase-literal-suffix
+// RUN: clang-tidy -config-file=%S/Inputs/config-file/config-file-spaces --list-checks -- | FileCheck %s -check-prefix=CHECK-SPACES
+// CHECK-SPACES: Enabled checks:
+// CHECK-SPACES-NEXT: hicpp-uppercase-literal-suffix
+// CHECK-SPACES-NEXT: hicpp-use-auto
+// CHECK-SPACES-NEXT: hicpp-use-emplace
+// CHECK-SPACES-EMPTY: