From fd8634a09de716f6de7b6699d6f4287056551525 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 23 Oct 2013 02:17:46 +0000 Subject: Make UsingShadowDecls redeclarable. This fixes some visibility problems with modules. With this fixed, I no longer see any test regressions in the libc++ test suite when enabling a single-module module.map for libc++ (other than issues with my system headers). llvm-svn: 193219 --- clang/lib/Serialization/ASTReaderDecl.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp') diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index e68c7fc6f9f..463af777986 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -1134,12 +1134,14 @@ void ASTDeclReader::VisitUsingDecl(UsingDecl *D) { } void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) { + RedeclarableResult Redecl = VisitRedeclarable(D); VisitNamedDecl(D); D->setTargetDecl(ReadDeclAs(Record, Idx)); D->UsingOrNextShadow = ReadDeclAs(Record, Idx); UsingShadowDecl *Pattern = ReadDeclAs(Record, Idx); if (Pattern) Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern); + mergeRedeclarable(D, Redecl); } void ASTDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { @@ -2151,6 +2153,12 @@ static bool isSameEntity(NamedDecl *X, NamedDecl *Y) { // FIXME: Also check the value is odr-equivalent. return true; + // Using shadow declarations with the same target match. + if (UsingShadowDecl *USX = dyn_cast(X)) { + UsingShadowDecl *USY = cast(Y); + return USX->getTargetDecl() == USY->getTargetDecl(); + } + // FIXME: Many other cases to implement. return false; } @@ -2258,6 +2266,8 @@ void ASTDeclReader::attachPreviousDecl(Decl *D, Decl *previous) { VD->RedeclLink.setNext(cast(previous)); } else if (TypedefNameDecl *TD = dyn_cast(D)) { TD->RedeclLink.setNext(cast(previous)); + } else if (UsingShadowDecl *USD = dyn_cast(D)) { + USD->RedeclLink.setNext(cast(previous)); } else if (ObjCInterfaceDecl *ID = dyn_cast(D)) { ID->RedeclLink.setNext(cast(previous)); } else if (ObjCProtocolDecl *PD = dyn_cast(D)) { @@ -2285,7 +2295,7 @@ void ASTDeclReader::attachLatestDecl(Decl *D, Decl *Latest) { TD->RedeclLink = Redeclarable::LatestDeclLink(cast(Latest)); } else if (FunctionDecl *FD = dyn_cast(D)) { - FD->RedeclLink + FD->RedeclLink = Redeclarable::LatestDeclLink(cast(Latest)); } else if (VarDecl *VD = dyn_cast(D)) { VD->RedeclLink @@ -2294,6 +2304,10 @@ void ASTDeclReader::attachLatestDecl(Decl *D, Decl *Latest) { TD->RedeclLink = Redeclarable::LatestDeclLink( cast(Latest)); + } else if (UsingShadowDecl *USD = dyn_cast(D)) { + USD->RedeclLink + = Redeclarable::LatestDeclLink( + cast(Latest)); } else if (ObjCInterfaceDecl *ID = dyn_cast(D)) { ID->RedeclLink = Redeclarable::LatestDeclLink( -- cgit v1.2.3