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

    <tr>
        <th>Summary</th>
        <td>
            Clang-tidy and #include directive in cpp file
        </td>
    </tr>

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

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

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

<pre>
    Hi!
I'm trying to use clang-tidy with FastBuild, and I encountered a problem when applying clang-tidy to the unity file. The main idea behind the FastBuild utility is to merge source files into one big source file using the '#include' directive. A typical unity file looks like this:
```cpp
#include "source1.cpp"
#include "source2.cpp"
#include "source3.cpp"
```
When I try to apply clang-tidy to this unity file, it doesn't analyze the listed sources. To fix this issue, I can use the --header-filter option with the following value:
```
--header-filter="dir_with_unity_files/*"
or
--header-filter=".*\.cpp"
```
Is this the correct behaviour?

Here is a minimal project example
```cpp
//-------- include/source1.h
void foo1();

//-------- include/source2.h
void foo2();

//-------- source/main.cpp

#include "source1.h"
#include "source2.h"

// OK  : clang -I include source/main.cpp source/source1.cpp source/source2.cpp
// OK  : clang -I include unity/unity.cpp
// OK  : clang-tidy --checks=google-readability-casting source/source1.cpp -- -I include
// FAIL: clang-tidy --checks=google-readability-casting unity/unity.cpp -- -I include
// FAIL: clang-tidy --header-filter="include/*" --checks=google-readability-casting unity/unity.cpp -- -I include
// OK  : clang-tidy --header-filter="include/*|unity/*" --checks=google-readability-casting unity/unity.cpp -- -I include
// OK  : clang-tidy --header-filter="include/*|.*\.cpp" --checks=google-readability-casting unity/unity.cpp -- -I include

int main() {
    foo1();
 foo2();
    return 0;
}

//-------- source/source1.cpp
#include <iostream>
void foo1() {
    std::cerr << "foo1: " << (int)1.1 << "\n";
}

//-------- source/source2.cpp
#include <iostream>
void foo2() {
    std::cerr << "foo2: " << (int)2.2 << "\n";
}

//-------- unity/unity.cpp
#include "..\source\main.cpp"
#include "..\source\source1.cpp"
#include "..\source\source2.cpp"
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVs1u4zYQfhr6MpAgjWzLPujgOBXWaIFeFugxoMWxxQ1FGiSVrPv0BSnHVhIn2QQt0CCQLHJ-P34zHO6c3Guiis1u2Ox2wnvfGlsdjPrB7_NFPtkacay-SYY5y25ZttowLDvw9ij1HryB3hE0iut94qU4wqP0LdTc-ZteKsFwDVwL2ADpxvTakyUBHA7WbBV18NiSBn44qGhtZMYb8C1Br6U_wk4qSuF7S9BxqUEK4rClVmoRhc7eoPdSBQXpgoGO7J7Amd42FG04kNobMJpgK_fjHehdTKclYFgyLKRuVC-IYQlCWmq8fKAUVuCPB9lwNQoMlDH3DpS8J_CtdKxYDUCxeTb8N4fDaeVsFxji4D5Pwzbi2xL4oUTxXOLJ7_D5V4B4Ew4sYBKxfgW0dKOEwplJD8KQ0wxLD1xzdfybIjpKOk_iBJ1L4buBnfw5mJDO9VF7Aw3XkRhBJUla4oJsspPKkwVz8NLogShhf2eUMo8B_geuenqN3_D5wgwrbhmikPYuGLqL4d_FQ2ZYM1yd4TD2Hf00SM7W7-G3cUN2IdTG2MCFQD7-IE1vWVGflOLzG1kK5OPQSS07rgLRfwQN-sm7g6K3mVEzrJPTH5zZVz-RpB3kHowUsDMmZ7hguGTFzdj9B1bwpRX8FSuDLsM61F56ifgdRrcf8Hm0P_IIf_4OwIrVwE5INk8JvA7hsjIqopeLmL6A920HkT0M6_h-X22omiRpWmruHStu98bsFSWWuODb2H6Shjsf-Hw1yiQZeX7mp15t_viSn1fhf9bJlcq4kGcopv8glKu4fhhKuX7y8b8L7Hk3-VcDi0-pfbwBh7IFVp7qFgCuNYVrJR5ELfneasgudV_e_koDGF9Yr6q7WEvjvCXeseK3q83qebzOi9Dpi1VD1gZ1VqxDj4jyxSr8vKwupPYMl3majyTZbK3D60tZ4KezwE9mgW9lgSl-OYs3G9W4zaYpm61P-c7W57Z9vSc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