summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/CodeComplete.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/CodeComplete.cpp')
-rw-r--r--clang-tools-extra/clangd/CodeComplete.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp
index 86268b6c25e..275b7cc832d 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -489,6 +489,9 @@ llvm::Optional<SymbolID> getSymbolID(const CodeCompletionResult &R,
switch (R.Kind) {
case CodeCompletionResult::RK_Declaration:
case CodeCompletionResult::RK_Pattern: {
+ // Computing USR caches linkage, which may change after code completion.
+ if (hasUnstableLinkage(R.Declaration))
+ return llvm::None;
return clang::clangd::getSymbolID(R.Declaration);
}
case CodeCompletionResult::RK_Macro:
@@ -1001,10 +1004,12 @@ private:
ScoredSignature Result;
Result.Signature = std::move(Signature);
Result.Quality = Signal;
- Result.IDForDoc =
- Result.Signature.documentation.empty() && Candidate.getFunction()
- ? clangd::getSymbolID(Candidate.getFunction())
- : None;
+ const FunctionDecl *Func = Candidate.getFunction();
+ if (Func && Result.Signature.documentation.empty()) {
+ // Computing USR caches linkage, which may change after code completion.
+ if (!hasUnstableLinkage(Func))
+ Result.IDForDoc = clangd::getSymbolID(Func);
+ }
return Result;
}
OpenPOWER on IntegriCloud