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

Commit cfccb75

Browse files
author
Chris Yang
committed
include utility
fake init to supress warning
1 parent 68da898 commit cfccb75

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

fml/platform/darwin/scoped_nsobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define FLUTTER_FML_PLATFORM_DARWIN_SCOPED_NSOBJECT_H_
77

88
#include <type_traits>
9+
#include <utility>
910

1011
// Include NSObject.h directly because Foundation.h pulls in many dependencies.
1112
// (Approx 100k lines of code versus 1.5k for NSObject.h). scoped_nsobject gets

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)