carlosgalvezp created this revision.
carlosgalvezp added a project: clang-tools-extra.
Herald added subscribers: libc-commits, arphaman, zzheng, kbarton, xazax.hun, 
mgorny, nemanjai.
Herald added a project: libc-project.
carlosgalvezp requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.

Instead of regex, to allow for negative globs.

Rename HeaderFilterRegex to HeaderFilter,
to keep it consistent.

Fix existing usage of HeaderFilter in the codebase.

Add unit test excluding one directory.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112720

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
  clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp
  
clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align-no-crash.cpp
  clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
  clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
  clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-readability-casting.c
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-multi-fixes.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-transitive.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
  clang-tools-extra/test/clang-tidy/checkers/zircon-temporary-objects.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/1/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
  clang-tools-extra/test/clang-tidy/infrastructure/Inputs/overlapping/o.h
  clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-mac-libcxx.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-error-within-include.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/overlapping.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
  libc/src/.clang-tidy
  libc/test/src/CMakeLists.txt

Index: libc/test/src/CMakeLists.txt
===================================================================
--- libc/test/src/CMakeLists.txt
+++ libc/test/src/CMakeLists.txt
@@ -115,7 +115,7 @@
     COMMAND $<TARGET_FILE:clang-tidy> --system-headers
       --checks=-*,llvmlibc-restrict-system-libc-headers
       "--extra-arg=-resource-dir=${COMPILER_RESOURCE_DIR}"
-      --header-filter=.*
+      --header-filter=*
       --warnings-as-errors=llvmlibc-*
       "-config={CheckOptions: [{key: llvmlibc-restrict-system-libc-headers.Includes, value: '-*, linux/*, asm/*.h, asm-generic/*.h'}]}"
       --quiet
Index: libc/src/.clang-tidy
===================================================================
--- libc/src/.clang-tidy
+++ libc/src/.clang-tidy
@@ -1,5 +1,5 @@
 Checks: '-*,llvmlibc-*'
-HeaderFilterRegex: '.*'
+HeaderFilter: '*'
 WarningsAsErrors: 'llvmlibc-*'
 CheckOptions:
   - key:             llvmlibc-restrict-system-libc-headers.Includes
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===================================================================
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -76,13 +76,13 @@
 TEST(ParseConfiguration, ValidConfiguration) {
   llvm::ErrorOr<ClangTidyOptions> Options =
       parseConfiguration(llvm::MemoryBufferRef("Checks: \"-*,misc-*\"\n"
-                                               "HeaderFilterRegex: \".*\"\n"
+                                               "HeaderFilter: \"*\"\n"
                                                "AnalyzeTemporaryDtors: true\n"
                                                "User: some.user",
                                                "Options"));
   EXPECT_TRUE(!!Options);
   EXPECT_EQ("-*,misc-*", *Options->Checks);
-  EXPECT_EQ(".*", *Options->HeaderFilterRegex);
+  EXPECT_EQ("*", *Options->HeaderFilter);
   EXPECT_EQ("some.user", *Options->User);
 }
 
