Bug Summary

File:out/../test/cctest/test_base_object_ptr.cc
Warning:line 138, column 3
Method called on moved-from object 'ptr'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test_base_object_ptr.cc -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/home/maurizio/node-v18.6.0/out -resource-dir /usr/local/lib/clang/16.0.0 -D V8_DEPRECATION_WARNINGS -D V8_IMMINENT_DEPRECATION_WARNINGS -D _GLIBCXX_USE_CXX11_ABI=1 -D NODE_OPENSSL_CONF_NAME=nodejs_conf -D NODE_OPENSSL_HAS_QUIC -D __STDC_FORMAT_MACROS -D OPENSSL_NO_PINSHARED -D OPENSSL_THREADS -D NODE_ARCH="x64" -D NODE_PLATFORM="linux" -D NODE_WANT_INTERNALS=1 -D HAVE_OPENSSL=1 -D HAVE_INSPECTOR=1 -D __POSIX__ -D NODE_USE_V8_PLATFORM=1 -D NODE_HAVE_I18N_SUPPORT=1 -D OPENSSL_API_COMPAT=0x10100000L -D GTEST_HAS_POSIX_RE=0 -D GTEST_LANG_CXX11=1 -D UNIT_TEST -D UCONFIG_NO_SERVICE=1 -D U_ENABLE_DYLOAD=0 -D U_STATIC_IMPLEMENTATION=1 -D U_HAVE_STD_STRING=1 -D UCONFIG_NO_BREAK_ITERATION=0 -D _LARGEFILE_SOURCE -D _FILE_OFFSET_BITS=64 -D _POSIX_C_SOURCE=200112 -D NGHTTP2_STATICLIB -D NDEBUG -D OPENSSL_USE_NODELETE -D L_ENDIAN -D OPENSSL_BUILDING_OPENSSL -D AES_ASM -D BSAES_ASM -D CMLL_ASM -D ECP_NISTZ256_ASM -D GHASH_ASM -D KECCAK1600_ASM -D MD5_ASM -D OPENSSL_BN_ASM_GF2m -D OPENSSL_BN_ASM_MONT -D OPENSSL_BN_ASM_MONT5 -D OPENSSL_CPUID_OBJ -D OPENSSL_IA32_SSE2 -D PADLOCK_ASM -D POLY1305_ASM -D SHA1_ASM -D SHA256_ASM -D SHA512_ASM -D VPAES_ASM -D WHIRLPOOL_ASM -D X25519_ASM -D OPENSSL_PIC -D NGTCP2_STATICLIB -D NGHTTP3_STATICLIB -I ../src -I ../tools/msvs/genfiles -I ../deps/v8/include -I ../deps/cares/include -I ../deps/uv/include -I ../deps/uvwasi/include -I ../test/cctest -I ../deps/googletest/include -I ../deps/histogram/src -I ../deps/icu-small/source/i18n -I ../deps/icu-small/source/common -I ../deps/zlib -I ../deps/llhttp/include -I ../deps/nghttp2/lib/includes -I ../deps/brotli/c/include -I ../deps/openssl/openssl/include -I ../deps/openssl/openssl/crypto/include -I ../deps/openssl/config/archs/linux-x86_64/asm/include -I ../deps/openssl/config/archs/linux-x86_64/asm -I ../deps/ngtcp2 -I ../deps/ngtcp2/ngtcp2/lib/includes -I ../deps/ngtcp2/ngtcp2/crypto/includes -I ../deps/ngtcp2/nghttp3/lib/includes -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8 -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/x86_64-redhat-linux -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/backward -internal-isystem /usr/local/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-unused-parameter -Wno-unused-parameter -std=gnu++17 -fdeprecated-macro -fdebug-compilation-dir=/home/maurizio/node-v18.6.0/out -ferror-limit 19 -fno-rtti -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2022-08-22-142216-507842-1 -x c++ ../test/cctest/test_base_object_ptr.cc
1#include "gtest/gtest.h"
2#include "node.h"
3#include "base_object-inl.h"
4#include "node_test_fixture.h"
5
6using node::BaseObject;
7using node::BaseObjectPtr;
8using node::BaseObjectWeakPtr;
9using node::Environment;
10using node::MakeBaseObject;
11using node::MakeDetachedBaseObject;
12using v8::HandleScope;
13using v8::Isolate;
14using v8::Local;
15using v8::Object;
16
17class BaseObjectPtrTest : public EnvironmentTestFixture {};
18
19class DummyBaseObject : public BaseObject {
20 public:
21 DummyBaseObject(Environment* env, Local<Object> obj) : BaseObject(env, obj) {}
22
23 static Local<Object> MakeJSObject(Environment* env) {
24 return BaseObject::MakeLazilyInitializedJSTemplate(env)
25 ->GetFunction(env->context()).ToLocalChecked()
26 ->NewInstance(env->context()).ToLocalChecked();
27 }
28
29 static BaseObjectPtr<DummyBaseObject> NewDetached(Environment* env) {
30 Local<Object> obj = MakeJSObject(env);
31 return MakeDetachedBaseObject<DummyBaseObject>(env, obj);
32 }
33
34 static BaseObjectPtr<DummyBaseObject> New(Environment* env) {
35 Local<Object> obj = MakeJSObject(env);
36 return MakeBaseObject<DummyBaseObject>(env, obj);
37 }
38
39 SET_NO_MEMORY_INFO()inline void MemoryInfo(node::MemoryTracker* tracker) const override
{}
40 SET_MEMORY_INFO_NAME(DummyBaseObject)inline std::string MemoryInfoName() const override { return "DummyBaseObject"
; }
41 SET_SELF_SIZE(DummyBaseObject)inline size_t SelfSize() const override { return sizeof(DummyBaseObject
); }
42};
43
44TEST_F(BaseObjectPtrTest, ScopedDetached)static_assert(sizeof("BaseObjectPtrTest") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("ScopedDetached") > 1, "test_name must not be empty"
); class BaseObjectPtrTest_ScopedDetached_Test : public BaseObjectPtrTest
{ public: BaseObjectPtrTest_ScopedDetached_Test() = default;
~BaseObjectPtrTest_ScopedDetached_Test() override = default;
BaseObjectPtrTest_ScopedDetached_Test(BaseObjectPtrTest_ScopedDetached_Test
const&) = delete; BaseObjectPtrTest_ScopedDetached_Test&
operator=(BaseObjectPtrTest_ScopedDetached_Test const&) =
delete; BaseObjectPtrTest_ScopedDetached_Test(BaseObjectPtrTest_ScopedDetached_Test
&&) noexcept = delete; BaseObjectPtrTest_ScopedDetached_Test
& operator=(BaseObjectPtrTest_ScopedDetached_Test&&
) noexcept = delete; private: void TestBody() override; static
::testing::TestInfo* const test_info_ __attribute__ ((unused
)); }; ::testing::TestInfo* const BaseObjectPtrTest_ScopedDetached_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "BaseObjectPtrTest"
, "ScopedDetached", nullptr, nullptr, ::testing::internal::CodeLocation
("../test/cctest/test_base_object_ptr.cc", 44), (::testing::internal
::GetTypeId<BaseObjectPtrTest>()), ::testing::internal::
SuiteApiResolver< BaseObjectPtrTest>::GetSetUpCaseOrSuite
("../test/cctest/test_base_object_ptr.cc", 44), ::testing::internal
::SuiteApiResolver< BaseObjectPtrTest>::GetTearDownCaseOrSuite
("../test/cctest/test_base_object_ptr.cc", 44), new ::testing
::internal::TestFactoryImpl<BaseObjectPtrTest_ScopedDetached_Test
>); void BaseObjectPtrTest_ScopedDetached_Test::TestBody()
{
45 const HandleScope handle_scope(isolate_);
46 const Argv argv;
47 Env env_{handle_scope, argv};
48 Environment* env = *env_;
49
50 EXPECT_EQ(env->base_object_created_after_bootstrap(), 0)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "0", env->base_object_created_after_bootstrap(), 0))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 50
, gtest_ar.failure_message()) = ::testing::Message()
;
51 {
52 BaseObjectPtr<DummyBaseObject> ptr = DummyBaseObject::NewDetached(env);
53 EXPECT_EQ(env->base_object_created_after_bootstrap(), 1)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "1", env->base_object_created_after_bootstrap(), 1))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 53
, gtest_ar.failure_message()) = ::testing::Message()
;
54 }
55 EXPECT_EQ(env->base_object_created_after_bootstrap(), 0)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "0", env->base_object_created_after_bootstrap(), 0))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 55
, gtest_ar.failure_message()) = ::testing::Message()
;
56}
57
58TEST_F(BaseObjectPtrTest, ScopedDetachedWithWeak)static_assert(sizeof("BaseObjectPtrTest") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("ScopedDetachedWithWeak") > 1, "test_name must not be empty"
); class BaseObjectPtrTest_ScopedDetachedWithWeak_Test : public
BaseObjectPtrTest { public: BaseObjectPtrTest_ScopedDetachedWithWeak_Test
() = default; ~BaseObjectPtrTest_ScopedDetachedWithWeak_Test(
) override = default; BaseObjectPtrTest_ScopedDetachedWithWeak_Test
(BaseObjectPtrTest_ScopedDetachedWithWeak_Test const&) = delete
; BaseObjectPtrTest_ScopedDetachedWithWeak_Test& operator
=(BaseObjectPtrTest_ScopedDetachedWithWeak_Test const&) =
delete; BaseObjectPtrTest_ScopedDetachedWithWeak_Test(BaseObjectPtrTest_ScopedDetachedWithWeak_Test
&&) noexcept = delete; BaseObjectPtrTest_ScopedDetachedWithWeak_Test
& operator=(BaseObjectPtrTest_ScopedDetachedWithWeak_Test
&&) noexcept = delete; private: void TestBody() override
; static ::testing::TestInfo* const test_info_ __attribute__ (
(unused)); }; ::testing::TestInfo* const BaseObjectPtrTest_ScopedDetachedWithWeak_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "BaseObjectPtrTest"
, "ScopedDetachedWithWeak", nullptr, nullptr, ::testing::internal
::CodeLocation("../test/cctest/test_base_object_ptr.cc", 58),
(::testing::internal::GetTypeId<BaseObjectPtrTest>()),
::testing::internal::SuiteApiResolver< BaseObjectPtrTest>
::GetSetUpCaseOrSuite("../test/cctest/test_base_object_ptr.cc"
, 58), ::testing::internal::SuiteApiResolver< BaseObjectPtrTest
>::GetTearDownCaseOrSuite("../test/cctest/test_base_object_ptr.cc"
, 58), new ::testing::internal::TestFactoryImpl<BaseObjectPtrTest_ScopedDetachedWithWeak_Test
>); void BaseObjectPtrTest_ScopedDetachedWithWeak_Test::TestBody
()
{
59 const HandleScope handle_scope(isolate_);
60 const Argv argv;
61 Env env_{handle_scope, argv};
62 Environment* env = *env_;
63
64 BaseObjectWeakPtr<DummyBaseObject> weak_ptr;
65
66 EXPECT_EQ(env->base_object_created_after_bootstrap(), 0)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "0", env->base_object_created_after_bootstrap(), 0))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 66
, gtest_ar.failure_message()) = ::testing::Message()
;
67 {
68 BaseObjectPtr<DummyBaseObject> ptr = DummyBaseObject::NewDetached(env);
69 weak_ptr = ptr;
70 EXPECT_EQ(env->base_object_created_after_bootstrap(), 1)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "1", env->base_object_created_after_bootstrap(), 1))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 70
, gtest_ar.failure_message()) = ::testing::Message()
;
71 }
72 EXPECT_EQ(weak_ptr.get(), nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("weak_ptr.get()"
, "nullptr", weak_ptr.get(), nullptr))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc"
, 72, gtest_ar.failure_message()) = ::testing::Message()
;
73 EXPECT_EQ(env->base_object_created_after_bootstrap(), 0)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "0", env->base_object_created_after_bootstrap(), 0))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 73
, gtest_ar.failure_message()) = ::testing::Message()
;
74}
75
76TEST_F(BaseObjectPtrTest, Undetached)static_assert(sizeof("BaseObjectPtrTest") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("Undetached") > 1, "test_name must not be empty"
); class BaseObjectPtrTest_Undetached_Test : public BaseObjectPtrTest
{ public: BaseObjectPtrTest_Undetached_Test() = default; ~BaseObjectPtrTest_Undetached_Test
() override = default; BaseObjectPtrTest_Undetached_Test(BaseObjectPtrTest_Undetached_Test
const&) = delete; BaseObjectPtrTest_Undetached_Test&
operator=(BaseObjectPtrTest_Undetached_Test const&) = delete
; BaseObjectPtrTest_Undetached_Test(BaseObjectPtrTest_Undetached_Test
&&) noexcept = delete; BaseObjectPtrTest_Undetached_Test
& operator=(BaseObjectPtrTest_Undetached_Test&&) noexcept
= delete; private: void TestBody() override; static ::testing
::TestInfo* const test_info_ __attribute__ ((unused)); }; ::testing
::TestInfo* const BaseObjectPtrTest_Undetached_Test::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "BaseObjectPtrTest"
, "Undetached", nullptr, nullptr, ::testing::internal::CodeLocation
("../test/cctest/test_base_object_ptr.cc", 76), (::testing::internal
::GetTypeId<BaseObjectPtrTest>()), ::testing::internal::
SuiteApiResolver< BaseObjectPtrTest>::GetSetUpCaseOrSuite
("../test/cctest/test_base_object_ptr.cc", 76), ::testing::internal
::SuiteApiResolver< BaseObjectPtrTest>::GetTearDownCaseOrSuite
("../test/cctest/test_base_object_ptr.cc", 76), new ::testing
::internal::TestFactoryImpl<BaseObjectPtrTest_Undetached_Test
>); void BaseObjectPtrTest_Undetached_Test::TestBody()
{
77 const HandleScope handle_scope(isolate_);
78 const Argv argv;
79 Env env_{handle_scope, argv};
80 Environment* env = *env_;
81
82 node::AddEnvironmentCleanupHook(
83 isolate_,
84 [](void* arg) {
85 EXPECT_EQ(static_cast<Environment*>(arg)->base_object_count(), 0)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("static_cast<Environment*>(arg)->base_object_count()"
, "0", static_cast<Environment*>(arg)->base_object_count
(), 0))) ; else ::testing::internal::AssertHelper(::testing::
TestPartResult::kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc"
, 85, gtest_ar.failure_message()) = ::testing::Message()
;
86 },
87 env);
88
89 BaseObjectPtr<DummyBaseObject> ptr = DummyBaseObject::New(env);
90 EXPECT_EQ(env->base_object_created_after_bootstrap(), 1)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "1", env->base_object_created_after_bootstrap(), 1))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 90
, gtest_ar.failure_message()) = ::testing::Message()
;
91}
92
93TEST_F(BaseObjectPtrTest, GCWeak)static_assert(sizeof("BaseObjectPtrTest") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("GCWeak") > 1, "test_name must not be empty"
); class BaseObjectPtrTest_GCWeak_Test : public BaseObjectPtrTest
{ public: BaseObjectPtrTest_GCWeak_Test() = default; ~BaseObjectPtrTest_GCWeak_Test
() override = default; BaseObjectPtrTest_GCWeak_Test(BaseObjectPtrTest_GCWeak_Test
const&) = delete; BaseObjectPtrTest_GCWeak_Test& operator
=(BaseObjectPtrTest_GCWeak_Test const&) = delete; BaseObjectPtrTest_GCWeak_Test
(BaseObjectPtrTest_GCWeak_Test&&) noexcept = delete; BaseObjectPtrTest_GCWeak_Test
& operator=(BaseObjectPtrTest_GCWeak_Test&&) noexcept
= delete; private: void TestBody() override; static ::testing
::TestInfo* const test_info_ __attribute__ ((unused)); }; ::testing
::TestInfo* const BaseObjectPtrTest_GCWeak_Test::test_info_ =
::testing::internal::MakeAndRegisterTestInfo( "BaseObjectPtrTest"
, "GCWeak", nullptr, nullptr, ::testing::internal::CodeLocation
("../test/cctest/test_base_object_ptr.cc", 93), (::testing::internal
::GetTypeId<BaseObjectPtrTest>()), ::testing::internal::
SuiteApiResolver< BaseObjectPtrTest>::GetSetUpCaseOrSuite
("../test/cctest/test_base_object_ptr.cc", 93), ::testing::internal
::SuiteApiResolver< BaseObjectPtrTest>::GetTearDownCaseOrSuite
("../test/cctest/test_base_object_ptr.cc", 93), new ::testing
::internal::TestFactoryImpl<BaseObjectPtrTest_GCWeak_Test>
); void BaseObjectPtrTest_GCWeak_Test::TestBody()
{
94 const HandleScope handle_scope(isolate_);
95 const Argv argv;
96 Env env_{handle_scope, argv};
97 Environment* env = *env_;
98
99 BaseObjectWeakPtr<DummyBaseObject> weak_ptr;
100
101 {
102 const HandleScope handle_scope(isolate_);
103 BaseObjectPtr<DummyBaseObject> ptr = DummyBaseObject::New(env);
104 weak_ptr = ptr;
105 ptr->MakeWeak();
106
107 EXPECT_EQ(env->base_object_created_after_bootstrap(), 1)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "1", env->base_object_created_after_bootstrap(), 1))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 107
, gtest_ar.failure_message()) = ::testing::Message()
;
108 EXPECT_EQ(weak_ptr.get(), ptr.get())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("weak_ptr.get()"
, "ptr.get()", weak_ptr.get(), ptr.get()))) ; else ::testing::
internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../test/cctest/test_base_object_ptr.cc", 108, gtest_ar.failure_message
()) = ::testing::Message()
;
109 EXPECT_EQ(weak_ptr->persistent().IsWeak(), false)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("weak_ptr->persistent().IsWeak()"
, "false", weak_ptr->persistent().IsWeak(), false))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 109
, gtest_ar.failure_message()) = ::testing::Message()
;
110
111 ptr.reset();
112 }
113
114 EXPECT_EQ(env->base_object_created_after_bootstrap(), 1)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "1", env->base_object_created_after_bootstrap(), 1))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 114
, gtest_ar.failure_message()) = ::testing::Message()
;
115 EXPECT_NE(weak_ptr.get(), nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::CmpHelperNE("weak_ptr.get()"
, "nullptr", weak_ptr.get(), nullptr))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc"
, 115, gtest_ar.failure_message()) = ::testing::Message()
;
116 EXPECT_EQ(weak_ptr->persistent().IsWeak(), true)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("weak_ptr->persistent().IsWeak()"
, "true", weak_ptr->persistent().IsWeak(), true))) ; else ::
testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../test/cctest/test_base_object_ptr.cc", 116, gtest_ar.failure_message
()) = ::testing::Message()
;
117
118 v8::V8::SetFlagsFromString("--expose-gc");
119 isolate_->RequestGarbageCollectionForTesting(Isolate::kFullGarbageCollection);
120
121 EXPECT_EQ(env->base_object_created_after_bootstrap(), 0)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "0", env->base_object_created_after_bootstrap(), 0))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 121
, gtest_ar.failure_message()) = ::testing::Message()
;
122 EXPECT_EQ(weak_ptr.get(), nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("weak_ptr.get()"
, "nullptr", weak_ptr.get(), nullptr))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc"
, 122, gtest_ar.failure_message()) = ::testing::Message()
;
123}
124
125TEST_F(BaseObjectPtrTest, Moveable)static_assert(sizeof("BaseObjectPtrTest") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("Moveable") > 1, "test_name must not be empty"
); class BaseObjectPtrTest_Moveable_Test : public BaseObjectPtrTest
{ public: BaseObjectPtrTest_Moveable_Test() = default; ~BaseObjectPtrTest_Moveable_Test
() override = default; BaseObjectPtrTest_Moveable_Test(BaseObjectPtrTest_Moveable_Test
const&) = delete; BaseObjectPtrTest_Moveable_Test& operator
=(BaseObjectPtrTest_Moveable_Test const&) = delete; BaseObjectPtrTest_Moveable_Test
(BaseObjectPtrTest_Moveable_Test&&) noexcept = delete
; BaseObjectPtrTest_Moveable_Test& operator=(BaseObjectPtrTest_Moveable_Test
&&) noexcept = delete; private: void TestBody() override
; static ::testing::TestInfo* const test_info_ __attribute__ (
(unused)); }; ::testing::TestInfo* const BaseObjectPtrTest_Moveable_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "BaseObjectPtrTest"
, "Moveable", nullptr, nullptr, ::testing::internal::CodeLocation
("../test/cctest/test_base_object_ptr.cc", 125), (::testing::
internal::GetTypeId<BaseObjectPtrTest>()), ::testing::internal
::SuiteApiResolver< BaseObjectPtrTest>::GetSetUpCaseOrSuite
("../test/cctest/test_base_object_ptr.cc", 125), ::testing::internal
::SuiteApiResolver< BaseObjectPtrTest>::GetTearDownCaseOrSuite
("../test/cctest/test_base_object_ptr.cc", 125), new ::testing
::internal::TestFactoryImpl<BaseObjectPtrTest_Moveable_Test
>); void BaseObjectPtrTest_Moveable_Test::TestBody()
{
126 const HandleScope handle_scope(isolate_);
127 const Argv argv;
128 Env env_{handle_scope, argv};
129 Environment* env = *env_;
130
131 BaseObjectPtr<DummyBaseObject> ptr = DummyBaseObject::NewDetached(env);
132 EXPECT_EQ(env->base_object_created_after_bootstrap(), 1)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "1", env->base_object_created_after_bootstrap(), 1))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 132
, gtest_ar.failure_message()) = ::testing::Message()
;
1
Control jumps to 'case 0:' at line 132
2
Assuming the condition is true
3
Taking true branch
133 BaseObjectWeakPtr<DummyBaseObject> weak_ptr { ptr };
134 EXPECT_EQ(weak_ptr.get(), ptr.get())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("weak_ptr.get()"
, "ptr.get()", weak_ptr.get(), ptr.get()))) ; else ::testing::
internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../test/cctest/test_base_object_ptr.cc", 134, gtest_ar.failure_message
()) = ::testing::Message()
;
4
Control jumps to 'case 0:' at line 134
5
Assuming the condition is true
6
Taking true branch
135
136 BaseObjectPtr<DummyBaseObject> ptr2 = std::move(ptr);
7
Object 'ptr' is moved
137 EXPECT_EQ(weak_ptr.get(), ptr2.get())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("weak_ptr.get()"
, "ptr2.get()", weak_ptr.get(), ptr2.get()))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../test/cctest/test_base_object_ptr.cc", 137, gtest_ar.failure_message
()) = ::testing::Message()
;
8
Control jumps to 'case 0:' at line 137
9
Assuming the condition is true
10
Taking true branch
138 EXPECT_EQ(ptr.get(), nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("ptr.get()"
, "nullptr", ptr.get(), nullptr))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc"
, 138, gtest_ar.failure_message()) = ::testing::Message()
;
11
Control jumps to 'case 0:' at line 138
12
Method called on moved-from object 'ptr'
139
140 BaseObjectWeakPtr<DummyBaseObject> weak_ptr2 = std::move(weak_ptr);
141 EXPECT_EQ(weak_ptr2.get(), ptr2.get())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("weak_ptr2.get()"
, "ptr2.get()", weak_ptr2.get(), ptr2.get()))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../test/cctest/test_base_object_ptr.cc", 141, gtest_ar.failure_message
()) = ::testing::Message()
;
142 EXPECT_EQ(weak_ptr.get(), nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("weak_ptr.get()"
, "nullptr", weak_ptr.get(), nullptr))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc"
, 142, gtest_ar.failure_message()) = ::testing::Message()
;
143 EXPECT_EQ(env->base_object_created_after_bootstrap(), 1)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "1", env->base_object_created_after_bootstrap(), 1))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 143
, gtest_ar.failure_message()) = ::testing::Message()
;
144
145 ptr2.reset();
146
147 EXPECT_EQ(weak_ptr2.get(), nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("weak_ptr2.get()"
, "nullptr", weak_ptr2.get(), nullptr))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc"
, 147, gtest_ar.failure_message()) = ::testing::Message()
;
148 EXPECT_EQ(env->base_object_created_after_bootstrap(), 0)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "0", env->base_object_created_after_bootstrap(), 0))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 148
, gtest_ar.failure_message()) = ::testing::Message()
;
149}
150
151TEST_F(BaseObjectPtrTest, NestedClasses)static_assert(sizeof("BaseObjectPtrTest") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("NestedClasses") > 1, "test_name must not be empty"
); class BaseObjectPtrTest_NestedClasses_Test : public BaseObjectPtrTest
{ public: BaseObjectPtrTest_NestedClasses_Test() = default; ~
BaseObjectPtrTest_NestedClasses_Test() override = default; BaseObjectPtrTest_NestedClasses_Test
(BaseObjectPtrTest_NestedClasses_Test const&) = delete; BaseObjectPtrTest_NestedClasses_Test
& operator=(BaseObjectPtrTest_NestedClasses_Test const&
) = delete; BaseObjectPtrTest_NestedClasses_Test(BaseObjectPtrTest_NestedClasses_Test
&&) noexcept = delete; BaseObjectPtrTest_NestedClasses_Test
& operator=(BaseObjectPtrTest_NestedClasses_Test&&
) noexcept = delete; private: void TestBody() override; static
::testing::TestInfo* const test_info_ __attribute__ ((unused
)); }; ::testing::TestInfo* const BaseObjectPtrTest_NestedClasses_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "BaseObjectPtrTest"
, "NestedClasses", nullptr, nullptr, ::testing::internal::CodeLocation
("../test/cctest/test_base_object_ptr.cc", 151), (::testing::
internal::GetTypeId<BaseObjectPtrTest>()), ::testing::internal
::SuiteApiResolver< BaseObjectPtrTest>::GetSetUpCaseOrSuite
("../test/cctest/test_base_object_ptr.cc", 151), ::testing::internal
::SuiteApiResolver< BaseObjectPtrTest>::GetTearDownCaseOrSuite
("../test/cctest/test_base_object_ptr.cc", 151), new ::testing
::internal::TestFactoryImpl<BaseObjectPtrTest_NestedClasses_Test
>); void BaseObjectPtrTest_NestedClasses_Test::TestBody()
{
152 class ObjectWithPtr : public BaseObject {
153 public:
154 ObjectWithPtr(Environment* env, Local<Object> obj) : BaseObject(env, obj) {}
155
156 BaseObjectPtr<BaseObject> ptr1;
157 BaseObjectPtr<BaseObject> ptr2;
158
159 SET_NO_MEMORY_INFO()inline void MemoryInfo(node::MemoryTracker* tracker) const override
{}
160 SET_MEMORY_INFO_NAME(ObjectWithPtr)inline std::string MemoryInfoName() const override { return "ObjectWithPtr"
; }
161 SET_SELF_SIZE(ObjectWithPtr)inline size_t SelfSize() const override { return sizeof(ObjectWithPtr
); }
162 };
163
164 const HandleScope handle_scope(isolate_);
165 const Argv argv;
166 Env env_{handle_scope, argv};
167 Environment* env = *env_;
168
169 node::AddEnvironmentCleanupHook(
170 isolate_,
171 [](void* arg) {
172 EXPECT_EQ(static_cast<Environment*>(arg)->base_object_count(), 0)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("static_cast<Environment*>(arg)->base_object_count()"
, "0", static_cast<Environment*>(arg)->base_object_count
(), 0))) ; else ::testing::internal::AssertHelper(::testing::
TestPartResult::kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc"
, 172, gtest_ar.failure_message()) = ::testing::Message()
;
173 },
174 env);
175
176 ObjectWithPtr* obj =
177 new ObjectWithPtr(env, DummyBaseObject::MakeJSObject(env));
178 obj->ptr1 = DummyBaseObject::NewDetached(env);
179 obj->ptr2 = DummyBaseObject::New(env);
180
181 EXPECT_EQ(env->base_object_created_after_bootstrap(), 3)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("env->base_object_created_after_bootstrap()"
, "3", env->base_object_created_after_bootstrap(), 3))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../test/cctest/test_base_object_ptr.cc", 181
, gtest_ar.failure_message()) = ::testing::Message()
;
182}