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

Argyrios Kyrtzidis kyrtzidis at apple.com
Thu Sep 5 10:55:34 PDT 2013


On Sep 4, 2013, at 6:52 PM, Eli Friedman <eli.friedman at gmail.com> wrote:

> 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.

You could also just ignore the ASTWriter::DeclarationMarkedUsed notification if writing the AST has started (WritingAST == true).

> 
> -Eli
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130905/44bd49fa/attachment.html>


More information about the cfe-commits mailing list