[PATCH] D145922: [clangd] Include SpecialMembersTests.cpp to the unittest.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 13 04:05:02 PDT 2023
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
This file was missing to be included in the unittest.
And the unittest was failing, this patch fixes some broken issues.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145922
Files:
clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
clang-tools-extra/clangd/unittests/CMakeLists.txt
clang-tools-extra/clangd/unittests/tweaks/SpecialMembersTests.cpp
Index: clang-tools-extra/clangd/unittests/tweaks/SpecialMembersTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/tweaks/SpecialMembersTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/SpecialMembersTests.cpp
@@ -7,17 +7,15 @@
//===----------------------------------------------------------------------===//
#include "TweakTesting.h"
-#include "gmock/gmock-matchers.h"
-#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace clang {
namespace clangd {
namespace {
-TWEAK_TEST(SpecialMembers);
+TWEAK_TEST(DeclareCopyMove);
-TEST_F(SpecialMembersTest, Test) {
+TEST_F(DeclareCopyMoveTest, Test) {
EXPECT_AVAILABLE("struct ^S {};");
EXPECT_UNAVAILABLE("struct S { ^ };");
EXPECT_UNAVAILABLE("union ^U {};");
@@ -27,17 +25,17 @@
"S &operator=(S&&); S &operator=(const S&);"
"};");
- const char *Output = R"cpp(struct S{S(const S &) = default;
- S(S &&) = default;
- S &operator=(const S &) = default;
- S &operator=(S &&) = default;
+ const char *Output = R"cpp(struct S{S(const S&) = default;
+S(S&&) = default;
+S &operator=(const S&) = default;
+S &operator=(S&&) = default;
};)cpp";
EXPECT_EQ(apply("struct ^S{};"), Output);
- Output = R"cpp(struct S{S(const S &) = default;
-S(S &&) = default;
-S &operator=(const S &) = delete;
-S &operator=(S &&) = delete;
+ Output = R"cpp(struct S{S(const S&) = default;
+S(S&&) = default;
+S &operator=(const S&) = delete;
+S &operator=(S&&) = delete;
int& ref;};)cpp";
EXPECT_EQ(apply("struct ^S{int& ref;};"), Output);
}
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===================================================================
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -130,6 +130,7 @@
tweaks/RawStringLiteralTests.cpp
tweaks/RemoveUsingNamespaceTests.cpp
tweaks/ShowSelectionTreeTests.cpp
+ tweaks/SpecialMembersTests.cpp
tweaks/SwapIfBranchesTests.cpp
tweaks/TweakTesting.cpp
tweaks/TweakTests.cpp
Index: clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
===================================================================
--- clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
@@ -103,7 +103,8 @@
// Trigger only on class definitions.
if (auto *N = Inputs.ASTSelection.commonAncestor())
Class = const_cast<CXXRecordDecl *>(N->ASTNode.get<CXXRecordDecl>());
- if (!Class || !Class->isThisDeclarationADefinition())
+ if (!Class || !Class->isThisDeclarationADefinition() ||
+ !(Class->isClass() || Class->isStruct()))
return false;
// Tweak is only available if some members are missing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145922.504585.patch
Type: text/x-patch
Size: 2828 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230313/15c33e84/attachment-0001.bin>
More information about the cfe-commits
mailing list