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

    <tr>
        <th>Summary</th>
        <td>
            clang-tidy ignores last check in .clang-tidy when combined with --checks command-line option
        </td>
    </tr>

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

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

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

<pre>
    Our .clang-tidy config file looks like this:
```
Checks: >
  clang-diagnostic-*,
  clang-analyzer-*,
  -clang-analyzer-osx.*,
  google-*,
  -google-objc-*,
  performance-*,
  portability-*,
  bugprone-*,
  -bugprone-narrowing-conversions,
  modernize-*,
  -modernize-use-nodiscard,
  -modernize-avoid-c-arrays,
  -modernize-pass-by-value,
  -modernize-use-trailing-return-type,
  readability-avoid-const-params-in-decls,
  readability-identifier-naming
...
```
When combining the config file with a custom check on a file, the generated config looks like this:
```
/usr/bin/clang-tidy-12 --dump-config --checks=-clang-analyzer-cplusplus.NewDeleteLeaks
---
Checks:          "clang-diagnostic-*,clang-analyzer-*,clang-diagnostic-*,\nclang-analyzer-*,\n-clang-analyzer-osx.*,\ngoogle-*,\n-google-objc-*,\nperformance-*,\nportability-*,\nbugprone-*,\n-bugprone-narrowing-conversions,\nmodernize-*,\n-modernize-use-nodiscard,\n-modernize-avoid-c-arrays,\n-modernize-pass-by-value,\n-modernize-use-trailing-return-type,\nreadability-avoid-const-params-in-decls,\nreadability-identifier-naming\n,-clang-analyzer-cplusplus.NewDeleteLeaks"
...
```
Running this combination of checks on a source file will ignore then `readability-identifier-naming` check. Looking at the dumped config, makes me suspect that it has to do with insufficient handling/stripping of the injected new line characters. Without the custom check, the config looks like this:
```
/usr/bin/clang-tidy-12 --dump-config
---
Checks:          "clang-diagnostic-*,clang-analyzer-*,clang-diagnostic-*,\nclang-analyzer-*,\n-clang-analyzer-osx.*,\ngoogle-*,\n-google-objc-*,\nperformance-*,\nportability-*,\nbugprone-*,\n-bugprone-narrowing-conversions,\nmodernize-*,\n-modernize-use-nodiscard,\n-modernize-avoid-c-arrays,\n-modernize-pass-by-value,\n-modernize-use-trailing-return-type,\nreadability-avoid-const-params-in-decls,\nreadability-identifier-naming\n"
...
```
which will apply the `readability-identifier-naming` check as expected. Also, when adding a trailing comma to as `readability-identifier-naming,` in the .clang-tidy file, it again works and the dumped config looks as:
```
Checks:          "clang-diagnostic-*,clang-analyzer-*,clang-diagnostic-*,\nclang-analyzer-*,\n-clang-analyzer-osx.*,\ngoogle-*,\n-google-objc-*,\nperformance-*,\nportability-*,\nbugprone-*,\n-bugprone-narrowing-conversions,\nmodernize-*,\n-modernize-use-nodiscard,\n-modernize-avoid-c-arrays,\n-modernize-pass-by-value,\n-modernize-use-trailing-return-type,\nreadability-avoid-const-params-in-decls,\nreadability-identifier-naming,\n,-clang-analyzer-cplusplus.NewDeleteLeaks"
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztlk1zozgQhn8NvqhE2dj448Ahm2xOUzNVe5lzgxpQIiRKEvF4fv22wE5ssJPsVu1p47JxoW51t8T7qMmNOGQ_OsviQoGuuJfiwAqjS1mxUipkyphnx5R8RuZr6aLlXTR_iOZ30Xp-_Pa39zUWz8HKouWfwxBjQ0ghodLGeVnwKLmLkvtLM2hQh99oR0Y-shr3K770qIypFI6nHUdN_jRO16ItjW1AF-NJrbEecqmkP4wseVe11uhJltdxDdaavaRKadNe0DpptDvzbIxAq-XvSYQ3Q-cojBHSFWDFdRd4MVLwglMyOLjrPi04x_MDfwHV4e1M3gItlOq16DuruT-0594WQZy24piVFuQpuoXGcam5wEK5GzOkQO1lKel5aWgoy-AUx_FV0fysUZPYmlxq8iV94YX09tLXDFjROW8aVgSFMaNpJFipgn5ChRoteBSnqZ8UbJQ8ds7SlZLT9U39fJEwzkXXtPwYkfPiqO6HsSqLVnUu_OLvuH9AhR6_IZ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