@@ -90,7 +90,7 @@
   llvm::ErrorOr<ClangTidyOptions> Options1 =
       parseConfiguration(llvm::MemoryBufferRef(R"(
       Checks: "check1,check2"
-      HeaderFilterRegex: "filter1"
+      HeaderFilter: "filter1"
       AnalyzeTemporaryDtors: true
       User: user1
       ExtraArgs: ['arg1', 'arg2']
@@ -102,7 +102,7 @@
   llvm::ErrorOr<ClangTidyOptions> Options2 =
       parseConfiguration(llvm::MemoryBufferRef(R"(
       Checks: "check3,check4"
-      HeaderFilterRegex: "filter2"
+      HeaderFilter: "filter2"
       AnalyzeTemporaryDtors: false
       User: user2
       ExtraArgs: ['arg3', 'arg4']
@@ -113,7 +113,7 @@
   ASSERT_TRUE(!!Options2);
   ClangTidyOptions Options = Options1->merge(*Options2, 0);
   EXPECT_EQ("check1,check2,check3,check4", *Options.Checks);
-  EXPECT_EQ("filter2", *Options.HeaderFilterRegex);
+  EXPECT_EQ("filter2", *Options.HeaderFilter);
   EXPECT_EQ("user2", *Options.User);
   ASSERT_TRUE(Options.ExtraArgs.hasValue());
   EXPECT_EQ("arg1,arg2,arg3,arg4", llvm::join(Options.ExtraArgs->begin(),
Index: clang-tools-extra/test/clang-tidy/infrastructure/overlapping.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/overlapping.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/overlapping.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy -checks=-*,llvm-include-order -header-filter=.* %s \
+// RUN: clang-tidy -checks=-*,llvm-include-order -header-filter=* %s \
 // RUN:   -- -isystem %S/Inputs/Headers -I %S/Inputs/overlapping | \
 // RUN:   not grep "note: this fix will not be applied because it overlaps with another fix"
 
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-error-within-include.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-error-within-include.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-error-within-include.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s google-explicit-constructor %t -- --header-filter=.* -system-headers -- -isystem %S/Inputs/nolintbeginend
+// RUN: %check_clang_tidy %s google-explicit-constructor %t -- --header-filter=* -system-headers -- -isystem %S/Inputs/nolintbeginend
 
 #include "error_in_include.inc"
 // CHECK-MESSAGES: error_in_include.inc:1:11: warning: single-argument constructors must be marked explicit
Index: clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -line-filter='[{"name":"line-filter.cpp","lines":[[18,18],[22,22]]},{"name":"header1.h","lines":[[1,2]]},{"name":"header2.h"},{"name":"header3.h"}]' -header-filter='header[12]\.h$' %s -- -I %S/Inputs/line-filter 2>&1 | FileCheck %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -line-filter='[{"name":"line-filter.cpp","lines":[[18,18],[22,22]]},{"name":"header1.h","lines":[[1,2]]},{"name":"header2.h"},{"name":"header3.h"}]' -header-filter='*/header1.h,*/header2.h' %s -- -I %S/Inputs/line-filter 2>&1 | FileCheck %s
 
 #include "header1.h"
 // CHECK-NOT: header1.h:{{.*}} warning
Index: clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp
@@ -1,15 +1,15 @@
 // RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck %s
 // RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='' -quiet %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK-QUIET %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK2 %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -quiet %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK2-QUIET %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header2\.h' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK3 %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header2\.h' -quiet %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK3-QUIET %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='*' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK2 %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='*' -quiet %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK2-QUIET %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='*/header2.h' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK3 %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='*/header2.h' -quiet %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK3-QUIET %s
 // FIXME: "-I %S/Inputs/file-filter/system/.." must be redundant.
 //       On Win32, file-filter/system\system-header1.h precedes
 //       file-filter\header*.h due to code order between '/' and '\\'.
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4 %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers -quiet %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4-QUIET %s
-
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='*' -system-headers %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4 %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='*' -system-headers -quiet %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4-QUIET %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='*,-*/header1.h' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK5 %s
 #include "header1.h"
 // CHECK-NOT: warning:
 // CHECK-QUIET-NOT: warning:
@@ -19,6 +19,7 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4: header1.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: header1.h:1:12: warning: single-argument constructors
+// CHECK5-NOT: warning:
 
 #include "header2.h"
 // CHECK-NOT: warning:
@@ -29,6 +30,7 @@
 // CHECK3-QUIET: header2.h:1:12: warning: single-argument constructors
 // CHECK4: header2.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: header2.h:1:12: warning: single-argument constructors
+// CHECK5: header2.h:1:12: warning: single-argument constructors
 
 #include <system-header.h>
 // CHECK-NOT: warning:
@@ -39,6 +41,7 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4: system-header.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: system-header.h:1:12: warning: single-argument constructors
+// CHECK5-NOT: warning:
 
 class A { A(int); };
 // CHECK: :[[@LINE-1]]:11: warning: single-argument constructors
@@ -49,6 +52,7 @@
 // CHECK3-QUIET: :[[@LINE-6]]:11: warning: single-argument constructors
 // CHECK4: :[[@LINE-7]]:11: warning: single-argument constructors
 // CHECK4-QUIET: :[[@LINE-8]]:11: warning: single-argument constructors
+// CHECK5: :[[@LINE-9]]:11: warning: single-argument constructors
 
 // CHECK-NOT: warning:
 // CHECK-QUIET-NOT: warning:
@@ -58,16 +62,19 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4-NOT: warning:
 // CHECK4-QUIET-NOT: warning:
+// CHECK5-NOT: warning:
 
 // CHECK: Suppressed 3 warnings (3 in non-user code)
-// CHECK: Use -header-filter=.* to display errors from all non-system headers.
+// CHECK: Use -header-filter=* to display errors from all non-system headers.
 // CHECK-QUIET-NOT: Suppressed
 // CHECK2: Suppressed 1 warnings (1 in non-user code)
-// CHECK2: Use -header-filter=.* {{.*}}
+// CHECK2: Use -header-filter=* {{.*}}
 // CHECK2-QUIET-NOT: Suppressed
 // CHECK3: Suppressed 2 warnings (2 in non-user code)
-// CHECK3: Use -header-filter=.* {{.*}}
+// CHECK3: Use -header-filter=* {{.*}}
 // CHECK3-QUIET-NOT: Suppressed
 // CHECK4-NOT: Suppressed {{.*}} warnings
-// CHECK4-NOT: Use -header-filter=.* {{.*}}
+// CHECK4-NOT: Use -header-filter=* {{.*}}
 // CHECK4-QUIET-NOT: Suppressed
+// CHECK5: Suppressed 2 warnings (2 in non-user code)
+// CHECK5: Use -header-filter=* {{.*}}
Index: clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
@@ -5,12 +5,12 @@
 // RUN: echo 'class A { A(int); };' > %t/dir1/header.h
 // RUN: ln -s %t/dir1/header.h %t/dir1/header_alias.h
 //
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='dir1/dir2/\.\./header_alias\.h' %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='dir1/dir2/\.\./header_alias\.h' -quiet %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header_alias\.h' %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header_alias\.h' -quiet %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header\.h' %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header\.h' -quiet %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='*/dir1/dir2/../header_alias.h' %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='*/dir1/dir2/../header_alias.h' -quiet %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='*/header_alias.h' %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='*/header_alias.h' -quiet %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='*/header.h' %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='*/header.h' -quiet %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER %s
 
 // Check that `-header-filter` operates on the same file paths as paths in
 // diagnostics printed by ClangTidy.
Index: clang-tools-extra/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp
@@ -5,7 +5,7 @@
 // RUN: %check_clang_tidy -std=c++11 %s readability-identifier-naming %t/without-modules -- \
 // RUN:   -config="CheckOptions: [{ \
 // RUN:      key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }]" \
-// RUN:   -header-filter=.* \
+// RUN:   -header-filter=* \
 // RUN:   -- -I %t/
 //
 // RUN: rm -rf %t
@@ -14,7 +14,7 @@
 // RUN: %check_clang_tidy -std=c++17 %s readability-identifier-naming %t/without-modules -- \
 // RUN:   -config="CheckOptions: [{ \
 // RUN:      key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }]" \
-// RUN:   -header-filter=.* \
+// RUN:   -header-filter=* \
 // RUN:   -- -I %t/
 //
 // Run clang-tidy on a file with modular includes:
@@ -25,7 +25,7 @@
 // RUN: %check_clang_tidy -std=c++11 %s readability-identifier-naming %t/with-modules -- \
 // RUN:   -config="CheckOptions: [{ \
 // RUN:      key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }]" \
-// RUN:   -header-filter=.* \
+// RUN:   -header-filter=* \
 // RUN:   -- -I %t/ \
 // RUN:   -fmodules -fimplicit-modules -fno-implicit-module-maps \
 // RUN:   -fmodule-map-file=%t/module.modulemap \
@@ -37,7 +37,7 @@
 // RUN: %check_clang_tidy -std=c++17 %s readability-identifier-naming %t/with-modules -- \
 // RUN:   -config="CheckOptions: [{ \
 // RUN:      key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }]" \
-// RUN:   -header-filter=.* \
+// RUN:   -header-filter=* \
 // RUN:   -- -I %t/ \
 // RUN:   -fmodules -fimplicit-modules -fno-implicit-module-maps \
 // RUN:   -fmodule-map-file=%t/module.modulemap \
Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -1,18 +1,18 @@
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/- -- | FileCheck %s -check-prefix=CHECK-BASE
 // CHECK-BASE: Checks: {{.*}}from-parent
-// CHECK-BASE: HeaderFilterRegex: parent
+// CHECK-BASE: HeaderFilter: parent
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/1/- -- | FileCheck %s -check-prefix=CHECK-CHILD1
 // CHECK-CHILD1: Checks: {{.*}}from-child1
-// CHECK-CHILD1: HeaderFilterRegex: child1
+// CHECK-CHILD1: HeaderFilter: child1
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/2/- -- | FileCheck %s -check-prefix=CHECK-CHILD2
 // CHECK-CHILD2: Checks: {{.*}}from-parent
-// CHECK-CHILD2: HeaderFilterRegex: parent
+// CHECK-CHILD2: HeaderFilter: parent
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/3/- -- | FileCheck %s -check-prefix=CHECK-CHILD3
 // CHECK-CHILD3: Checks: {{.*}}from-parent,from-child3
-// CHECK-CHILD3: HeaderFilterRegex: child3
+// CHECK-CHILD3: HeaderFilter: child3
 // RUN: clang-tidy -dump-config -checks='from-command-line' -header-filter='from command line' %S/Inputs/config-files/- -- | FileCheck %s -check-prefix=CHECK-COMMAND-LINE
 // CHECK-COMMAND-LINE: Checks: {{.*}}from-parent,from-command-line
-// CHECK-COMMAND-LINE: HeaderFilterRegex: from command line
+// CHECK-COMMAND-LINE: HeaderFilter: from command line
 
 // For this test we have to use names of the real checks because otherwise values are ignored.
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD4
Index: clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp
@@ -10,12 +10,12 @@
 // RUN: sed 's|test_dir|%/T/compilation-database-test|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
 
 // Regression test: shouldn't crash.
-// RUN: not clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.* 2>&1 | FileCheck %s -check-prefix=CHECK-NOT-EXIST
+// RUN: not clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=* 2>&1 | FileCheck %s -check-prefix=CHECK-NOT-EXIST
 // CHECK-NOT-EXIST: Error while processing {{.*[/\\]}}not-exist.
 // CHECK-NOT-EXIST: unable to handle compilation
 // CHECK-NOT-EXIST: Found compiler error
 
-// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/d.cpp -header-filter=.* -fix
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/d.cpp -header-filter=* -fix
 // RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %s -check-prefix=CHECK-FIX1
 // RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %s -check-prefix=CHECK-FIX2
 // RUN: FileCheck -input-file=%T/compilation-database-test/b/b.cpp %s -check-prefix=CHECK-FIX3
Index: clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-mac-libcxx.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-mac-libcxx.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-mac-libcxx.cpp
@@ -10,7 +10,7 @@
 // Pretend clang is installed beside the mock library that we provided.
 // RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ -stdlib=libc++ -std=c++11 -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
 // RUN: cp "%s" "%t/test.cpp"
-// RUN: clang-tidy -header-filter='.*' -system-headers -checks='-*,modernize-use-using'  "%t/test.cpp" | FileCheck %s
+// RUN: clang-tidy -header-filter='*' -system-headers -checks='-*,modernize-use-using'  "%t/test.cpp" | FileCheck %s
 // CHECK: mock_vector:{{[0-9]+}}:{{[0-9]+}}: warning: use 'using' instead of 'typedef'
 
 #include <mock_vector>
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/overlapping/o.h
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/Inputs/overlapping/o.h
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/overlapping/o.h
@@ -1,4 +1,4 @@
-// run: clang-tidy -checks=-*,llvm-include-order -header-filter=.* %s \
+// run: clang-tidy -checks=-*,llvm-include-order -header-filter=* %s \
 // run:   -- -isystem %S/Inputs/Headers -I %S/Inputs/overlapping | \
 // run:   not grep "note: this fix will not be applied because it overlaps with another fix"
 
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
@@ -1,3 +1,3 @@
 InheritParentConfig: true
 Checks: 'from-child3'
-HeaderFilterRegex: 'child3'
+HeaderFilter: 'child3'
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/1/.clang-tidy
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/1/.clang-tidy
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/1/.clang-tidy
@@ -1,2 +1,2 @@
 Checks: 'from-child1'
-HeaderFilterRegex: 'child1'
+HeaderFilter: 'child1'
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/.clang-tidy
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/.clang-tidy
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/.clang-tidy
@@ -1,2 +1,2 @@
 Checks: 'from-parent'
-HeaderFilterRegex: 'parent'
+HeaderFilter: 'parent'
Index: clang-tools-extra/test/clang-tidy/checkers/zircon-temporary-objects.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/zircon-temporary-objects.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/zircon-temporary-objects.cpp
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s zircon-temporary-objects %t -- \
 // RUN:   -config="{CheckOptions: [{key: zircon-temporary-objects.Names, value: 'Foo;NS::Bar'}]}" \
-// RUN:   -header-filter=.*
+// RUN:   -header-filter=*
 
 // Should flag instances of Foo, NS::Bar.
 
Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
@@ -15,7 +15,7 @@
 // RUN:   {key: readability-identifier-naming.FunctionCase, value: camelBack}, \
 // RUN:   {key: readability-identifier-naming.ParameterCase, value: CamelCase}, \
 // RUN:   {key: readability-identifier-naming.GetConfigPerFile, value: true} \
-// RUN:  ]}' -header-filter='.*' -- -I%theaders
+// RUN:  ]}' -header-filter='*' -- -I%theaders
 
 // On DISABLED run, everything should be made 'camelBack'.
 
@@ -26,7 +26,7 @@
 // RUN:   {key: readability-identifier-naming.FunctionCase, value: camelBack}, \
 // RUN:   {key: readability-identifier-naming.ParameterCase, value: CamelCase}, \
 // RUN:   {key: readability-identifier-naming.GetConfigPerFile, value: false} \
-// RUN:  ]}' -header-filter='.*' -- -I%theaders
+// RUN:  ]}' -header-filter='*' -- -I%theaders
 
 #include "global-style1/header.h"
 #include "global-style2/header.h"
Index: clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-transitive.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-transitive.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-transitive.cpp
@@ -3,7 +3,7 @@
 // RUN: cp -r %S/Inputs/portability-restrict-system-includes %T/Headers/portability-restrict-system-includes
 // RUN: %check_clang_tidy -std=c++11 %s portability-restrict-system-includes %t \
 // RUN:   -- -config="{CheckOptions: [{key: portability-restrict-system-includes.Includes, value: 'transitive.h,s.h'}]}" \
-// RUN:   -system-headers -header-filter=.* \
+// RUN:   -system-headers -header-filter=* \
 // RUN:   -- -I %T/Headers/portability-restrict-system-includes -isystem %T/Headers/portability-restrict-system-includes/system
 // RUN: FileCheck -input-file=%T/Headers/portability-restrict-system-includes/transitive2.h %s -check-prefix=CHECK-FIXES
 // RUN: rm -rf %T/Headers
Index: clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-multi-fixes.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-multi-fixes.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-multi-fixes.cpp
@@ -1,6 +1,6 @@
 // RUN: cat %S/Inputs/modernize-pass-by-value/header-with-fix.h > %T/pass-by-value-header-with-fix.h
 // RUN: sed -e 's#//.*$##' %s > %t.cpp
-// RUN: clang-tidy %t.cpp -checks='-*,modernize-pass-by-value' -header-filter='.*' -fix -- -std=c++11 -I %T | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error}}:"
+// RUN: clang-tidy %t.cpp -checks='-*,modernize-pass-by-value' -header-filter='*' -fix -- -std=c++11 -I %T | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error}}:"
 // RUN: FileCheck -input-file=%t.cpp %s -check-prefix=CHECK-FIXES
 // RUN: FileCheck -input-file=%T/pass-by-value-header-with-fix.h %s -check-prefix=CHECK-HEADER-FIXES
 
Index: clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
@@ -1,5 +1,5 @@
 // RUN: cp %S/Inputs/modernize-pass-by-value/header.h %T/pass-by-value-header.h
-// RUN: clang-tidy %s -checks='-*,modernize-pass-by-value' -header-filter='.*' -fix -- -std=c++11 -I %T | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error}}:"
+// RUN: clang-tidy %s -checks='-*,modernize-pass-by-value' -header-filter='*' -fix -- -std=c++11 -I %T | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error}}:"
 // RUN: FileCheck -input-file=%T/pass-by-value-header.h %s -check-prefix=CHECK-FIXES
 // FIXME: Make the test work in all language modes.
 
Index: clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
@@ -1,9 +1,9 @@
 // RUN: cp %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
-// RUN: %check_clang_tidy -std=c++17 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: %check_clang_tidy -std=c++17 %s modernize-concat-nested-namespaces %t -- -header-filter="*" -- -I %T
 // RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
 // Restore header file and re-run with c++20:
 // RUN: cp %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
-// RUN: %check_clang_tidy -std=c++20 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: %check_clang_tidy -std=c++20 %s modernize-concat-nested-namespaces %t -- -header-filter="*" -- -I %T
 // RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
 
 #include "modernize-concat-nested-namespaces.h"
Index: clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
@@ -1,6 +1,6 @@
 // RUN: echo "static void staticFunctionHeader(int i) {;}" > %T/header.h
 // RUN: echo "static void staticFunctionHeader(int  /*i*/) {;}" > %T/header-fixed.h
-// RUN: %check_clang_tidy -std=c++11 %s misc-unused-parameters %t -- -header-filter='.*' -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -std=c++11 %s misc-unused-parameters %t -- -header-filter='*' -- -fno-delayed-template-parsing
 // RUN: diff %T/header.h %T/header-fixed.h
 // FIXME: Make the test work in all language modes.
 
Index: clang-tools-extra/test/clang-tidy/checkers/google-readability-casting.c
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/google-readability-casting.c
+++ clang-tools-extra/test/clang-tidy/checkers/google-readability-casting.c
@@ -3,7 +3,7 @@
 // need to run clang-tidy directly in order to verify handling of .c files:
 // RUN: clang-tidy --checks=-*,google-readability-casting %s -- -x c++ | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:'
 // RUN: cp %s %t.main_file.cpp
-// RUN: clang-tidy --checks=-*,google-readability-casting -header-filter='.*' %t.main_file.cpp -- -I%S -DTEST_INCLUDE -x c++ | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:'
+// RUN: clang-tidy --checks=-*,google-readability-casting -header-filter='*' %t.main_file.cpp -- -I%S -DTEST_INCLUDE -x c++ | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:'
 
 #ifdef TEST_INCLUDE
 
Index: clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy %s -checks='-*,google-build-namespaces,google-build-using-namespace' -header-filter='.*' -- | FileCheck %s -implicit-check-not="{{warning|error}}:"
+// RUN: clang-tidy %s -checks='-*,google-build-namespaces,google-build-using-namespace' -header-filter='*' -- | FileCheck %s -implicit-check-not="{{warning|error}}:"
 #include "Inputs/google-namespaces.h"
 // CHECK: warning: do not use unnamed namespaces in header files [google-build-namespaces]
 
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-macro-usage %t -- -header-filter=.* -system-headers --
+// RUN: %check_clang_tidy %s cppcoreguidelines-macro-usage %t -- -header-filter=* -system-headers --
 
 #ifndef INCLUDE_GUARD
 #define INCLUDE_GUARD
Index: clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
@@ -1,5 +1,5 @@
-// RUN: %check_clang_tidy %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 50}]}" -header-filter=.*
-// RUN: %check_clang_tidy -check-suffix=MULT %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 5}]}" -header-filter=.* "--" -DMULT
+// RUN: %check_clang_tidy %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 50}]}" -header-filter=*
+// RUN: %check_clang_tidy -check-suffix=MULT %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 5}]}" -header-filter=* "--" -DMULT
 
 #ifdef MULT
 // For loops with *= and /= increments.
Index: clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s altera-struct-pack-align %t -- -header-filter=.*
+// RUN: %check_clang_tidy %s altera-struct-pack-align %t -- -header-filter=*
 
 // Struct needs both alignment and packing
 struct error {
Index: clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align-no-crash.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align-no-crash.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align-no-crash.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -expect-clang-tidy-error %s altera-struct-pack-align %t -- -header-filter=.*
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s altera-struct-pack-align %t -- -header-filter=*
 
 struct A;
 struct B {
Index: clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp
@@ -1,7 +1,7 @@
-// RUN: %check_clang_tidy -check-suffix=OLDCLOLDAOC %s altera-single-work-item-barrier %t -- -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h -DOLDCLOLDAOC
-// RUN: %check_clang_tidy -check-suffix=NEWCLOLDAOC %s altera-single-work-item-barrier %t -- -header-filter=.* "--" -cl-std=CL2.0 -c --include opencl-c.h -DNEWCLOLDAOC
-// RUN: %check_clang_tidy -check-suffix=OLDCLNEWAOC %s altera-single-work-item-barrier %t -- -config='{CheckOptions: [{key: altera-single-work-item-barrier.AOCVersion, value: 1701}]}' -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h -DOLDCLNEWAOC
-// RUN: %check_clang_tidy -check-suffix=NEWCLNEWAOC %s altera-single-work-item-barrier %t -- -config='{CheckOptions: [{key: altera-single-work-item-barrier.AOCVersion, value: 1701}]}' -header-filter=.* "--" -cl-std=CL2.0 -c --include opencl-c.h -DNEWCLNEWAOC
+// RUN: %check_clang_tidy -check-suffix=OLDCLOLDAOC %s altera-single-work-item-barrier %t -- -header-filter=* "--" -cl-std=CL1.2 -c --include opencl-c.h -DOLDCLOLDAOC
+// RUN: %check_clang_tidy -check-suffix=NEWCLOLDAOC %s altera-single-work-item-barrier %t -- -header-filter=* "--" -cl-std=CL2.0 -c --include opencl-c.h -DNEWCLOLDAOC
+// RUN: %check_clang_tidy -check-suffix=OLDCLNEWAOC %s altera-single-work-item-barrier %t -- -config='{CheckOptions: [{key: altera-single-work-item-barrier.AOCVersion, value: 1701}]}' -header-filter=* "--" -cl-std=CL1.2 -c --include opencl-c.h -DOLDCLNEWAOC
+// RUN: %check_clang_tidy -check-suffix=NEWCLNEWAOC %s altera-single-work-item-barrier %t -- -config='{CheckOptions: [{key: altera-single-work-item-barrier.AOCVersion, value: 1701}]}' -header-filter=* "--" -cl-std=CL2.0 -c --include opencl-c.h -DNEWCLNEWAOC
 
 #ifdef OLDCLOLDAOC  // OpenCL 1.2 Altera Offline Compiler < 17.1
 void __kernel error_barrier_no_id(__global int * foo, int size) {
Index: clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s altera-id-dependent-backward-branch %t -- -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h
+// RUN: %check_clang_tidy %s altera-id-dependent-backward-branch %t -- -header-filter=* "--" -cl-std=CL1.2 -c --include opencl-c.h
 
 typedef struct ExampleStruct {
   int IDDepField;
Index: clang-tools-extra/test/clang-tidy/checkers/abseil-no-namespace.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/abseil-no-namespace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-no-namespace.cpp
@@ -1,5 +1,5 @@
 // RUN: %check_clang_tidy %s abseil-no-namespace %t -- -- -I %S/Inputs
-// RUN: clang-tidy -checks='-*, abseil-no-namespace' -header-filter='.*' %s -- -I %S/Inputs 2>&1 | FileCheck %s
+// RUN: clang-tidy -checks='-*, abseil-no-namespace' -header-filter='*' %s -- -I %S/Inputs 2>&1 | FileCheck %s
 
 /// Warning will not be triggered on internal Abseil code that is included.
 #include "absl/strings/internal-file.h"
Index: clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
@@ -1,5 +1,5 @@
 // RUN: %check_clang_tidy %s abseil-no-internal-dependencies %t,  -- -- -I %S/Inputs
-// RUN: clang-tidy -checks='-*, abseil-no-internal-dependencies' -header-filter='.*' %s -- -I %S/Inputs 2>&1 | FileCheck %s
+// RUN: clang-tidy -checks='-*, abseil-no-internal-dependencies' -header-filter='*' %s -- -I %S/Inputs 2>&1 | FileCheck %s
 
 #include "absl/strings/internal-file.h"
 #include "absl/flags/internal-file.h"
Index: clang-tools-extra/docs/clang-tidy/index.rst
===================================================================
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -198,7 +198,7 @@
                                      from the main file of each translation unit are
                                      always displayed.
                                      Can be used together with -line-filter.
-                                     This option overrides the 'HeaderFilterRegex'
+                                     This option overrides the 'HeaderFilter'
                                      option in .clang-tidy file, if any.
     --line-filter=<string>         -
                                      List of files with line ranges to filter the
@@ -266,7 +266,7 @@
       ---
       Checks:              '-*,some-check'
       WarningsAsErrors:    ''
-      HeaderFilterRegex:   ''
+      HeaderFilter:   ''
       FormatStyle:         none
       InheritParentConfig: true
       User:                user
Index: clang-tools-extra/docs/ReleaseNotes.rst
===================================================================
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -67,6 +67,19 @@
 Improvements to clang-tidy
 --------------------------
 
+.. warning::
+
+  - `HeaderFilterRegex` has been renamed to `HeaderFilter`.
+  - `HeaderFilter` is now a glob expression, instead a regex expression. The consequences are:
+    - The glob expression must match the full path of the header, therefore users should use
+      `HeaderFilter: '*/header.h'`
+
+    - Multiple positive or negative globs can be used, with the same semantics as `Checks`:
+
+      ```
+      HeaderFilter: '*/header1.h,-*/header2,h'
+      ```
+
 - Added support for globbing in `NOLINT*` expressions, to simplify suppressing
   multiple warnings in the same line.
 
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===================================================================
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -45,7 +45,7 @@
     ---
     Checks:              '-*,some-check'
     WarningsAsErrors:    ''
-    HeaderFilterRegex:   ''
+    HeaderFilter:   ''
     FormatStyle:         none
     InheritParentConfig: true
     User:                user
@@ -84,12 +84,12 @@
                                              cl::cat(ClangTidyCategory));
 
 static cl::opt<std::string> HeaderFilter("header-filter", cl::desc(R"(
-Regular expression matching the names of the
+Glob expression matching the names of the
 headers to output diagnostics from. Diagnostics
 from the main file of each translation unit are
 always displayed.
 Can be used together with -line-filter.
-This option overrides the 'HeaderFilterRegex'
+This option overrides the 'HeaderFilter'
 option in .clang-tidy file, if any.
 )"),
                                          cl::init(""),
@@ -128,10 +128,10 @@
                                cl::init(false), cl::cat(ClangTidyCategory));
 
 static cl::opt<bool> FixNotes("fix-notes", cl::desc(R"(
-If a warning has no fix, but a single fix can 
-be found through an associated diagnostic note, 
-apply the fix. 
-Specifying this flag will implicitly enable the 
+If a warning has no fix, but a single fix can
+be found through an associated diagnostic note,
+apply the fix.
+Specifying this flag will implicitly enable the
 '--fix' flag.
 )"),
                               cl::init(false), cl::cat(ClangTidyCategory));
@@ -281,7 +281,7 @@
                    << " with check filters";
     llvm::errs() << ").\n";
     if (Stats.ErrorsIgnoredNonUserCode)
-      llvm::errs() << "Use -header-filter=.* to display errors from all "
+      llvm::errs() << "Use -header-filter=* to display errors from all "
                       "non-system headers. Use -system-headers to display "
                       "errors from system headers as well.\n";
   }
@@ -299,7 +299,7 @@
   ClangTidyOptions DefaultOptions;
   DefaultOptions.Checks = DefaultChecks;
   DefaultOptions.WarningsAsErrors = "";
-  DefaultOptions.HeaderFilterRegex = HeaderFilter;
+  DefaultOptions.HeaderFilter = HeaderFilter;
   DefaultOptions.SystemHeaders = SystemHeaders;
   DefaultOptions.FormatStyle = FormatStyle;
   DefaultOptions.User = llvm::sys::Process::GetEnv("USER");
@@ -313,7 +313,7 @@
   if (WarningsAsErrors.getNumOccurrences() > 0)
     OverrideOptions.WarningsAsErrors = WarningsAsErrors;
   if (HeaderFilter.getNumOccurrences() > 0)
-    OverrideOptions.HeaderFilterRegex = HeaderFilter;
+    OverrideOptions.HeaderFilter = HeaderFilter;
   if (SystemHeaders.getNumOccurrences() > 0)
     OverrideOptions.SystemHeaders = SystemHeaders;
   if (FormatStyle.getNumOccurrences() > 0)
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===================================================================
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -74,9 +74,9 @@
 
   /// Output warnings from headers matching this filter. Warnings from
   /// main files will always be displayed.
-  llvm::Optional<std::string> HeaderFilterRegex;
+  llvm::Optional<std::string> HeaderFilter;
 
-  /// Output warnings from system headers matching \c HeaderFilterRegex.
+  /// Output warnings from system headers matching \c HeaderFilter.
   llvm::Optional<bool> SystemHeaders;
 
   /// Format code around applied fixes with clang-format using this
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===================================================================
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -88,7 +88,7 @@
     bool Ignored = false;
     IO.mapOptional("Checks", Options.Checks);
     IO.mapOptional("WarningsAsErrors", Options.WarningsAsErrors);
-    IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex);
+    IO.mapOptional("HeaderFilter", Options.HeaderFilter);
     IO.mapOptional("AnalyzeTemporaryDtors", Ignored); // legacy compatibility
     IO.mapOptional("FormatStyle", Options.FormatStyle);
     IO.mapOptional("User", Options.User);
@@ -110,7 +110,7 @@
   ClangTidyOptions Options;
   Options.Checks = "";
   Options.WarningsAsErrors = "";
-  Options.HeaderFilterRegex = "";
+  Options.HeaderFilter = "";
   Options.SystemHeaders = false;
   Options.FormatStyle = "none";
   Options.User = llvm::None;
@@ -146,7 +146,7 @@
                                               unsigned Order) {
   mergeCommaSeparatedLists(Checks, Other.Checks);
   mergeCommaSeparatedLists(WarningsAsErrors, Other.WarningsAsErrors);
-  overrideValue(HeaderFilterRegex, Other.HeaderFilterRegex);
+  overrideValue(HeaderFilter, Other.HeaderFilter);
   overrideValue(SystemHeaders, Other.SystemHeaders);
   overrideValue(FormatStyle, Other.FormatStyle);
   overrideValue(User, Other.User);
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===================================================================
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -11,6 +11,7 @@
 
 #include "ClangTidyOptions.h"
 #include "ClangTidyProfiling.h"
+#include "GlobList.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Tooling/Core/Diagnostic.h"
 #include "llvm/ADT/DenseMap.h"
@@ -272,7 +273,7 @@
 
   /// Returns the \c HeaderFilter constructed for the options set in the
   /// context.
-  llvm::Regex *getHeaderFilter();
+  GlobList *getHeaderFilter();
 
   /// Updates \c LastErrorRelatesToUserCode and LastErrorPassesLineFilter
   /// according to the diagnostic \p Location.
@@ -286,7 +287,7 @@
   bool RemoveIncompatibleErrors;
   bool GetFixesFromNotes;
   std::vector<ClangTidyError> Errors;
-  std::unique_ptr<llvm::Regex> HeaderFilter;
+  std::unique_ptr<GlobList> HeaderFilter;
   bool LastErrorRelatesToUserCode;
   bool LastErrorPassesLineFilter;
   bool LastErrorWasIgnored;
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===================================================================
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -17,7 +17,6 @@
 
 #include "ClangTidyDiagnosticConsumer.h"
 #include "ClangTidyOptions.h"
-#include "GlobList.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTDiagnostic.h"
 #include "clang/AST/Attr.h"
@@ -758,17 +757,17 @@
   StringRef FileName(File->getName());
   LastErrorRelatesToUserCode = LastErrorRelatesToUserCode ||
                                Sources.isInMainFile(Location) ||
-                               getHeaderFilter()->match(FileName);
+                               getHeaderFilter()->contains(FileName);
 
   unsigned LineNumber = Sources.getExpansionLineNumber(Location);
   LastErrorPassesLineFilter =
       LastErrorPassesLineFilter || passesLineFilter(FileName, LineNumber);
 }
 
-llvm::Regex *ClangTidyDiagnosticConsumer::getHeaderFilter() {
+GlobList *ClangTidyDiagnosticConsumer::getHeaderFilter() {
   if (!HeaderFilter)
     HeaderFilter =
-        std::make_unique<llvm::Regex>(*Context.getOptions().HeaderFilterRegex);
+        std::make_unique<GlobList>(*Context.getOptions().HeaderFilter);
   return HeaderFilter.get();
 }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to