diff --git a/clang-tools-extra/clangd/refactor/Rename.cpp b/clang-tools-extra/clangd/refactor/Rename.cpp --- a/clang-tools-extra/clangd/refactor/Rename.cpp +++ b/clang-tools-extra/clangd/refactor/Rename.cpp @@ -637,7 +637,10 @@ if (DeclsUnderCursor.size() > 1) return makeError(ReasonToReject::AmbiguousSymbol); const auto &RenameDecl = **DeclsUnderCursor.begin(); - if (RenameDecl.getName() == RInputs.NewName) + const auto *ID = RenameDecl.getIdentifier(); + if (!ID) + return makeError(ReasonToReject::UnsupportedSymbol); + if (ID->getName() == RInputs.NewName) return makeError(ReasonToReject::SameName); auto Invalid = checkName(RenameDecl, RInputs.NewName); if (Invalid) diff --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp b/clang-tools-extra/clangd/unittests/RenameTests.cpp --- a/clang-tools-extra/clangd/unittests/RenameTests.cpp +++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp @@ -946,6 +946,13 @@ )cpp", "not a supported kind", !HeaderFile, Index}, + {R"cpp(// disallow rename on non-normal identifiers. + @interface Foo {} + -(int) f^oo; // special name. + @end + )cpp", + "not a supported kind", HeaderFile, Index}, + {R"cpp( void foo(int); void foo(char);