diff options
author | John McCall <rjmccall@apple.com> | 2015-09-09 23:04:17 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2015-09-09 23:04:17 +0000 |
commit | f4a1b771574d63819e297204d09cc507a1ddd18f (patch) | |
tree | c37e1dc04d24aae556f4c6e928eb042c817f36b9 /clang/lib/Sema/SemaLookup.cpp | |
parent | eee657045f83304db40ebc63ed7c2b93e127d9f0 (diff) | |
download | bcm5719-llvm-f4a1b771574d63819e297204d09cc507a1ddd18f.tar.gz bcm5719-llvm-f4a1b771574d63819e297204d09cc507a1ddd18f.zip |
Fix access control for lookups using the Microsoft __super extension.
rdar://22464808
llvm-svn: 247207
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index dc23c13fbb3..923da4e06b6 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -2098,17 +2098,30 @@ bool Sema::LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, /// /// @returns True if any decls were found (but possibly ambiguous) bool Sema::LookupInSuper(LookupResult &R, CXXRecordDecl *Class) { + // The access-control rules we use here are essentially the rules for + // doing a lookup in Class that just magically skipped the direct + // members of Class itself. That is, the naming class is Class, and the + // access includes the access of the base. for (const auto &BaseSpec : Class->bases()) { CXXRecordDecl *RD = cast<CXXRecordDecl>( BaseSpec.getType()->castAs<RecordType>()->getDecl()); LookupResult Result(*this, R.getLookupNameInfo(), R.getLookupKind()); Result.setBaseObjectType(Context.getRecordType(Class)); LookupQualifiedName(Result, RD); - for (auto *Decl : Result) - R.addDecl(Decl); + + // Copy the lookup results into the target, merging the base's access into + // the path access. + for (auto I = Result.begin(), E = Result.end(); I != E; ++I) { + R.addDecl(I.getDecl(), + CXXRecordDecl::MergeAccess(BaseSpec.getAccessSpecifier(), + I.getAccess())); + } + + Result.suppressDiagnostics(); } R.resolveKind(); + R.setNamingClass(Class); return !R.empty(); } |