This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5649b24c48ab: [clangd] Fix an assertion failure in 
NamedDecl::getName during the prepareRename (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153617

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1129,6 +1129,15 @@
         using ns::^foo;
       )cpp",
        "there are multiple symbols at the given location", !HeaderFile},
+
+      {R"cpp(
+        void test() {
+          // no crash
+          using namespace std;
+          int [[V^ar]];
+        }
+      )cpp",
+        nullptr, !HeaderFile},
   };
 
   for (const auto& Case : Cases) {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===================================================================
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -332,7 +332,8 @@
       return nullptr;
     for (const auto &Child : DS->getDeclGroup())
       if (const auto *ND = dyn_cast<NamedDecl>(Child))
-        if (ND != &RenamedDecl && ND->getName() == Name)
+        if (ND != &RenamedDecl && ND->getDeclName().isIdentifier() &&
+            ND->getName() == Name)
           return ND;
     return nullptr;
   };


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1129,6 +1129,15 @@
         using ns::^foo;
       )cpp",
        "there are multiple symbols at the given location", !HeaderFile},
+
+      {R"cpp(
+        void test() {
+          // no crash
+          using namespace std;
+          int [[V^ar]];
+        }
+      )cpp",
+        nullptr, !HeaderFile},
   };
 
   for (const auto& Case : Cases) {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===================================================================
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -332,7 +332,8 @@
       return nullptr;
     for (const auto &Child : DS->getDeclGroup())
       if (const auto *ND = dyn_cast<NamedDecl>(Child))
-        if (ND != &RenamedDecl && ND->getName() == Name)
+        if (ND != &RenamedDecl && ND->getDeclName().isIdentifier() &&
+            ND->getName() == Name)
           return ND;
     return nullptr;
   };
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to