<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59736>59736</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Incorrect `__LINE__` with `-frewrite-includes` and mixed CRLF
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
slonopotamus
</td>
</tr>
</table>
<pre>
## Way to reproduce
Create 1.cpp (CRLF line endings)
```cpp
#include "1.h"
```
Create 1.h (LF line endings)
```cpp
#if 1
static_assert(__LINE__ == 2, "");
#endif
```
Try to compile
```
$ clang++ -E -frewrite-includes 1.cpp | clang++ -c -x c++ -
In file included from 1.cpp:1:
./1.h:3:1: error: static assertion failed due to requirement '3 == 2':
static_assert(__LINE__ == 2, "");
^ ~~~~~~~~~~~~~
1 error generated.
```
## Tested on
```
$ clang++ --version
clang version 15.0.5
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/15/bin
Configuration file: /etc/clang/clang++.cfg
```
## Additional info
Bug **doesn't reproduce** if `-frewrite-includes` is omitted.
Bug **doesn't reproduce** if whitespace in front of `#if 1` is removed.
Bug **doesn't reproduce** if both `1.h` and `1.cpp` have same line endings.
Bug **reproduces** if CRLF/LF is swapped - `1.cpp` has LF and `1.h` has CRLF.
Bug **reproduces** if whitespace in front of `#if 1` is replaced with TAB.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVc9vqzgQ_mucyygIhkKSA4ekLVKlag-rSnuMjD2AV8ZmbdPmXfZvXxnINn37fu5DCIVhZr6Z7xtPuPeqM0QVK06seNjwKfTWVV5bY0cb-DD5TWPlp4phzjCHP_gnCBYcjc7KSRBLH1h6XJ73jnggyBIxjsBwf__7cw1aGQIyUpnOMzys_mW63GIcVwvmygg9SQKGmCU9Q_zM94tQfQT6cRgAgAjVQrYYfOBBiTP3nlxguD-fn59-ezyfg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