[PATCH] D97803: [clangd] Overload bundles are only deprecated if each overloads is.

2021-08-12 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG08c04ca00542: [clangd] Overload bundles are only deprecated 
if each overloads is. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D97803?vs=327574=366116#toc

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
@@ -1657,7 +1657,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);
@@ -1695,6 +1695,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
@@ -282,6 +282,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);
@@ -310,8 +311,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;
@@ -333,7 +332,6 @@
 }
 Completion.RequiredQualifier = std::string(ShortestQualifier);
   }
-  Completion.Deprecated |= (C.IndexResult->Flags & Symbol::Deprecated);
 }
 if (C.IdentifierResult) {
   Completion.Origin |= SymbolOrigin::Identifier;
@@ -409,6 +407,14 @@
  /*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() {


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1657,7 +1657,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);
@@ -1695,6 +1695,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
@@ -282,6 +282,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);
@@ -310,8 +311,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;
@@ -333,7 +332,6 @@
 }
 Completion.RequiredQualifier = std::string(ShortestQualifier);
   }
-  

[PATCH] D97803: [clangd] Overload bundles are only deprecated if each overloads is.

2021-08-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:410
+if (Completion.Deprecated) {
+  Completion.Deprecated =
+  (C.SemaResult &&

kbobyrev wrote:
> sammccall wrote:
> > kbobyrev wrote:
> > > The comment you added says "cleared" which means this should probably be 
> > > `|=` rather than `=`, right?
> > > 
> > > Also, I this looks longer but probably more readable at least for me.
> > > 
> > > Also, the sources might be `SemaResult`, `IndexResult` or 
> > > `IdentifierResult`, right? :( Otherwise could've been 
> > > `Completion.Deprecated |= C.SemaResult ? C.SemaResult->Availability == 
> > > CXAvailability_Deprecated : C.IndexResult->Flags & Symbol::Deprecated;`
> > > The comment you added says "cleared" which means this should probably be 
> > > |= rather than =, right?
> > 
> > No, `Deprecated` *starts out true* and gets set to false (cleared) if we 
> > see any non-deprecated entry. (computes AND)
> > 
> > Your version assumes it starts out false and sets it if we see any 
> > deprecated entry. (computes OR).
> > 
> > I agree the OR version reads better - it's wrong though :-)
> Ahh, okay, makes sense, thank you!
> 
> Nit: I think the version I suggested (with fixes `|=` vs `=`) is somewhat 
> easier to read and doesn't take much more space.
Done, though with `&=` instead of `=` otherwise the logic is subtly different 
(the second clobbers the first).
And because of &= we need an explicit cast to bool.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97803/new/

https://reviews.llvm.org/D97803

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97803: [clangd] Overload bundles are only deprecated if each overloads is.

2021-08-12 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.
This revision is now accepted and ready to land.

I see, thank you very much for the explanation!




Comment at: clang-tools-extra/clangd/CodeComplete.cpp:410
+if (Completion.Deprecated) {
+  Completion.Deprecated =
+  (C.SemaResult &&

sammccall wrote:
> kbobyrev wrote:
> > The comment you added says "cleared" which means this should probably be 
> > `|=` rather than `=`, right?
> > 
> > Also, I this looks longer but probably more readable at least for me.
> > 
> > Also, the sources might be `SemaResult`, `IndexResult` or 
> > `IdentifierResult`, right? :( Otherwise could've been 
> > `Completion.Deprecated |= C.SemaResult ? C.SemaResult->Availability == 
> > CXAvailability_Deprecated : C.IndexResult->Flags & Symbol::Deprecated;`
> > The comment you added says "cleared" which means this should probably be |= 
> > rather than =, right?
> 
> No, `Deprecated` *starts out true* and gets set to false (cleared) if we see 
> any non-deprecated entry. (computes AND)
> 
> Your version assumes it starts out false and sets it if we see any deprecated 
> entry. (computes OR).
> 
> I agree the OR version reads better - it's wrong though :-)
Ahh, okay, makes sense, thank you!

Nit: I think the version I suggested (with fixes `|=` vs `=`) is somewhat 
easier to read and doesn't take much more space.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97803/new/

https://reviews.llvm.org/D97803

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97803: [clangd] Overload bundles are only deprecated if each overloads is.

2021-08-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.
Herald added a project: clang-tools-extra.

Whoops, lost this patch...

In D97803#2602787 , @kbobyrev wrote:

> So, if my understanding is correct, this will make the whole bundle 
> non-deprecated if at least one overload is not deprecated?  This is probably 
> an improvement over the existing behaviour.

Yes, exactly.

> However, do we maybe want to split the bundles into deprecated and 
> non-deprecated groups?

I don't think splitting bundles over this is worthwhile.

- it's a distraction. The point of bundling is to hide some differences within 
an overload set, to let you see all the methods more clearly.
- the "deprecated" signal means "you don't want this". This is well-defined, 
and false, for a mixed bundle.




Comment at: clang-tools-extra/clangd/CodeComplete.cpp:410
+if (Completion.Deprecated) {
+  Completion.Deprecated =
+  (C.SemaResult &&

kbobyrev wrote:
> The comment you added says "cleared" which means this should probably be `|=` 
> rather than `=`, right?
> 
> Also, I this looks longer but probably more readable at least for me.
> 
> Also, the sources might be `SemaResult`, `IndexResult` or `IdentifierResult`, 
> right? :( Otherwise could've been `Completion.Deprecated |= C.SemaResult ? 
> C.SemaResult->Availability == CXAvailability_Deprecated : 
> C.IndexResult->Flags & Symbol::Deprecated;`
> The comment you added says "cleared" which means this should probably be |= 
> rather than =, right?

No, `Deprecated` *starts out true* and gets set to false (cleared) if we see 
any non-deprecated entry. (computes AND)

Your version assumes it starts out false and sets it if we see any deprecated 
entry. (computes OR).

I agree the OR version reads better - it's wrong though :-)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97803/new/

https://reviews.llvm.org/D97803

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97803: [clangd] Overload bundles are only deprecated if each overloads is.

2021-03-04 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

So, if my understanding is correct, this will make the whole bundle 
non-deprecated if at least one overload is not deprecated? This is probably an 
improvement over the existing behaviour. However, do we maybe want to split the 
bundles into deprecated and non-deprecated groups?




Comment at: clang-tools-extra/clangd/CodeComplete.cpp:410
+if (Completion.Deprecated) {
+  Completion.Deprecated =
+  (C.SemaResult &&

The comment you added says "cleared" which means this should probably be `|=` 
rather than `=`, right?

Also, I this looks longer but probably more readable at least for me.

Also, the sources might be `SemaResult`, `IndexResult` or `IdentifierResult`, 
right? :( Otherwise could've been `Completion.Deprecated |= C.SemaResult ? 
C.SemaResult->Availability == CXAvailability_Deprecated : C.IndexResult->Flags 
& Symbol::Deprecated;`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97803/new/

https://reviews.llvm.org/D97803

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97803: [clangd] Overload bundles are only deprecated if each overloads is.

2021-03-02 Thread Sam McCall via Phabricator via cfe-commits
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() {


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) {
+  

[PATCH] D97803: [clangd] Overload bundles are only deprecated if each overloads is.

2021-03-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 327565.
sammccall edited the summary of this revision.
sammccall added a comment.

fix bug link


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
@@ -249,6 +249,12 @@
 return RankedIncludeHeaders[0];
   }
 
+  bool isDeprecated() const {
+return (SemaResult &&
+SemaResult->Availability == CXAvailability_Deprecated) ||
+   (IndexResult && IndexResult->Flags & Symbol::Deprecated);
+  }
+
   using Bundle = llvm::SmallVector;
 };
 using ScoredBundle =
@@ -309,8 +315,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,13 +336,13 @@
 }
 Completion.RequiredQualifier = std::string(ShortestQualifier);
   }
-  Completion.Deprecated |= (C.IndexResult->Flags & Symbol::Deprecated);
 }
 if (C.IdentifierResult) {
   Completion.Origin |= SymbolOrigin::Identifier;
   Completion.Kind = CompletionItemKind::Text;
   Completion.Name = std::string(C.IdentifierResult->Name);
 }
+Completion.Deprecated |= C.isDeprecated();
 
 // Turn absolute path into a literal string that can be #included.
 auto Inserted = [&](llvm::StringRef Header)
@@ -408,6 +412,7 @@
  /*CommentsFromHeader=*/false));
   }
 }
