[clang-tools-extra] 338d162 - [clang-tidy] Ignore all spaces in the list of checks

Dmitry Polukhin via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 24 06:43:36 PDT 2021


Author: Dmitry Polukhin
Date: 2021-03-24T06:43:13-07:00
New Revision: 338d16275571df4d841609d7e12bcb310b3a95e6

URL: https://github.com/llvm/llvm-project/commit/338d16275571df4d841609d7e12bcb310b3a95e6
DIFF: https://github.com/llvm/llvm-project/commit/338d16275571df4d841609d7e12bcb310b3a95e6.diff

LOG: [clang-tidy] Ignore all spaces in the list of checks

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

Added: 
    clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file-spaces

Modified: 
    clang-tools-extra/clang-tidy/GlobList.cpp
    clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/GlobList.cpp b/clang-tools-extra/clang-tidy/GlobList.cpp
index 43945fcdc074..863bb4672852 100644
--- a/clang-tools-extra/clang-tidy/GlobList.cpp
+++ b/clang-tools-extra/clang-tidy/GlobList.cpp
@@ -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
index 000000000000..4aa1f846ade6
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file-spaces
@@ -0,0 +1,9 @@
+Checks: "
+  -*
+  ,
+  hicpp-uppercase-literal-suffix
+  ,hicpp-use-auto
+
+
+  ,  hicpp-use-emplace
+"

diff  --git a/clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
index 49028d198f75..16b216a1d4f6 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
@@ -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:


        


More information about the cfe-commits mailing list