[PATCH] D97803: [clangd] Overload bundles are only deprecated if each overloads is.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 2 13:50:12 PST 2021
sammccall updated this revision to Diff 327574.
sammccall added a comment.
simplify
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97803/new/
https://reviews.llvm.org/D97803
Files:
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1644,7 +1644,7 @@
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);
@@ -1682,6 +1682,7 @@
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")));
Index: clang-tools-extra/clangd/CodeComplete.cpp
===================================================================
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -281,6 +281,7 @@
: 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);
@@ -309,8 +310,6 @@
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;
@@ -332,7 +331,6 @@
}
Completion.RequiredQualifier = std::string(ShortestQualifier);
}
- Completion.Deprecated |= (C.IndexResult->Flags & Symbol::Deprecated);
}
if (C.IdentifierResult) {
Completion.Origin |= SymbolOrigin::Identifier;
@@ -408,6 +406,12 @@
/*CommentsFromHeader=*/false));
}
}
+ if (Completion.Deprecated) {
+ Completion.Deprecated =
+ (C.SemaResult &&
+ C.SemaResult->Availability == CXAvailability_Deprecated) ||
+ (C.IndexResult && C.IndexResult->Flags & Symbol::Deprecated);
+ }
}
CodeCompletion build() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97803.327574.patch
Type: text/x-patch
Size: 2449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210302/36b56aa2/attachment.bin>
More information about the cfe-commits
mailing list