forked from OSchip/llvm-project
[clangd] Fix an assertion violation in rename.
NamedDecl::getName() asserts the name must be an identifier. Differential Revision: https://reviews.llvm.org/D92642
This commit is contained in:
parent
df1ddc4234
commit
445289aa63
|
@ -637,7 +637,10 @@ llvm::Expected<RenameResult> rename(const RenameInputs &RInputs) {
|
|||
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)
|
||||
|
|
|
@ -946,6 +946,13 @@ TEST(RenameTest, Renameable) {
|
|||
)cpp",
|
||||
"not a supported kind", !HeaderFile, Index},
|
||||
|
||||
{R"cpp(// disallow rename on non-normal identifiers.
|
||||
@interface Foo {}
|
||||
-(int) fo^o:(int)x; // Token is an identifier, but declaration name isn't a simple identifier.
|
||||
@end
|
||||
)cpp",
|
||||
"not a supported kind", HeaderFile, Index},
|
||||
|
||||
{R"cpp(
|
||||
void foo(int);
|
||||
void foo(char);
|
||||
|
|
Loading…
Reference in New Issue