diff options
author | Vassil Vassilev <v.g.vassilev@gmail.com> | 2016-04-27 10:46:06 +0000 |
---|---|---|
committer | Vassil Vassilev <v.g.vassilev@gmail.com> | 2016-04-27 10:46:06 +0000 |
commit | a4d7d783d04f15b65c749daa33baa3d94b1e5904 (patch) | |
tree | 39acf11e06deec8f291c0cb6fe09d20fde5b4bed /clang/lib/Serialization/ASTWriter.cpp | |
parent | 7c85a8cb46702e221f5d3eecc3c8e946b325eeb6 (diff) | |
download | bcm5719-llvm-a4d7d783d04f15b65c749daa33baa3d94b1e5904.tar.gz bcm5719-llvm-a4d7d783d04f15b65c749daa33baa3d94b1e5904.zip |
[modules] Fix Decl's Used invariant.
The Decl::isUsed has a value for every decl. In non-module builds it is very
difficult (but possible) to break this invariant but when we walk up the redecl
chain we find the neccessary information.
When deserializing the decls from a module it is much more difficult to update
correctly this invariant. The patch centralizes the information whether a decl
is used in the canonical decl marking the entire entity as being used.
Fixes https://llvm.org/bugs/show_bug.cgi?id=27401
Patch by Cristina Cristescu and me.
Thanks to Richard Smith who helped to debug and understand the issue!
Reviewed by Richard Smith.
llvm-svn: 267691
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 073ed674741..32c9c4787c4 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -5784,8 +5784,13 @@ void ASTWriter::AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, void ASTWriter::DeclarationMarkedUsed(const Decl *D) { assert(!WritingAST && "Already writing the AST!"); - if (!D->isFromASTFile()) - return; + + // If there is *any* declaration of the entity that's not from an AST file, + // we can skip writing the update record. We make sure that isUsed() triggers + // completion of the redeclaration chain of the entity. + for (auto Prev = D->getMostRecentDecl(); Prev; Prev = Prev->getPreviousDecl()) + if (IsLocalDecl(Prev)) + return; DeclUpdates[D].push_back(DeclUpdate(UPD_DECL_MARKED_USED)); } |