Skip to content

Hierarchical .clang-tidy HeaderFilterRegex Settings Ignored in Clang-Tidy 19 #121969

@sfc-gh-mheimel

Description

@sfc-gh-mheimel

Summary

Our project uses a hierarchical .clang-tidy files to selectively enable checks for specific folders. Previously (in Clang-Tidy 18.1.x), we could rely on HeaderFilterRegex to exclude headers in other directories from checks that were only enabled in certain subfolders. After updating to Clang-Tidy 19.1.x, the subfolder’s HeaderFilterRegex seems to be ignored, causing unwanted warnings for headers outside the subfolder.

We traced this regression to PR #91400; reverting that PR makes Clang-Tidy 19 behave like 18 again.

Steps to Reproduce

Folder Structure

.clang-tidy
test.hpp
a/
 ├─ .clang-tidy
 └─ main.cpp

File Contents

  1. Root .clang-tidy:
HeaderFilterRegex: '.*'
Checks: -.*
  1. Root test.hpp:
int test() {
  return (int)4.0;  // violates google-readability-casting
}
  1. Subfolder a/.clang-tidy:
InheritParentConfig: true
HeaderFilterRegex: '.*a/.*'
Checks: google-readability-casting
  1. Subfolder a/main.cpp:
#include "test.hpp"

int main() {
  return test();
}

Steps to reproduce

With clang-18 (Expected Behavior)

> clang-tidy-18 a/main.cpp --quiet -- -I.
1 warning generated.

With clang-19 (Regression)

> clang-tidy-19 a/main.cpp --quiet -- -I.
1 warning generated.
./test.hpp:2:10: error: C-style casts are discouraged; use static_cast [google-readability-casting,-warnings-as-errors]
   2 |   return (int)4.0;
     |          ^~~~~
     |          static_cast<int>( )

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions