diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-06-16 20:26:19 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-06-16 20:26:19 +0000 |
commit | 675d279af405d594552613c40a1507516039c694 (patch) | |
tree | 0a261a5d60f673e2c1d0c83e9363ef8c070652a6 /clang/lib/Serialization/ASTReaderDecl.cpp | |
parent | 50f518be65ce3ea3be9ec06fcb103a752af18005 (diff) | |
download | bcm5719-llvm-675d279af405d594552613c40a1507516039c694.tar.gz bcm5719-llvm-675d279af405d594552613c40a1507516039c694.zip |
[modules] When we merge redecl chains or mark a decl used with an update
record, mark all subsequent decls as 'used' too, to maintain the AST invariant
that getPreviousDecl()->Used implies this->Used.
llvm-svn: 211050
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 7e652c47181..47748a33f76 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -2492,6 +2492,11 @@ void ASTDeclReader::attachPreviousDecl(Decl *D, Decl *Previous) { Previous->IdentifierNamespace & (Decl::IDNS_Ordinary | Decl::IDNS_Tag | Decl::IDNS_Type); + // If the previous declaration is marked as used, then this declaration should + // be too. + if (Previous->Used) + D->Used = true; + // If the previous declaration is an inline function declaration, then this // declaration is too. if (auto *FD = dyn_cast<FunctionDecl>(D)) { @@ -3280,7 +3285,14 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, case UPD_DECL_MARKED_USED: { // FIXME: This doesn't send the right notifications if there are // ASTMutationListeners other than an ASTWriter. - D->Used = true; + + // Maintain AST consistency: any later redeclarations are used too. + for (auto *Redecl = D->getMostRecentDecl(); /**/; + Redecl = Redecl->getPreviousDecl()) { + Redecl->Used = true; + if (Redecl == D) + break; + } break; } |