Skip to content

Commit

Permalink
fake init to supress warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Yang committed Nov 3, 2023
1 parent 5880b58 commit 3fa9f52
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fml/platform/darwin/scoped_nsobject_unittests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

namespace {

// This is to suppress the bugprone-use-after-move warning.
// This strategy is recommanded here:
// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/use-after-move.html#silencing-erroneous-warnings
template <class T>
void IS_INITIALIZED(T&) {}

TEST(ScopedNSObjectTest, ScopedNSObject) {
fml::scoped_nsobject<NSObject> p1([[NSObject alloc] init]);
ASSERT_TRUE(p1.get());
Expand Down Expand Up @@ -51,10 +57,11 @@
}
ASSERT_EQ(2u, [p1 retainCount]);

fml::scoped_nsobject<NSObject> p7([NSObject new]);
fml::scoped_nsobject<NSObject> p7([[NSObject alloc] init]);
fml::scoped_nsobject<NSObject> p8(std::move(p7));
ASSERT_TRUE(p8);
ASSERT_EQ(1u, [p8 retainCount]);
IS_INITIALIZED(p7);
ASSERT_FALSE(p7.get());
}

Expand Down

0 comments on commit 3fa9f52

Please sign in to comment.