[clang-tools-extra] 6761ba7 - [clangd] Avoid triggering linkage computation for decl with unstable linkage in SymbolRelevanceSignals::computeASTSignals()
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 20 18:56:51 PST 2022
Author: Nathan Ridge
Date: 2022-12-20T21:56:36-05:00
New Revision: 6761ba7639a4a1285a2e86a4beaad70569a6c222
URL: https://github.com/llvm/llvm-project/commit/6761ba7639a4a1285a2e86a4beaad70569a6c222
DIFF: https://github.com/llvm/llvm-project/commit/6761ba7639a4a1285a2e86a4beaad70569a6c222.diff
LOG: [clangd] Avoid triggering linkage computation for decl with unstable linkage in SymbolRelevanceSignals::computeASTSignals()
Fixes https://github.com/clangd/clangd/issues/1427
Differential Revision: https://reviews.llvm.org/D140379
Added:
Modified:
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/Quality.cpp b/clang-tools-extra/clangd/Quality.cpp
index 70a85d73a4823..da8e60ef8d88e 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -303,6 +303,8 @@ void SymbolRelevanceSignals::computeASTSignals(
(SemaResult.Kind != CodeCompletionResult::RK_Pattern))
return;
if (const NamedDecl *ND = SemaResult.getDeclaration()) {
+ if (hasUnstableLinkage(ND))
+ return;
auto ID = getSymbolID(ND);
if (!ID)
return;
diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 4c788ea7efbc4..a8e2916107af8 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1100,6 +1100,21 @@ TEST(CompletionTests, EmptySnippetDoesNotCrash) {
)cpp");
}
+TEST(CompletionTest, Issue1427Crash) {
+ // Need to provide main file signals to ensure that the branch in
+ // SymbolRelevanceSignals::computeASTSignals() that tries to
+ // compute a symbol ID is taken.
+ ASTSignals MainFileSignals;
+ CodeCompleteOptions Opts;
+ Opts.MainFileSignals = &MainFileSignals;
+ completions(R"cpp(
+ auto f = []() {
+ 1.0_^
+ };
+ )cpp",
+ {}, Opts);
+}
+
TEST(CompletionTest, BacktrackCrashes) {
// Sema calls code completion callbacks twice in these cases.
auto Results = completions(R"cpp(
More information about the cfe-commits
mailing list