Issue 121969
Summary Hierarchical .clang-tidy HeaderFilterRegex Settings Ignored in Clang-Tidy 19
Labels clang-tidy
Assignees
Reporter 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](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>( )
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to