[cfe-commits] r115647 - in /cfe/trunk: lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp test/PCH/Inputs/chain-remap-types1.h test/PCH/Inputs/chain-remap-types2.h test/PCH/chain-remap-types.m tools/libclang/CIndexUSRs.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Wed Oct 6 04:43:02 PDT 2010
On 05.10.2010 20:37, Douglas Gregor wrote:
> Author: dgregor
> Date: Tue Oct 5 13:37:06 2010
> New Revision: 115647
>
> URL: http://llvm.org/viewvc/llvm-project?rev=115647&view=rev
> Log:
> Fix a marvelous chained AST writing bug, where we end up with the
> following amusing sequence:
> - AST writing schedules writing a type X* that it had never seen
> before
> - AST writing starts writing another declaration, ends up
> deserializing X* from a prior AST file. Now we have two type IDs for
> the same type!
> - AST writer tries to write X*. It only has the lower-numbered ID
> from the the prior AST file, so references to the higher-numbered ID
> that was scheduled for writing go off into lalaland.
>
> To fix this, keep the higher-numbered ID so we end up writing the type
> twice. Since this issue occurs so rarely, and type records are
> generally rather small, I deemed this better than the alternative: to
> keep a separate mapping from the higher-numbered IDs to the
> lower-numbered IDs, which we would end up having to check whenever we
> want to deserialize any type.
>
Well, there's the really nice but complicated version: dump ASTContext's
uniqueing table to AST files so that we can do uniqueing while
considering types not yet loaded. :-)
Sebastian
More information about the cfe-commits
mailing list