[clang][modules] Account for non-affecting inputs in `ASTWriter`
authorJan Svoboda <jan_svoboda@apple.com>
Wed, 2 Nov 2022 02:23:51 +0000 (19:23 -0700)
committerJan Svoboda <jan_svoboda@apple.com>
Wed, 2 Nov 2022 02:31:51 +0000 (19:31 -0700)
commit6924a49690eee074f6c341d3ada4e98d640b8a7e
tree63a3258325eb1952b80a795c4252f1e7fce6e2aa
parenta13122c612a653026b2ac220e220c50783c3aa82
[clang][modules] Account for non-affecting inputs in `ASTWriter`

In D106876, we stopped serializing module map files that didn't affect compilation of the current module.

However, since each `SourceLocation` is simply an offset into `SourceManager`'s global buffer of concatenated input files in, these need to be adjusted during serialization. Otherwise, they can incorrectly point after the buffer or into subsequent input file.

This patch starts adjusting `SourceLocation`s, `FileID`s and other `SourceManager` offsets in `ASTWriter`.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D136624
clang/include/clang/Serialization/ASTWriter.h
clang/lib/Serialization/ASTWriter.cpp
clang/test/Modules/add-remove-irrelevant-module-map.m