+Completion.Deprecated = Completion.Deprecated && C.isDeprecated();
   }
 
   CodeCompletion build() {


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
@@ -249,6 +249,12 @@
 return RankedIncludeHeaders[0];
   }
 
+  bool isDeprecated() const {
+return (SemaResult &&
+SemaResult->Availability == CXAvailability_Deprecated) ||
+   (IndexResult && IndexResult->Flags & Symbol::Deprecated);
+  }
+
   using Bundle = llvm::SmallVector;
 };
 using ScoredBundle =
@@ -309,8 +315,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,13 +336,13 @@
 }
 Completion.RequiredQualifier = std::string(ShortestQualifier);
   }
-  Completion.Deprecated |= (C.IndexResult->Flags & Symbol::Deprecated);
 }
 if (C.IdentifierResult) {
   Completion.Origin |= 

[PATCH] D97803: [clangd] Overload bundles are only deprecated if each overloads is.

2021-03-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kbobyrev.
Herald added subscribers: usaxena95, kadircet, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Fixes https://github.com/clangd/clangd/issues/707


Repository:
  rG LLVM Github Monorepo

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
@@ -249,6 +249,12 @@
 return RankedIncludeHeaders[0];
   }
 
+  bool isDeprecated() const {
+return (SemaResult &&
+SemaResult->Availability == CXAvailability_Deprecated) ||
+   (IndexResult && IndexResult->Flags & Symbol::Deprecated);
+  }
+
   using Bundle = llvm::SmallVector;
 };
 using ScoredBundle =
@@ -309,8 +315,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,13 +336,13 @@
 }
 Completion.RequiredQualifier = std::string(ShortestQualifier);
   }
-  Completion.Deprecated |= (C.IndexResult->Flags & Symbol::Deprecated);
 }
 if (C.IdentifierResult) {
   Completion.Origin |= SymbolOrigin::Identifier;
   Completion.Kind = CompletionItemKind::Text;
   Completion.Name = std::string(C.IdentifierResult->Name);
 }
+Completion.Deprecated |= C.isDeprecated();
 
 // Turn absolute path into a literal string that can be #included.
 auto Inserted = [&](llvm::StringRef Header)
@@ -408,6 +412,7 @@
  /*CommentsFromHeader=*/false));
   }
 }
+Completion.Deprecated = Completion.Deprecated && C.isDeprecated();
   }
 
   CodeCompletion build() {


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
@@ -249,6 +249,12 @@
 return RankedIncludeHeaders[0];
   }
 
+  bool isDeprecated() const {
+return (SemaResult &&
+SemaResult->Availability == CXAvailability_Deprecated) ||
+   (IndexResult && IndexResult->Flags & Symbol::Deprecated);
+  }
+
   using Bundle = llvm::SmallVector;
 };
 using ScoredBundle =
@@ -309,8 +315,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,13 +336,13 @@
 }
 Completion.RequiredQualifier = std::string(ShortestQualifier);
   }
-  Completion.Deprecated |=