aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaAccess.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-03-24 07:46:06 +0000
committerJohn McCall <rjmccall@apple.com>2010-03-24 07:46:06 +0000
commit7ad650f88ecbbe659f10f9f6b34a1f29ea9cf8f9 (patch)
tree61e3a3d23e1318c3f00760c390ad5ff3f429c98d /lib/Sema/SemaAccess.cpp
parent2eef829b19bdc59976a827fa39b409440e352bff (diff)
Support friend function specializations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99389 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaAccess.cpp')
-rw-r--r--lib/Sema/SemaAccess.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/Sema/SemaAccess.cpp b/lib/Sema/SemaAccess.cpp
index e74c8f60c3..5b1a9d880a 100644
--- a/lib/Sema/SemaAccess.cpp
+++ b/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<FunctionDecl>(DC)) {
Function = cast<FunctionDecl>(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<CXXRecordDecl*>::const_iterator record_iterator;
+ DeclContext *Inner;
llvm::SmallVector<CXXRecordDecl*, 4> 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,