When compiling from an already preprocessed CPP, the checksums generated in the debug info would be those of the (input) preprocessed CPP, not those of the actual #includes.
Note how all the files have the same checksum below:
** Module: "E:\RD\tests\clang_hash\main.obj" 0 E:\RD\tests\clang_hash\lib.h (MD5: 136293700AE501A1FB76EBD273C8D288) 1 C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\stdio.h (MD5: 136293700AE501A1FB76EBD273C8D288) 2 E:\RD\tests\clang_hash\main.cpp (MD5: 136293700AE501A1FB76EBD273C8D288) 3 C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_stdio_config.h (MD5: 136293700AE501A1FB76EBD273C8D288)
When debugging in Visual Studio an EXE linked with the OBJ above, Visual Studio complains about the source files being different from when they were compiled, since the sources are compared by hash.
This patch simply clears the checksums to match MSVC behavior. Visual Studio will simply bypass the hash checking in that case, and hapily open the source file.
** Module: "E:\RD\tests\clang_hash\main.obj" 0 c:\program files (x86)\windows kits\10\include\10.0.17763.0\ucrt\stdio.h (None) 1 c:\program files (x86)\windows kits\10\include\10.0.17763.0\ucrt\corecrt_wstdio.h (None) 2 c:\program files (x86)\windows kits\10\include\10.0.17763.0\ucrt\corecrt_stdio_config.h (None) 3 c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\include\vcruntime_new.h (None) 4 e:\rd\tests\clang_hash\main.cpp (None) 5 e:\rd\tests\clang_hash\lib.h (None)
We could write more complicated code to open the files from the corresponding #line directives, but we have no guarantee the preprocessed CPP is compiled in the same conditions as when it was pre-processed. Actually, when using Fastbuild, the files are preprocessed locally on the user's PC; then the preprocessed content is sent and compiled remotely on another PC that does not have the source code.
Thanks to Lambert Clara for the preliminary patch!