[clang] [ASTWriter] Detect more non-affecting FileIDs to reduce source location duplication (PR #112015)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 5 06:31:20 PST 2024


ilya-biryukov wrote:

> This is unexpected and I think it breaks the correctness of clang-scan-deps. I think we might need to take your patch a bit further and make it so that `ASTWriter::WriteInputFiles()` doesn't care whether the SLocEntry associated with the file through `Module::DefinitionLoc` is loaded or local.

I want to dig into it a little more, but the problem is not introduced with this PR, so I suggest to do this in a follow-up in the interest of keeping this PR focused.

The particular challenge on my mind that makes it worth exploring in a different PR is that `InputFileRef`s that are written for two purposes:
- as ways to implement clang-scan-deps (e.g. `IsModuleMapFile` and `IsTopLevel` flags seem to be used solely by clang-scan-deps),
- as a way to write internal `SourceManager` data structures (`SLocEntry`). This seems to be the primary purposes for which they were introduced into the serialized format (I didn't check the history, though, it's just a guess).

It might be desirable to write some loaded locations for the former, but it goes against the idea for the latter.

https://github.com/llvm/llvm-project/pull/112015


More information about the cfe-commits mailing list