r190016 - Note when a decl is used in AST files.

Eli Friedman eli.friedman at gmail.com
Wed Sep 4 18:52:49 PDT 2013


On Wed, Sep 4, 2013 at 6:32 PM, Richard Smith <richard at metafoo.co.uk> wrote:

> On Wed, Sep 4, 2013 at 6:07 PM, Eli Friedman <eli.friedman at gmail.com>wrote:
>
>> With this commit, I'm hitting the following assertion:
>>
>> Assertion failed: (!WritingAST && "Already writing the AST!"), function
>> DeclarationMarkedUsed, file
>> /Volumes/storage/llvm/tools/clang/lib/Serialization/ASTWriter.cpp, line
>> 5376.
>>
>> (Unfortunately, it's going to be a bit difficult to reduce.)
>>
>> Basically, what happens is that ASTWriter::WriteASTCore() calls
>> ASTReader::updateOutOfDateIdentifier(), which eventually calls
>> ASTDeclReader::UpdateDecl, which explodes because we're updating the AST in
>> the middle of writing it.
>>
>> What do you think of moving the loop which call updateOutOfDateIdentifier
>> out into ASTWriter::WriteAST, before we set WritingAST to true?
>>
>
> No objection to that change, but I'm pretty sure there are other parts of
> the AST writer that trigger deserialization of AST nodes. Another
> possibility:
>
> +    case UPD_DECL_MARKED_USED: {
> +      D->markUsed(Reader.getContext());
> +      break;
>
> Do you need to use markUsed here, rather than setIsUsed? We already have
> an appropriate update record for this declaration in whichever AST file
> we're loading.
>
>
>
I'm not sure I really understand how this needs to work.  I mean, the
ASTWriter doesn't really care if it doesn't get notified: any update record
has to come from a file which the file its writing depends on.  On the
other hand, other users of ASTMutationListener (are the any?) might care:
if the decl got deserialized before the AST file with the update was
included, they might miss an update caused by loading an AST file.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130904/97f197e1/attachment.html>


More information about the cfe-commits mailing list