summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCodeComplete.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2018-10-22 08:47:31 +0000
committerEric Liu <ioeric@google.com>2018-10-22 08:47:31 +0000
commit2bfd3f5eb7fbc52ca5943964b242c2c51d46ed9c (patch)
tree6efe675bd8381b9d93fbbe04c3f1ea51a2eb882b /clang/lib/Sema/SemaCodeComplete.cpp
parentea656472545d53f4dba0f0524716805797253ea1 (diff)
downloadbcm5719-llvm-2bfd3f5eb7fbc52ca5943964b242c2c51d46ed9c.tar.gz
bcm5719-llvm-2bfd3f5eb7fbc52ca5943964b242c2c51d46ed9c.zip
[CodeComplete] Fix accessibility of protected members when accessing members implicitly.
Reviewers: ilya-biryukov Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53369 llvm-svn: 344889
Diffstat (limited to 'clang/lib/Sema/SemaCodeComplete.cpp')
-rw-r--r--clang/lib/Sema/SemaCodeComplete.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 303d96be7a2..a6799c5c297 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -3686,13 +3686,20 @@ void Sema::CodeCompleteOrdinaryName(Scope *S,
}
// If we are in a C++ non-static member function, check the qualifiers on
- // the member function to filter/prioritize the results list.
- if (CXXMethodDecl *CurMethod = dyn_cast<CXXMethodDecl>(CurContext))
- if (CurMethod->isInstance())
+ // the member function to filter/prioritize the results list and set the
+ // context to the record context so that accessibility check in base class
+ // works correctly.
+ RecordDecl *MemberCompletionRecord = nullptr;
+ if (CXXMethodDecl *CurMethod = dyn_cast<CXXMethodDecl>(CurContext)) {
+ if (CurMethod->isInstance()) {
Results.setObjectTypeQualifiers(
Qualifiers::fromCVRMask(CurMethod->getTypeQualifiers()));
+ MemberCompletionRecord = CurMethod->getParent();
+ }
+ }
- CodeCompletionDeclConsumer Consumer(Results, CurContext);
+ CodeCompletionDeclConsumer Consumer(Results, CurContext, /*FixIts=*/{},
+ MemberCompletionRecord);
LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
CodeCompleter->includeGlobals(),
CodeCompleter->loadExternal());
OpenPOWER on IntegriCloud