Author: Furkan Usta Date: 2022-06-15T15:52:59+02:00 New Revision: 462def25ec134d30aade4ffbf1ddc4185f2ec616
URL: https://github.com/llvm/llvm-project/commit/462def25ec134d30aade4ffbf1ddc4185f2ec616 DIFF: https://github.com/llvm/llvm-project/commit/462def25ec134d30aade4ffbf1ddc4185f2ec616.diff LOG: [clang] Use correct visibility parameters when following a Using declaration Fixes https://github.com/clangd/clangd/issues/1137 Reviewed By: kadircet Differential Revision: https://reviews.llvm.org/D127629 Added: Modified: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp clang/lib/Sema/SemaCodeComplete.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp index 316fcb6293b12..18b02af48095f 100644 --- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -413,6 +413,23 @@ TEST(CompletionTest, Accessible) { )cpp"); EXPECT_THAT(External.Completions, AllOf(has("pub"), Not(has("prot")), Not(has("priv")))); + + auto Results = completions(R"cpp( + struct Foo { + public: void pub(); + protected: void prot(); + private: void priv(); + }; + struct Bar : public Foo { + private: using Foo::pub; + }; + void test() { + Bar B; + B.^ + } + )cpp"); + EXPECT_THAT(Results.Completions, + AllOf(Not(has("priv")), Not(has("prot")), Not(has("pub")))); } TEST(CompletionTest, Qualifiers) { diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index d35e9c6e42bf2..ae2e71dcd5dac 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -1095,7 +1095,9 @@ void ResultBuilder::MaybeAddResult(Result R, DeclContext *CurContext) { if (const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) { CodeCompletionResult Result(Using->getTargetDecl(), getBasePriority(Using->getTargetDecl()), - R.Qualifier); + R.Qualifier, false, + (R.Availability == CXAvailability_Available || + R.Availability == CXAvailability_Deprecated)); Result.ShadowDecl = Using; MaybeAddResult(Result, CurContext); return; @@ -1268,7 +1270,9 @@ void ResultBuilder::AddResult(Result R, DeclContext *CurContext, if (const auto *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) { CodeCompletionResult Result(Using->getTargetDecl(), getBasePriority(Using->getTargetDecl()), - R.Qualifier); + R.Qualifier, false, + (R.Availability == CXAvailability_Available || + R.Availability == CXAvailability_Deprecated)); Result.ShadowDecl = Using; AddResult(Result, CurContext, Hiding); return; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits