This is an archive of the discontinued LLVM Phabricator instance.

Fix for Bug 27401. Always mark the canonical Decl as used.
Needs ReviewPublic

Authored by CrisCristescu on Apr 20 2016, 3:16 AM.



As discussed, when checking for the usage of a Decl, the module merging might not detect
that it has been already marked as used in the Redeclarables chain.
Always marking the canonical Decl ensures consistency.

Diff Detail


Event Timeline

CrisCristescu retitled this revision from to Fix for Bug 27401. Always mark the canonical Decl as used..
CrisCristescu updated this object.
CrisCristescu added a reviewer: rsmith.
CrisCristescu set the repository for this revision to rL LLVM.
CrisCristescu added a project: Restricted Project.
CrisCristescu updated this object.
rsmith edited edge metadata.Apr 20 2016, 10:06 AM

You also need to update ASTDeclReader::VisitDecl to set the Used flag on the canonical declaration. ASTWriter::DeclarationMarkedUsed should also be updated to only create an update record when necessary; if there is *any* declaration of the entity that's not from an AST file, we can skip writing the update record (but we should make sure that isUsed() triggers completion of the redeclaration chain of the entity if we're going to serialize / deserialize the flag on individual Decls).


You should check for this attribute on the most recent declaration instead (attributes accumulate along the redeclaration chain).


I think it's fine either way.


You need to be careful to avoid this causing a downstream ASTWriter to write an update record. You can set the Used flag directly, as we did before (and keep the FIXME above which notes that doing so isn't entirely correct).

CrisCristescu edited edge metadata.
CrisCristescu changed the edit policy from "All Users" to "Subscribers".Apr 21 2016, 7:46 AM
CrisCristescu added a subscriber: v.g.vassilev.