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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] preprocessor line directives ignored in diagnostics
        </td>
    </tr>

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

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

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

<pre>
    Hello,

I'm trying to run `clang-tidy` on already preprocessed source files.
This is needed in order to distribute analysis over the network with FASTBuild.

But I can't get it to respect line directives, thus the messages do not make sense for the end-user because the line numbers are way off.

To repro (note that I'm on windows, but I confirmed that the behavior is the same on linux):

`a.cpp`
```cpp
#include <vector>
#include <string>

void foo(const std::string&);
int main()
{
 std::vector<std::string> ss;
        for (auto s : ss)
 foo(s);
}
```

Running
```shell
clang-cl.exe a.cpp -E > b.cpp
clang-tidy.exe --checks="-*,performance-for-range-copy" b.cpp -- --driver-mode=cl
```
outputs
```
1 warning generated.
D:\debug\b.cpp:26898:12: warning: loop variable is copied but only used as const reference; consider
 making it a const reference [performance-for-range-copy]
 for (auto s : ss)
           ^
 const  &
```

Furthermore, introducing a compilation error in `b.cpp` and compiling with `clang[-cl]` outputs an error message pointing to the correct file/line, but not under `clang-tidy`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VduO4jgTfhpzUwoKDgnhggsOg_65_bdfwLEribcdV-QDDPv0Kyehm2n1ToQC1MlfnT4L73VnEQ-sPLHyshIx9OQO4haVxX9WDanH4X9oDDF-ZvmF5cf5_ZPx3QDBPbTtIBC4aIFVuTTCdlnQ6sGqHMiCMA6FesDocHQk0XtU4Ck6idBqg349x3vrtQftwSIqVKAtkFPoUmilfXC6iQFBWGEeXnugW9L1CBbDndw73HXo4Xr86-0UtVHrV6inGOAnSGEZ3wXoMIAOE2T0I8oARlsEpR3KoG_o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