From 816d75b7012ac9fabbe134579ba1a1dba80a5f4f Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 24 Mar 2010 07:46:06 +0000 Subject: Support friend function specializations. llvm-svn: 99389 --- clang/lib/Sema/SemaAccess.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'clang/lib/Sema/SemaAccess.cpp') diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp index e74c8f60c38..5b1a9d880a9 100644 --- a/clang/lib/Sema/SemaAccess.cpp +++ b/clang/lib/Sema/SemaAccess.cpp @@ -53,10 +53,11 @@ bool Sema::SetMemberAccessSpecifier(NamedDecl *MemberDecl, namespace { struct EffectiveContext { - EffectiveContext() : Function(0), Dependent(false) {} + EffectiveContext() : Inner(0), Function(0), Dependent(false) {} - explicit EffectiveContext(DeclContext *DC) { - Dependent = DC->isDependentContext(); + explicit EffectiveContext(DeclContext *DC) + : Inner(DC), + Dependent(DC->isDependentContext()) { if (isa(DC)) { Function = cast(DC)->getCanonicalDecl(); @@ -86,14 +87,15 @@ struct EffectiveContext { != Records.end(); } - DeclContext *getPrimaryContext() const { - assert((Function || !Records.empty()) && "context has no primary context"); - if (Function) return Function; - return Records[0]; + /// Retrieves the innermost "useful" context. Can be null if we're + /// doing access-control without privileges. + DeclContext *getInnerContext() const { + return Inner; } typedef llvm::SmallVectorImpl::const_iterator record_iterator; + DeclContext *Inner; llvm::SmallVector Records; FunctionDecl *Function; bool Dependent; @@ -636,7 +638,7 @@ static void DelayAccess(Sema &S, SourceLocation Loc, const Sema::AccessedEntity &Entity) { assert(EC.isDependent() && "delaying non-dependent access"); - DeclContext *DC = EC.getPrimaryContext(); + DeclContext *DC = EC.getInnerContext(); assert(DC->isDependentContext() && "delaying non-dependent access"); DependentDiagnostic::Create(S.Context, DC, DependentDiagnostic::Access, Loc, -- cgit v1.2.3