diff options
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 19113da7e3c..cd232251e23 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -1216,6 +1216,7 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) { VD->VarDeclBits.TSCSpec = Record[Idx++]; VD->VarDeclBits.InitStyle = Record[Idx++]; if (!isa<ParmVarDecl>(VD)) { + VD->NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = Record[Idx++]; VD->NonParmVarDeclBits.ExceptionVar = Record[Idx++]; VD->NonParmVarDeclBits.NRVOVariable = Record[Idx++]; VD->NonParmVarDeclBits.CXXForRangeDecl = Record[Idx++]; @@ -3069,6 +3070,29 @@ void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader, namespace clang { template<> void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader, + Redeclarable<VarDecl> *D, + Decl *Previous, Decl *Canon) { + VarDecl *VD = static_cast<VarDecl*>(D); + VarDecl *PrevVD = cast<VarDecl>(Previous); + D->RedeclLink.setPrevious(PrevVD); + D->First = PrevVD->First; + + // We should keep at most one definition on the chain. + if (VD->isThisDeclarationADefinition()) { + for (VarDecl *CurD = PrevVD; CurD; CurD = CurD->getPreviousDecl()) { + // If we find an already demoted definition, this we already visited this + // part of the chain. Reduces the loop from quadratic-time to linear-time. + if (CurD->isThisDeclarationADemotedDefinition() || + CurD->isThisDeclarationADefinition()) { + VD->demoteThisDefinitionToDeclaration(); + break; + } + } + } +} + +template<> +void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader, Redeclarable<FunctionDecl> *D, Decl *Previous, Decl *Canon) { FunctionDecl *FD = static_cast<FunctionDecl*>(D); |