diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2013-07-12 18:54:40 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2013-07-12 18:54:40 +0000 |
commit | 9bdd1bb40317bd3545817634c4d06e1b27feecae (patch) | |
tree | c7e70da9b856d4bd1b1cfeaa05661146a155adbe /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 5f1ef3c8aafb137595531b2808c2e2382d1b5fa1 (diff) | |
download | bcm5719-llvm-9bdd1bb40317bd3545817634c4d06e1b27feecae.tar.gz bcm5719-llvm-9bdd1bb40317bd3545817634c4d06e1b27feecae.zip |
Revert r186040 to fix PR16597 while Richard investigates what the best
fix is.
Original commit log:
If we friend a declaration twice, that should not make it visible to
name lookup in the surrounding context. Slightly rework how we handle
friend declarations to inherit the visibility of the prior
declaration, rather than setting a friend declaration to be visible
whenever there was a prior declaration.
llvm-svn: 186185
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 14185c37ad1..b5a80d3f6a0 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -960,7 +960,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { else Inst->setAccess(D->getAccess()); - Inst->setObjectOfFriendDecl(); + Inst->setObjectOfFriendDecl(PrevClassTemplate != 0); // TODO: do we want to track the instantiation progeny of this // friend target decl? } else { @@ -1110,8 +1110,8 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) { // If the original function was part of a friend declaration, // inherit its namespace state. - if (D->getFriendObjectKind()) - Record->setObjectOfFriendDecl(); + if (Decl::FriendObjectKind FOK = D->getFriendObjectKind()) + Record->setObjectOfFriendDecl(FOK == Decl::FOK_Declared); // Make sure that anonymous structs and unions are recorded. if (D->isAnonymousStructOrUnion()) { @@ -1315,7 +1315,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, assert(isFriend && "non-friend has dependent specialization info?"); // This needs to be set now for future sanity. - Function->setObjectOfFriendDecl(); + Function->setObjectOfFriendDecl(/*HasPrevious*/ true); // Instantiate the explicit template arguments. TemplateArgumentListInfo ExplicitArgs(Info->getLAngleLoc(), @@ -1365,7 +1365,13 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, // If the original function was part of a friend declaration, // inherit its namespace state and add it to the owner. if (isFriend) { - PrincipalDecl->setObjectOfFriendDecl(); + NamedDecl *PrevDecl; + if (TemplateParams) + PrevDecl = FunctionTemplate->getPreviousDecl(); + else + PrevDecl = Function->getPreviousDecl(); + + PrincipalDecl->setObjectOfFriendDecl(PrevDecl != 0); DC->makeDeclVisibleInContext(PrincipalDecl); bool queuedInstantiation = false; @@ -1633,7 +1639,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, TemplateParams, Method); if (isFriend) { FunctionTemplate->setLexicalDeclContext(Owner); - FunctionTemplate->setObjectOfFriendDecl(); + FunctionTemplate->setObjectOfFriendDecl(true); } else if (D->isOutOfLine()) FunctionTemplate->setLexicalDeclContext(D->getLexicalDeclContext()); Method->setDescribedFunctionTemplate(FunctionTemplate); @@ -1660,7 +1666,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, TempParamLists.data()); Method->setLexicalDeclContext(Owner); - Method->setObjectOfFriendDecl(); + Method->setObjectOfFriendDecl(true); } else if (D->isOutOfLine()) Method->setLexicalDeclContext(D->getLexicalDeclContext()); |