[PATCH] D92642: [clangd] Fix an assertion violation in rename.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 4 01:36:02 PST 2020
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang.
NamedDecl::getName() asserts the name must be an identifier.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D92642
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
@@ -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);
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===================================================================
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ 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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92642.309481.patch
Type: text/x-patch
Size: 1322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201204/e2b1317b/attachment.bin>
More information about the cfe-commits
mailing list