[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
This commit is contained in:
Dmitry Polukhin 2021-03-23 05:26:21 -07:00
parent 0620e6f4b7
commit 338d162755
3 changed files with 17 additions and 2 deletions

View 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("()^$|*+?.[]\\{}");

View file

@ -0,0 +1,9 @@
Checks: "
-*
,
hicpp-uppercase-literal-suffix
,hicpp-use-auto
, hicpp-use-emplace
"

View 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: