Author: Sam McCall Date: 2021-08-12T23:46:08+02:00 New Revision: 08c04ca00542bc2605e7c5d723f8cf478f012f61
URL: https://github.com/llvm/llvm-project/commit/08c04ca00542bc2605e7c5d723f8cf478f012f61 DIFF: https://github.com/llvm/llvm-project/commit/08c04ca00542bc2605e7c5d723f8cf478f012f61.diff LOG: [clangd] Overload bundles are only deprecated if each overloads is. Fixes https://github.com/clangd/clangd/issues/705 Differential Revision: https://reviews.llvm.org/D97803 Added: Modified: clang-tools-extra/clangd/CodeComplete.cpp clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp index b36cfd4ba00c..588161e65133 100644 --- a/clang-tools-extra/clangd/CodeComplete.cpp +++ b/clang-tools-extra/clangd/CodeComplete.cpp @@ -282,6 +282,7 @@ struct CodeCompletionBuilder { : ASTCtx(ASTCtx), EnableFunctionArgSnippets(Opts.EnableFunctionArgSnippets), IsUsingDeclaration(IsUsingDeclaration), NextTokenKind(NextTokenKind) { + Completion.Deprecated = true; // cleared by any non-deprecated overload. add(C, SemaCCS); if (C.SemaResult) { assert(ASTCtx); @@ -310,8 +311,6 @@ struct CodeCompletionBuilder { return std::tie(X.range.start.line, X.range.start.character) < std::tie(Y.range.start.line, Y.range.start.character); }); - Completion.Deprecated |= - (C.SemaResult->Availability == CXAvailability_Deprecated); } if (C.IndexResult) { Completion.Origin |= C.IndexResult->Origin; @@ -333,7 +332,6 @@ struct CodeCompletionBuilder { } Completion.RequiredQualifier = std::string(ShortestQualifier); } - Completion.Deprecated |= (C.IndexResult->Flags & Symbol::Deprecated); } if (C.IdentifierResult) { Completion.Origin |= SymbolOrigin::Identifier; @@ -409,6 +407,14 @@ struct CodeCompletionBuilder { /*CommentsFromHeader=*/false)); } } + if (Completion.Deprecated) { + if (C.SemaResult) + Completion.Deprecated &= + C.SemaResult->Availability == CXAvailability_Deprecated; + if (C.IndexResult) + Completion.Deprecated &= + bool(C.IndexResult->Flags & Symbol::Deprecated); + } } CodeCompletion build() { diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp index cfa2def7a615..3170099b437b 100644 --- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -1657,7 +1657,7 @@ TEST(CompletionTest, OverloadBundling) { std::string Context = R"cpp( struct X { // Overload with int - int a(int); + int a(int) __attribute__((deprecated("", ""))); // Overload with bool int a(bool); int b(float); @@ -1695,6 +1695,7 @@ TEST(CompletionTest, OverloadBundling) { EXPECT_EQ(A.ReturnType, "int"); // All overloads return int. // For now we just return one of the doc strings arbitrarily. ASSERT_TRUE(A.Documentation); + ASSERT_FALSE(A.Deprecated); // Not all overloads deprecated. EXPECT_THAT( A.Documentation->asPlainText(), AnyOf(HasSubstr("Overload with int"), HasSubstr("Overload with bool"))); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits