diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2018-07-30 15:19:05 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2018-07-30 15:19:05 +0000 |
commit | 55b1b157b67c90b8e1adb70226fb9b39200eaf40 (patch) | |
tree | 0c8470ed05332a4857089f1d8a682d7971a42a7c /clang/lib/Sema/SemaCodeComplete.cpp | |
parent | 764b3d8cc59fbe3523c444d011f981aaec689d6d (diff) | |
download | llvm-55b1b157b67c90b8e1adb70226fb9b39200eaf40.zip llvm-55b1b157b67c90b8e1adb70226fb9b39200eaf40.tar.gz llvm-55b1b157b67c90b8e1adb70226fb9b39200eaf40.tar.bz2 |
[CodeComplete] Fix the crash in code completion on access checking
Started crashing in r337453. See the added test case for the crash repro.
The fix reverts part of r337453 that causes the crash and does
not actually break anything when reverted.
llvm-svn: 338255
Diffstat (limited to 'clang/lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 30 |
1 files changed, 2 insertions, 28 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 4e571eb..30af826 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -1303,34 +1303,8 @@ namespace { void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass) override { bool Accessible = true; - if (Ctx) { - DeclContext *AccessingCtx = Ctx; - // If ND comes from a base class, set the naming class back to the - // derived class if the search starts from the derived class (i.e. - // InBaseClass is true). - // - // Example: - // class B { protected: int X; } - // class D : public B { void f(); } - // void D::f() { this->^; } - // The completion after "this->" will have `InBaseClass` set to true and - // `Ctx` set to "B", when looking up in `B`. We need to set the actual - // accessing context (i.e. naming class) to "D" so that access can be - // calculated correctly. - if (InBaseClass && isa<CXXRecordDecl>(Ctx)) { - CXXRecordDecl *RC = nullptr; - // Get the enclosing record. - for (DeclContext *DC = CurContext; !DC->isFileContext(); - DC = DC->getParent()) { - if ((RC = dyn_cast<CXXRecordDecl>(DC))) - break; - } - if (RC) - AccessingCtx = RC; - } - Accessible = Results.getSema().IsSimplyAccessible(ND, AccessingCtx); - } - + if (Ctx) + Accessible = Results.getSema().IsSimplyAccessible(ND, Ctx); ResultBuilder::Result Result(ND, Results.getBasePriority(ND), nullptr, false, Accessible, FixIts); Results.AddResult(Result, CurContext, Hiding, InBaseClass); |