[PATCH] D20124: [PCH] Serialize skipped preprocessor ranges

Cameron via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 20 08:00:32 PST 2017


cameron314 added a comment.

In https://reviews.llvm.org/D20124#928552, @ilya-biryukov wrote:

> Why do we store raw source locations in `PPSkippedRange`? Would storing `SourceLocation` and using  `ASTWriter::AddSourceLocation` and `ASTReader:: ReadSourceLocation` do the trick?


I followed the pattern used to store `PPEntityOffset`s; it allows the entire array to be written in one chunk. Using `AddSourceLocation`/`ReadSourceLocation` boils down to the same thing -- `AddSourceLocation` simply rotates by one bit, and `ReadSourceLocation` simply rotates back and calls `ASTReader::TranslateSourceLocation` (which I call from `AST::ReadSkippedRange` explicitly instead). So the source location translation path is exactly the same either way.

The thing is, the PCH created for the preamble is imported as a module, meaning the part of the source code that overlaps the preamble of the entry file has a different file ID from the entry file itself. Is there any way to force source locations in the preamble to map to the actual entry file instead of the module's version of the entry file?


https://reviews.llvm.org/D20124





More information about the cfe-commits mailing list