<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58386>58386</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] InheritParentConfig search does not work with the --config-file flag
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
chih-hung
</td>
</tr>
</table>
<pre>
When clang-tidy has a config file specified by the --config-file flag,
the InheritParentConfig option in the file does not inherit
parent config files. The search of parent config files starts
from the source file directory, not the config file directory.
The following config files and commands show the problme.
```
$ cat s1/s2/.clang-tidy
---
InheritParentConfig: true
Checks: '-clang*,cert-msc30-c'
...
$ cat s1/.clang-tidy
---
Checks: '-clang*,misc-static-assert'
...
$ cat d1/d2/.clang-tidy
---
InheritParentConfig: true
Checks: '-clang*,cert-con54-cpp'
...
$ cat d1/.clang-tidy
---
Checks: '-clang*,google-runtime-int'
...
# correct inheritance of .clang-tidy from source file directories
$ clang-tidy --list-checks s1/s2/x.c --
Enabled checks:
cert-msc30-c
misc-static-assert
$ clang-tidy --list-checks d1/d2/x.c --
Enabled checks:
cert-con54-cpp
google-runtime-int
# With --config-file=s1/s2/.clang-tidy,
# inheritance search from source directory d1/d2 but not from s1/s2.
$ clang-tidy --list-checks --config-file=s1/s2/.clang-tidy d1/d2/x.c --
Enabled checks:
cert-con54-cpp
cert-msc30-c
google-runtime-int
$ clang-tidy --list-checks --config-file=s1/s2/.clang-tidy tmp/x.c --
Enabled checks:
cert-msc30-c
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VUtvnDAQ_jVwsYxY8wgcOKSbRuqth0o5G2PAjbGRbbrNv-9gwi4bkSZtWoR4zIzn--bhca2bp-qh5woxSVWHnWieUE8toohp1YoOtUJyZEfORCt4g-on5HqOMF7U2KtbSbuAHIP4LohvZ_UX1XMj3FdquHLHxZEendAKCeUd-HWN5hYp7UDo7RcHo1-1xbcR-gZrLKeG9Ui3aMcEWUeNs4uL1ujBw1g9GbaiCcOZ0-YJqHrU2WAb5dkgWrwszxm51VLqk1DdNSRVDQiGAd6A3-uTdzkaXcuBr07y-PlefkmKGHXIHgJybwk8okvmFxOM8fKxk8UguUXOTHwxOPacPdpZFpAb7P0EBCCOjBuHB8uSGDNQLdZRdBXXFZPXSbyKMQjLMCTdCYaptYD4FlIzIzX_NWYoT5ZiNo7v4vIXUXdad5JjMyknBo6F-k3UCTSHmVtq7W-qoBehfTe4yLfqXpsKbjeULwswlsJCpJ7hpo9-Rgyt9D8rWkvYrWwNYxEjuK5a4yzdKebLpL3G4FLVP2FwKdRZvpPaF-l8EK6_Hj1Bcre_k9ZpNC_bZv95hmyzft72ayionpwfEIvV4j96RyreRe3fJWy_lG-l8cP83TB-pN1eDMSQV4c8z4oizdIybKqkKZOShk44yasg-7SpaXa3e7A8l_R8mJy0eUSnuVX2T6pwMrLqnRs9U3IPdwfWUx3BLIcfKX-sLwyz_Ds0B_wKayfYkeQ-K5IiD_sqY3VZ5mlK2pwd8pryJikPcZ4XBS8YK9tQ0ppLO8cQEKL4CXkX8A2BhKIiMSGH-JDHh5SQMqJlU9bZTVzElBRl0gZpzAcqZDTziLTpQlN5SvXUWVDOdbMXJWxa0SnuUzb7p5PrtalYL3rcT6oLPXjlyf8C_Cpzbw">