<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/121969>121969</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Hierarchical .clang-tidy HeaderFilterRegex Settings Ignored in Clang-Tidy 19
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          sfc-gh-mheimel
      </td>
    </tr>
</table>

<pre>
    # 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](https://github.com/llvm/llvm-project/pull/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`:
  ```yaml
  HeaderFilterRegex: '.*'
  Checks: -.*
  ```

2. Root `test.hpp`:
  ```c++
  int test() {
    return (int)4.0;  // violates google-readability-casting
  }
  ```

3. Subfolder `a/.clang-tidy`:
  ```yaml
  InheritParentConfig: true
  HeaderFilterRegex: '.*a/.*'
  Checks: google-readability-casting
  ```

4. Subfolder `a/main.cpp`:
  ```c++
  #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>( )
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVk9v47gP_TTKhbAhy0kcH3JwMw1mTr-i_QFzXCgyY2tHkbISlTaXfvaF7CRN_013twhQQ5TIx8dHSjIE3VnEJZvdsNm3iYzUO78MW5V1fbbrUe_QTDauPS6ZKOEh7nbSHxlv_hc97L37ExVBDBhAQq_RS696raQBNue5MtJ2Gen2yOYcttpgAHIQ0KAifUBzBLRyYxBUj-pXgK3zEPao9FYr2DrTog853Hk8aBeDOQITC21hNfj9v26PUCzyIn9iomZiBY8IykXTgk-unU0gvqNs0a-1IfT32OFTgkIO8EmZ2CL0gz2AtuCoRw-t9qjIeY0Btt7tztiolwSP6BGcvQBv0zmFnqS2EOLmgrnZEnqI-1aStl0KeA26HkGvgHp8OcZuBVtwVtfhU-ABcTdwuEHQnXUe2-RGyRhSmGgfpSVs4VF6q203MnpO0UUKusXXQXNgvGG8-YlAXipsgXodwGPnMQTtbIrGZjd398BEWRdTztnsGxOLnmgfWNkwsWZi3Wnq4yZXbsfE2pjD-V920ggT6300hon16ELUrLwBjwf0I0GJ3bt72MlfGF5zBRvs5QHB6F8IxQJkJ7XNR9SDJgn3Ayf3uPeujQpHQ7KthxzhgXxUFP1gmfPTjzfXCuUNYaC83-8Zb2TKijeQSlJPWb06fSw4vD5z2TF92bFL-NTg5zrYFSptEFbOEloKjDdFDvfO0fueSfTyBuDi5ih3Zlh5r46yASaqnImGiWrYsxqEmwzZsPzK0whIvES-ZP9BWMXETfqlRW0J0l4mFkzUwKpxGcAjRW_HFiUm6mnOU41hFAgctDOSMEDnXGcw8yhbudFG0zFTMiQVjEGrbx8hLXN4OGs22VKF_ilZP2yPXtOd9Ghp5exWd4kV8hG_JHOI8yGpX-XxGv_0A_wXoXxBOROltuO4YkJcCiXEaD1XJbn7rCovFWPlze94Pkn00lT-XVMl809NPYzsF4tU8tunPao0eW5Ss2rnU6Q3-i9v4aVg6dw1B5Blf0WNBFkG2Y_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