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.
https://llvm.org/bugs/show_bug.cgi?id=27401
Details
- Reviewers
rsmith
Diff Detail
- Repository
- rL LLVM
Event Timeline
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).
lib/AST/DeclBase.cpp | ||
---|---|---|
349 | You should check for this attribute on the most recent declaration instead (attributes accumulate along the redeclaration chain). | |
359 | I think it's fine either way. | |
lib/Serialization/ASTReaderDecl.cpp | ||
3863 | 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). |
You should check for this attribute on the most recent declaration instead (attributes accumulate along the redeclaration chain).