[clang-tools-extra] Add option to exclude headers from clang-tidy analysis (PR #91400)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 30 21:57:21 PDT 2025
cppgent0 wrote:
Ubuntu 24.04 installed clang-tidy-19
tried:
```
HeaderFilterRegex: '^(?!/usr/share/arduino/|/opt/arduino/).*'
ExcludeHeaderFilterRegex : '/usr/share/arduino/.*|/opt/arduino/.*|.*/Arduino.h|.*/USBAPI.h'
SystemHeaders: false
```
Get these warnings:
```-- 5] /usr/share/arduino/hardware/arduino/avr/cores/arduino/USBAPI.h:33:10: warning: circular header file dependency detected while including 'Arduino.h', please check the include path [misc-header-include-cycle]
-- 6] 33 | #include "Arduino.h"
-- 7] | ^
-- 8] /usr/share/arduino/hardware/arduino/avr/cores/arduino/Arduino.h:234:10: note: 'USBAPI.h' included from here
-- 9] 234 | #include "USBAPI.h"
-- 10] | ^
-- 11] src/main.cpp:7:10: note: 'Arduino.h' included from here
-- 12] 7 | #include <Arduino.h>
```
confirmed that clang-tidy is finding the correct .clang-tidy file
```
$ clang-tidy-19 -dump-config src/main.cpp | grep HeaderFilter
HeaderFilterRegex: '^(?!/usr/share/arduino/|/opt/arduino/).*'
ExcludeHeaderFilterRegex: '/usr/share/arduino/.*|/opt/arduino/.*|.*/Arduino.h|.*/USBAPI.h'
```
I have tried many combinations of regexes for HeaderFilterRegex and EcludeHeaderFilterRegex:
```
# HeaderFilterRegx: '.*'
# HeaderFilterRegex: '^(?!/usr/share/arduino/|/opt/arduino/).*'
# HeaderFilterRegex: '^?!/usr/share.*'
# ExcludeHeaderFilterRegex : '/usr/share/arduino/.*'
# ExcludeHeaderFilterRegex : '/usr/share/arduino/.*|.*/USBAPI.h'
```
Is the ciruclar-header warning a special case? If so, what should these settings be to handle it?
https://github.com/llvm/llvm-project/pull/91400
More information about the cfe-commits
mailing list