Author: Christian Kandeler Date: 2023-05-22T12:50:38+02:00 New Revision: 008cb29f87f3af391eb6c3747bdad16f2e386161
URL: https://github.com/llvm/llvm-project/commit/008cb29f87f3af391eb6c3747bdad16f2e386161 DIFF: https://github.com/llvm/llvm-project/commit/008cb29f87f3af391eb6c3747bdad16f2e386161.diff LOG: [clangd] Renaming: Treat member functions like other functions ... by skipping the conflict check. The same considerations apply. Reviewed By: hokein Differential Revision: https://reviews.llvm.org/D150685 Added: Modified: clang-tools-extra/clangd/refactor/Rename.cpp clang-tools-extra/clangd/unittests/RenameTests.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/refactor/Rename.cpp b/clang-tools-extra/clangd/refactor/Rename.cpp index 6362768f9b475..b3270534b13b1 100644 --- a/clang-tools-extra/clangd/refactor/Rename.cpp +++ b/clang-tools-extra/clangd/refactor/Rename.cpp @@ -515,7 +515,8 @@ std::optional<InvalidName> checkName(const NamedDecl &RenameDecl, else { // Name conflict detection. // Function conflicts are subtle (overloading), so ignore them. - if (RenameDecl.getKind() != Decl::Function) { + if (RenameDecl.getKind() != Decl::Function && + RenameDecl.getKind() != Decl::CXXMethod) { if (auto *Conflict = lookupSiblingWithName(ASTCtx, RenameDecl, NewName)) Result = InvalidName{ InvalidName::Conflict, diff --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp b/clang-tools-extra/clangd/unittests/RenameTests.cpp index 5b99f8c4fc44c..9be4a970a7cfb 100644 --- a/clang-tools-extra/clangd/unittests/RenameTests.cpp +++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp @@ -1062,6 +1062,19 @@ TEST(RenameTest, Renameable) { )cpp", "conflict", !HeaderFile, "Conflict"}, + {R"cpp( + void func(int); + void [[o^therFunc]](double); + )cpp", + nullptr, !HeaderFile, "func"}, + {R"cpp( + struct S { + void func(int); + void [[o^therFunc]](double); + }; + )cpp", + nullptr, !HeaderFile, "func"}, + {R"cpp( int V^ar; )cpp", @@ -1121,9 +1134,7 @@ TEST(RenameTest, Renameable) { } else { EXPECT_TRUE(bool(Results)) << "rename returned an error: " << llvm::toString(Results.takeError()); - ASSERT_EQ(1u, Results->GlobalChanges.size()); - EXPECT_EQ(applyEdits(std::move(Results->GlobalChanges)).front().second, - expectedResult(T, NewName)); + EXPECT_EQ(Results->LocalChanges, T.ranges()); } } } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits