This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6761ba7639a4: [clangd] Avoid triggering linkage computation 
for decl with unstable linkage in… (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140379

Files:
  clang-tools-extra/clangd/Quality.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
@@ -1100,6 +1100,21 @@
     )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(
Index: clang-tools-extra/clangd/Quality.cpp
===================================================================
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -303,6 +303,8 @@
       (SemaResult.Kind != CodeCompletionResult::RK_Pattern))
     return;
   if (const NamedDecl *ND = SemaResult.getDeclaration()) {
+    if (hasUnstableLinkage(ND))
+      return;
     auto ID = getSymbolID(ND);
     if (!ID)
       return;


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1100,6 +1100,21 @@
     )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(
Index: clang-tools-extra/clangd/Quality.cpp
===================================================================
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -303,6 +303,8 @@
       (SemaResult.Kind != CodeCompletionResult::RK_Pattern))
     return;
   if (const NamedDecl *ND = SemaResult.getDeclaration()) {
+    if (hasUnstableLinkage(ND))
+      return;
     auto ID = getSymbolID(ND);
     if (!ID)
       return;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to