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

    <tr>
        <th>Summary</th>
        <td>
            clang-tidy: readability-identifier-naming - false positive with InheritParentConfig + VariableIgnoredRegexp + library macro
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          feltech
      </td>
    </tr>
</table>

<pre>
    I happened upon this issue when attempting to use the [trompeloeil](https://github.com/rollbear/trompeloeil) mocking framework, which provides macros that give access to method parameters as `_1`, `_2` etc placeholders.

These placeholders, despite being defined outside the project, cause `readability-identifier-naming` to trigger.

Adding a `VariableIgnoredRegexp` in the top-level `.clang-tidy` works to allow these placeholders. But ideally we would only allow them in a child `.clang-tidy` under the test directory and make use of `InheritParentConfig`.  However, for some reason this doesn't work.

Here is a minimal reproducible example, using CMake's built-in clang-tidy support (tested with `clang-tidy-12`):

[clang-tidy-bug-inherit-checkoptions.zip](https://github.com/llvm/llvm-project/files/8428243/clang-tidy-bug-inherit-checkoptions.zip)

This simply has a library header (outside the source tree) that defines a macro 
```
#define SOMEMACRO(code) int _1 = 0; code;
```
The `main.cpp` then uses this macro as `SOMEMACRO(_1 = 2)`.  This is sufficient to trigger
```
/usr/local/bin/cmake --build /home/dave/workspace/clang-tidy-bug-inherit-checkoptions/src/cmake-build-debug --target all
[1/2] Building CXX object CMakeFiles/clang_tidy_bug_inherit_checkoptions.dir/main/main.cpp.o
/home/dave/workspace/clang-tidy-bug-inherit-checkoptions/src/main/main.cpp:5:3: warning: invalid case style for variable '_1'; cannot be fixed automatically [readability-identifier-naming]
  SOMEMACRO(_1 = 2)
  ^
/home/dave/workspace/clang-tidy-bug-inherit-checkoptions/src/../somelib/somelib.hpp:2:29: note: expanded from macro 'SOMEMACRO'
#define SOMEMACRO(code) int _1 = 0; code;
```
despite a local `.clang-tidy` of
```
InheritParentConfig: true

CheckOptions:
  - { key: readability-identifier-naming.VariableIgnoredRegexp,  value: ".*"   }
```
Moving the `VariableIgnoredRegexp` to the top-level `.clang-tidy` does successfully suppress the warning.






</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVl1v4jgU_TXhxSICB0r7wEM_Bk0fqq5mR6t5Q05yQ7x14sh2oOyv33MdaOksnc5KlUjikOv7cXzOtXNb7pf3olZdRy2Vou9sK0KtvdDe9yR2NbVChUBNF3S7EcGK3hMsSCTzm-Bs05GxpE0yv0vkZR1C55PsOpEr_DY61H2eFrbBi7PG5KQchqfT5JVobPHEviunGtpZ95TIWwTWRS06Z7e6JC8aVTjrEVcFsdFbEqooyHvOp6FQ21J0iqcHcl4oL5KLyXqKG7viscRNUChEZ1RBtTUlDNNkcpdMrof795pQ2OlnnovYnQ4kcuIMS6o0o2T74JFWhAEp_k1FYONCMTaI5EiVKtdGh_0Ydm3QlSY3blUDL5wJ0g5Obzbk3uRwXZYcRrGPv5TTKjd0v2mto_Ibbei547m6jXGD7caGtmTYOC2MajfjoMs9mzCIERtljN2x-U-lpeKmDwKpwWAvdlhn2xvU1eLtZU7DoZQoao1P_w3St_A0pEI-iFI7wGAdHLQl1uuJIlNsxVPv25qcDn8oBzBubVtphiEV4qvdoQbH6FXWCW8bEkDPH1lYWvJtIhch1vQGrK_kCCxFhkBVN8pgIhaj7AsN2AQ9q6YzxJ57z6jePiAnuPIi77UJYxT3WpDwfddZFwRIzOVgkXdgL-f-ajSeykipK2b4SSZQwolR3m_gO9Y7LmoqniykY1uf_qO7D1VizPb4GL8wa1VpQ6Dj6nImL-Usw-h34yHXNxwHXl4Dlz0kz9AZnTuFNavBWKwmkjvltre9KzB0RCzUqL5BAxF21qQ4-Acuw294ldlgJ_58fPjycH377RGuC1tGP7oNYj0VSXYnJkl2I-L_2c1ZT9_rqKhG6TYtuiiAwD0J3PIDRYY0Bs2fRjtEkIxB5Nr3oa1h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