[cfe-commits] Source Manager Changes
Sebastian Redl
sebastian.redl at getdesigned.at
Thu Sep 30 11:17:34 PDT 2010
Hi,
This is the first big set of changes towards supporting modules, and I'd like to get some feedback before I commit back to mainline, because the changes are pretty intrusive.
The diff contains three patches. The first two are pretty trivial, the third one is the big one.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sourcemanager.patch
Type: application/octet-stream
Size: 235578 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100930/4ed8c52b/attachment.obj>
-------------- next part --------------
commit 8b5446bb49c2564881bc7bb42992067c8e2d9489
Author: Sebastian Redl <sebastian.redl at getdesigned.at>
Date: Sat Sep 25 21:51:45 2010 -0700
Upcoming changes will make chained PCH the only way of PCH reuse, so make it the default and remove the compiler option.
commit f47170746fe2e65d9c30cd23a77fbc0460851d3f
Author: Sebastian Redl <sebastian.redl at getdesigned.at>
Date: Fri Sep 17 11:33:43 2010 -0700
Record module loaders and module source order.
commit 20d90a2f8204bd145f3d97f2d2bc5dd9642a9ed2
Author: Sebastian Redl <sebastian.redl at getdesigned.at>
Date: Sat Sep 25 21:25:23 2010 -0700
1) Change the source manager to allocate locations for directly parsed files and files loaded from modules separately.
The purpose of this is to keep the locations for the directly parsed locations in one block, without loaded modulesgetting mixed in. This is necessary in order to efficiently write out a new module.
First, this makes FileID a wrapper for a signed int instead of an unsigned. Positive IDs are local (directly parsed). 0 is the invalid ID, -1 the tombstone. -2 and below are the IDs for loaded files.
Second, source locations for local files are allocated at the low end of the address space, those for loaded files at the upper end.
The source manager keeps the SLocEntries for those two blocks in separate vectors. The one for local entries works as previously, while the one for loaded entries is sorted in the opposite direction.
The downside is that source locations are now different between using an include file directly and using a PCH. This means that you cannot create a PCH that contains both the current file and another PCH you include. The only way to reuse PCH data now is to use chained PCH.
2) Change serialization to make use of this new model, and be able to load additional files at any time, remapping source locations as they are loaded.
Most importantly, this means that the module from which any given source location is loaded must be known. Since just about everything has source locations, this means threading PerFileData arguments throughout most functions.
Source locations also needs to be remapped in the stored diagnostics of ASTUnit. This carries a slight change to how ASTUnit stores diagnostics in general.
Line table serialization also needs some fixes. The line table gets promoted out of the source manager block into the main block, since it has no business being in the source manager block. More importantly, it has to come after the source location offsets record, which has to come after the source manager block.
3) Synthesize include locations for loaded files when they don't have one, unless the AST file is the main compiler input. This allows the source manager to assume that all include trees are rooted in the main file, except for the built-ins buffer.
4) There are now only two PCHLevels for declarations. 0 means directly parsed, or from a precompiled preamble, or from an AST main input file. 1 means from a PCH or a module. Should change this to a bool soon.
Sebastian
More information about the cfe-commits
mailing list