Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 3fa9f52

Browse files
author
Chris Yang
committed
fake init to supress warning
1 parent 5880b58 commit 3fa9f52

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fml/platform/darwin/scoped_nsobject_unittests.mm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
namespace {
1212

13+
// This is to suppress the bugprone-use-after-move warning.
14+
// This strategy is recommanded here:
15+
// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/use-after-move.html#silencing-erroneous-warnings
16+
template <class T>
17+
void IS_INITIALIZED(T&) {}
18+
1319
TEST(ScopedNSObjectTest, ScopedNSObject) {
1420
fml::scoped_nsobject<NSObject> p1([[NSObject alloc] init]);
1521
ASSERT_TRUE(p1.get());
@@ -51,10 +57,11 @@
5157
}
5258
ASSERT_EQ(2u, [p1 retainCount]);
5359

54-
fml::scoped_nsobject<NSObject> p7([NSObject new]);
60+
fml::scoped_nsobject<NSObject> p7([[NSObject alloc] init]);
5561
fml::scoped_nsobject<NSObject> p8(std::move(p7));
5662
ASSERT_TRUE(p8);
5763
ASSERT_EQ(1u, [p8 retainCount]);
64+
IS_INITIALIZED(p7);
5865
ASSERT_FALSE(p7.get());
5966
}
6067

0 commit comments

Comments
 (0)