Bug Summary

File:root/firefox-clang/mfbt/tests/TestUniquePtr.cpp
Warning:line 433, column 3
Method called on moved-from object 'n1'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name TestUniquePtr.cpp -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 -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/mfbt/tests -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/mfbt/tests -resource-dir /usr/lib/llvm-23/lib/clang/23 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -D _GLIBCXX_ASSERTIONS=1 -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -I /root/firefox-clang/mfbt/tests -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/mfbt/tests -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/testing -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/x86_64-linux-gnu/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16/backward -internal-isystem /usr/lib/llvm-23/lib/clang/23/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-error=pessimizing-move -Wno-error=large-by-value-copy=128 -Wno-error=implicit-int-float-conversion -Wno-error=thread-safety-analysis -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -Wno-character-conversion -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -fdiagnostics-absolute-paths -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -mllvm -dwarf-linkage-names=Abstract -faddrsig -fdwarf2-cfi-asm -o /tmp/scan-build-2026-11-12-001017-1011516-1 -x c++ /root/firefox-clang/mfbt/tests/TestUniquePtr.cpp
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5#include <stddef.h>
6
7#include <memory> // For unique_ptr
8#include <type_traits>
9#include <utility>
10
11#include "mozilla/Assertions.h"
12#include "mozilla/UniquePtr.h"
13#include "mozilla/UniquePtrExtensions.h"
14#include "mozilla/Vector.h"
15
16using mozilla::UniqueFreePtr;
17using mozilla::UniquePtr;
18using mozilla::Vector;
19
20#define CHECK(c)do { bool cond = !!(c); do { static_assert( mozilla::detail::
AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"c" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp",
20); do { } while (false); do { MOZ_CrashSequence(__null, 20
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
\
21 do { \
22 bool cond = !!(c); \
23 MOZ_RELEASE_ASSERT(cond, "Test failed: " #c)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(cond)>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("cond" " (" "Test failed: " #c ")"
, "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp", 23); do
{ } while (false); do { MOZ_CrashSequence(__null, 23); __attribute__
((nomerge)) ::abort(); } while (false); } } while (false)
; \
24 } while (false)
25
26typedef UniquePtr<int> NewInt;
27static_assert(sizeof(NewInt) == sizeof(int*), "stored most efficiently");
28
29static size_t gADestructorCalls = 0;
30
31struct A {
32 public:
33 A() : mX(0) {}
34 virtual ~A() { gADestructorCalls++; }
35
36 int mX;
37};
38
39static size_t gBDestructorCalls = 0;
40
41struct B : public A {
42 public:
43 B() : mY(1) {}
44 ~B() { gBDestructorCalls++; }
45
46 int mY;
47};
48
49typedef UniquePtr<A> UniqueA;
50typedef UniquePtr<B, UniqueA::deleter_type> UniqueB; // permit interconversion
51
52static_assert(sizeof(UniqueA) == sizeof(A*), "stored most efficiently");
53static_assert(sizeof(UniqueB) == sizeof(B*), "stored most efficiently");
54
55struct DeleterSubclass : UniqueA::deleter_type {};
56
57typedef UniquePtr<B, DeleterSubclass> UniqueC;
58static_assert(sizeof(UniqueC) == sizeof(B*), "stored most efficiently");
59
60static UniqueA ReturnUniqueA() { return UniqueA(new B); }
61
62static UniqueA ReturnLocalA() {
63 UniqueA a(new A);
64 return a;
65}
66
67static void TestDeleterType() {
68 // Make sure UniquePtr will use its deleter's pointer type if it defines one.
69 typedef int* Ptr;
70 struct Deleter {
71 typedef Ptr pointer;
72 Deleter() = default;
73 void operator()(int* p) { delete p; }
74 };
75 UniquePtr<Ptr, Deleter> u(new int, Deleter());
76}
77
78static bool TestDefaultFreeGuts() {
79 static_assert(std::is_same_v<NewInt::deleter_type, std::default_delete<int> >,
80 "weird deleter?");
81
82 NewInt n1(new int);
83 CHECK(n1)do { bool cond = !!(n1); do { static_assert( mozilla::detail::
AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"n1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 83); do { } while (false); do { MOZ_CrashSequence(__null, 83
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
84 CHECK(n1.get() != nullptr)do { bool cond = !!(n1.get() != nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() != nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 84); do { } while (false); do { MOZ_CrashSequence(__null, 84
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
85
86 n1 = nullptr;
87 CHECK(!n1)do { bool cond = !!(!n1); do { static_assert( mozilla::detail
::AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"!n1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 87); do { } while (false); do { MOZ_CrashSequence(__null, 87
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
88 CHECK(n1.get() == nullptr)do { bool cond = !!(n1.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 88); do { } while (false); do { MOZ_CrashSequence(__null, 88
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
89
90 int* p1 = new int;
91 n1.reset(p1);
92 CHECK(n1)do { bool cond = !!(n1); do { static_assert( mozilla::detail::
AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"n1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 92); do { } while (false); do { MOZ_CrashSequence(__null, 92
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
93 NewInt n2(std::move(n1));
94 CHECK(!n1)do { bool cond = !!(!n1); do { static_assert( mozilla::detail
::AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"!n1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 94); do { } while (false); do { MOZ_CrashSequence(__null, 94
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
95 CHECK(n1.get() == nullptr)do { bool cond = !!(n1.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 95); do { } while (false); do { MOZ_CrashSequence(__null, 95
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
96 CHECK(n2.get() == p1)do { bool cond = !!(n2.get() == p1); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n2.get() == p1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 96); do { } while (false); do { MOZ_CrashSequence(__null, 96
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
97
98 std::swap(n1, n2);
99 CHECK(n1.get() == p1)do { bool cond = !!(n1.get() == p1); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == p1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 99); do { } while (false); do { MOZ_CrashSequence(__null, 99
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
100 CHECK(n2.get() == nullptr)do { bool cond = !!(n2.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n2.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 100); do { } while (false); do { MOZ_CrashSequence(__null, 100
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
101
102 n1.swap(n2);
103 CHECK(n1.get() == nullptr)do { bool cond = !!(n1.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 103); do { } while (false); do { MOZ_CrashSequence(__null, 103
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
104 CHECK(n2.get() == p1)do { bool cond = !!(n2.get() == p1); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n2.get() == p1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 104); do { } while (false); do { MOZ_CrashSequence(__null, 104
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
105 delete n2.release();
106
107 CHECK(n1.get() == nullptr)do { bool cond = !!(n1.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 107); do { } while (false); do { MOZ_CrashSequence(__null, 107
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
108 CHECK(n2 == nullptr)do { bool cond = !!(n2 == nullptr); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n2 == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 108); do { } while (false); do { MOZ_CrashSequence(__null, 108
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
109 CHECK(nullptr == n2)do { bool cond = !!(nullptr == n2); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "nullptr == n2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 109); do { } while (false); do { MOZ_CrashSequence(__null, 109
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
110
111 int* p2 = new int;
112 int* p3 = new int;
113 n1.reset(p2);
114 n2.reset(p3);
115 CHECK(n1.get() == p2)do { bool cond = !!(n1.get() == p2); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == p2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 115); do { } while (false); do { MOZ_CrashSequence(__null, 115
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
116 CHECK(n2.get() == p3)do { bool cond = !!(n2.get() == p3); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n2.get() == p3" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 116); do { } while (false); do { MOZ_CrashSequence(__null, 116
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
117
118 n1.swap(n2);
119 CHECK(n2 != nullptr)do { bool cond = !!(n2 != nullptr); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n2 != nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 119); do { } while (false); do { MOZ_CrashSequence(__null, 119
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
120 CHECK(nullptr != n2)do { bool cond = !!(nullptr != n2); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "nullptr != n2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 120); do { } while (false); do { MOZ_CrashSequence(__null, 120
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
121 CHECK(n2.get() == p2)do { bool cond = !!(n2.get() == p2); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n2.get() == p2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 121); do { } while (false); do { MOZ_CrashSequence(__null, 121
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
122 CHECK(n1.get() == p3)do { bool cond = !!(n1.get() == p3); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == p3" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 122); do { } while (false); do { MOZ_CrashSequence(__null, 122
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
123
124 UniqueA a1;
125 CHECK(a1 == nullptr)do { bool cond = !!(a1 == nullptr); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "a1 == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 125); do { } while (false); do { MOZ_CrashSequence(__null, 125
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
126 a1.reset(new A);
127 CHECK(gADestructorCalls == 0)do { bool cond = !!(gADestructorCalls == 0); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 0" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 127); do { } while (false); do { MOZ_CrashSequence(__null, 127
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
128 CHECK(a1->mX == 0)do { bool cond = !!(a1->mX == 0); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "a1->mX == 0" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 128); do { } while (false); do { MOZ_CrashSequence(__null, 128
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
129
130 B* bp1 = new B;
131 bp1->mX = 5;
132 CHECK(gBDestructorCalls == 0)do { bool cond = !!(gBDestructorCalls == 0); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 0" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 132); do { } while (false); do { MOZ_CrashSequence(__null, 132
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
133 a1.reset(bp1);
134 CHECK(gADestructorCalls == 1)do { bool cond = !!(gADestructorCalls == 1); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 134); do { } while (false); do { MOZ_CrashSequence(__null, 134
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
135 CHECK(a1->mX == 5)do { bool cond = !!(a1->mX == 5); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "a1->mX == 5" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 135); do { } while (false); do { MOZ_CrashSequence(__null, 135
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
136 a1.reset(nullptr);
137 CHECK(gADestructorCalls == 2)do { bool cond = !!(gADestructorCalls == 2); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 137); do { } while (false); do { MOZ_CrashSequence(__null, 137
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
138 CHECK(gBDestructorCalls == 1)do { bool cond = !!(gBDestructorCalls == 1); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 138); do { } while (false); do { MOZ_CrashSequence(__null, 138
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
139
140 B* bp2 = new B;
141 UniqueB b1(bp2);
142 UniqueA a2(nullptr);
143 a2 = std::move(b1);
144 CHECK(gADestructorCalls == 2)do { bool cond = !!(gADestructorCalls == 2); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 144); do { } while (false); do { MOZ_CrashSequence(__null, 144
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
145 CHECK(gBDestructorCalls == 1)do { bool cond = !!(gBDestructorCalls == 1); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 145); do { } while (false); do { MOZ_CrashSequence(__null, 145
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
146
147 UniqueA a3(std::move(a2));
148 a3 = nullptr;
149 CHECK(gADestructorCalls == 3)do { bool cond = !!(gADestructorCalls == 3); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 3" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 149); do { } while (false); do { MOZ_CrashSequence(__null, 149
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
150 CHECK(gBDestructorCalls == 2)do { bool cond = !!(gBDestructorCalls == 2); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 150); do { } while (false); do { MOZ_CrashSequence(__null, 150
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
151
152 B* bp3 = new B;
153 bp3->mX = 42;
154 UniqueB b2(bp3);
155 UniqueA a4(std::move(b2));
156 CHECK(b2.get() == nullptr)do { bool cond = !!(b2.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "b2.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 156); do { } while (false); do { MOZ_CrashSequence(__null, 156
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
157 CHECK((*a4).mX == 42)do { bool cond = !!((*a4).mX == 42); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "(*a4).mX == 42" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 157); do { } while (false); do { MOZ_CrashSequence(__null, 157
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
158 CHECK(gADestructorCalls == 3)do { bool cond = !!(gADestructorCalls == 3); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 3" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 158); do { } while (false); do { MOZ_CrashSequence(__null, 158
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
159 CHECK(gBDestructorCalls == 2)do { bool cond = !!(gBDestructorCalls == 2); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 159); do { } while (false); do { MOZ_CrashSequence(__null, 159
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
160
161 UniqueA a5(new A);
162 UniqueB b3(new B);
163 a5 = std::move(b3);
164 CHECK(gADestructorCalls == 4)do { bool cond = !!(gADestructorCalls == 4); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 4" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 164); do { } while (false); do { MOZ_CrashSequence(__null, 164
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
165 CHECK(gBDestructorCalls == 2)do { bool cond = !!(gBDestructorCalls == 2); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 165); do { } while (false); do { MOZ_CrashSequence(__null, 165
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
166
167 ReturnUniqueA();
168 CHECK(gADestructorCalls == 5)do { bool cond = !!(gADestructorCalls == 5); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 5" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 168); do { } while (false); do { MOZ_CrashSequence(__null, 168
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
169 CHECK(gBDestructorCalls == 3)do { bool cond = !!(gBDestructorCalls == 3); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 3" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 169); do { } while (false); do { MOZ_CrashSequence(__null, 169
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
170
171 ReturnLocalA();
172 CHECK(gADestructorCalls == 6)do { bool cond = !!(gADestructorCalls == 6); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 6" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 172); do { } while (false); do { MOZ_CrashSequence(__null, 172
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
173 CHECK(gBDestructorCalls == 3)do { bool cond = !!(gBDestructorCalls == 3); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 3" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 173); do { } while (false); do { MOZ_CrashSequence(__null, 173
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
174
175 UniqueA a6(ReturnLocalA());
176 a6 = nullptr;
177 CHECK(gADestructorCalls == 7)do { bool cond = !!(gADestructorCalls == 7); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 7" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 177); do { } while (false); do { MOZ_CrashSequence(__null, 177
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
178 CHECK(gBDestructorCalls == 3)do { bool cond = !!(gBDestructorCalls == 3); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 3" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 178); do { } while (false); do { MOZ_CrashSequence(__null, 178
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
179
180 UniqueC c1(new B);
181 UniqueA a7(new B);
182 a7 = std::move(c1);
183 CHECK(gADestructorCalls == 8)do { bool cond = !!(gADestructorCalls == 8); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 8" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 183); do { } while (false); do { MOZ_CrashSequence(__null, 183
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
184 CHECK(gBDestructorCalls == 4)do { bool cond = !!(gBDestructorCalls == 4); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 4" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 184); do { } while (false); do { MOZ_CrashSequence(__null, 184
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
185
186 c1.reset(new B);
187
188 UniqueA a8(std::move(c1));
189 CHECK(gADestructorCalls == 8)do { bool cond = !!(gADestructorCalls == 8); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 8" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 189); do { } while (false); do { MOZ_CrashSequence(__null, 189
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
190 CHECK(gBDestructorCalls == 4)do { bool cond = !!(gBDestructorCalls == 4); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 4" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 190); do { } while (false); do { MOZ_CrashSequence(__null, 190
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
191
192 // These smart pointers still own B resources.
193 CHECK(a4)do { bool cond = !!(a4); do { static_assert( mozilla::detail::
AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"a4" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 193); do { } while (false); do { MOZ_CrashSequence(__null, 193
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
194 CHECK(a5)do { bool cond = !!(a5); do { static_assert( mozilla::detail::
AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"a5" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 194); do { } while (false); do { MOZ_CrashSequence(__null, 194
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
195 CHECK(a7)do { bool cond = !!(a7); do { static_assert( mozilla::detail::
AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"a7" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 195); do { } while (false); do { MOZ_CrashSequence(__null, 195
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
196 CHECK(a8)do { bool cond = !!(a8); do { static_assert( mozilla::detail::
AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"a8" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 196); do { } while (false); do { MOZ_CrashSequence(__null, 196
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
197 return true;
198}
199
200static bool TestDefaultFree() {
201 CHECK(TestDefaultFreeGuts())do { bool cond = !!(TestDefaultFreeGuts()); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "TestDefaultFreeGuts()" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 201); do { } while (false); do { MOZ_CrashSequence(__null, 201
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
202 CHECK(gADestructorCalls == 12)do { bool cond = !!(gADestructorCalls == 12); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 12" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 202); do { } while (false); do { MOZ_CrashSequence(__null, 202
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
203 CHECK(gBDestructorCalls == 8)do { bool cond = !!(gBDestructorCalls == 8); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 8" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 203); do { } while (false); do { MOZ_CrashSequence(__null, 203
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
204 return true;
205}
206
207static size_t FreeClassCounter = 0;
208
209struct FreeClass {
210 public:
211 FreeClass() = default;
212
213 void operator()(int* aPtr) {
214 FreeClassCounter++;
215 delete aPtr;
216 }
217};
218
219typedef UniquePtr<int, FreeClass> NewIntCustom;
220static_assert(sizeof(NewIntCustom) == sizeof(int*), "stored most efficiently");
221
222static bool TestFreeClass() {
223 CHECK(FreeClassCounter == 0)do { bool cond = !!(FreeClassCounter == 0); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "FreeClassCounter == 0" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 223); do { } while (false); do { MOZ_CrashSequence(__null, 223
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
224 {
225 NewIntCustom n1(new int);
226 CHECK(FreeClassCounter == 0)do { bool cond = !!(FreeClassCounter == 0); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "FreeClassCounter == 0" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 226); do { } while (false); do { MOZ_CrashSequence(__null, 226
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
227 }
228 CHECK(FreeClassCounter == 1)do { bool cond = !!(FreeClassCounter == 1); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "FreeClassCounter == 1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 228); do { } while (false); do { MOZ_CrashSequence(__null, 228
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
229
230 NewIntCustom n2;
231 {
232 NewIntCustom n3(new int);
233 CHECK(FreeClassCounter == 1)do { bool cond = !!(FreeClassCounter == 1); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "FreeClassCounter == 1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 233); do { } while (false); do { MOZ_CrashSequence(__null, 233
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
234 n2 = std::move(n3);
235 }
236 CHECK(FreeClassCounter == 1)do { bool cond = !!(FreeClassCounter == 1); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "FreeClassCounter == 1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 236); do { } while (false); do { MOZ_CrashSequence(__null, 236
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
237 n2 = nullptr;
238 CHECK(FreeClassCounter == 2)do { bool cond = !!(FreeClassCounter == 2); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "FreeClassCounter == 2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 238); do { } while (false); do { MOZ_CrashSequence(__null, 238
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
239
240 n2.reset(nullptr);
241 CHECK(FreeClassCounter == 2)do { bool cond = !!(FreeClassCounter == 2); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "FreeClassCounter == 2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 241); do { } while (false); do { MOZ_CrashSequence(__null, 241
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
242 n2.reset(new int);
243 n2.reset();
244 CHECK(FreeClassCounter == 3)do { bool cond = !!(FreeClassCounter == 3); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "FreeClassCounter == 3" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 244); do { } while (false); do { MOZ_CrashSequence(__null, 244
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
245
246 NewIntCustom n4(new int, FreeClass());
247 CHECK(FreeClassCounter == 3)do { bool cond = !!(FreeClassCounter == 3); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "FreeClassCounter == 3" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 247); do { } while (false); do { MOZ_CrashSequence(__null, 247
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
248 n4.reset(new int);
249 CHECK(FreeClassCounter == 4)do { bool cond = !!(FreeClassCounter == 4); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "FreeClassCounter == 4" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 249); do { } while (false); do { MOZ_CrashSequence(__null, 249
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
250 n4.reset();
251 CHECK(FreeClassCounter == 5)do { bool cond = !!(FreeClassCounter == 5); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "FreeClassCounter == 5" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 251); do { } while (false); do { MOZ_CrashSequence(__null, 251
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
252
253 FreeClass f;
254 NewIntCustom n5(new int, f);
255 CHECK(FreeClassCounter == 5)do { bool cond = !!(FreeClassCounter == 5); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "FreeClassCounter == 5" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 255); do { } while (false); do { MOZ_CrashSequence(__null, 255
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
256 int* p = n5.release();
257 CHECK(FreeClassCounter == 5)do { bool cond = !!(FreeClassCounter == 5); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "FreeClassCounter == 5" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 257); do { } while (false); do { MOZ_CrashSequence(__null, 257
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
258 delete p;
259
260 return true;
261}
262
263typedef UniquePtr<int, std::default_delete<int>&> IntDeleterRef;
264typedef UniquePtr<A, std::default_delete<A>&> ADeleterRef;
265typedef UniquePtr<B, std::default_delete<A>&> BDeleterRef;
266
267static_assert(sizeof(IntDeleterRef) > sizeof(int*),
268 "has to be heavier than an int* to store the reference");
269static_assert(sizeof(ADeleterRef) > sizeof(A*),
270 "has to be heavier than an A* to store the reference");
271static_assert(sizeof(BDeleterRef) > sizeof(int*),
272 "has to be heavier than a B* to store the reference");
273
274static bool TestReferenceDeleterGuts() {
275 std::default_delete<int> delInt;
276 IntDeleterRef id1(new int, delInt);
277
278 IntDeleterRef id2(std::move(id1));
279 CHECK(id1 == nullptr)do { bool cond = !!(id1 == nullptr); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "id1 == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 279); do { } while (false); do { MOZ_CrashSequence(__null, 279
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
280 CHECK(nullptr != id2)do { bool cond = !!(nullptr != id2); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "nullptr != id2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 280); do { } while (false); do { MOZ_CrashSequence(__null, 280
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
281 CHECK(&id1.get_deleter() == &id2.get_deleter())do { bool cond = !!(&id1.get_deleter() == &id2.get_deleter
()); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"&id1.get_deleter() == &id2.get_deleter()" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 281); do { } while (false); do { MOZ_CrashSequence(__null, 281
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
282
283 IntDeleterRef id3(std::move(id2));
284
285 std::default_delete<A> delA;
286 ADeleterRef a1(new A, delA);
287 a1.reset(nullptr);
288 a1.reset(new B);
289 a1 = nullptr;
290
291 BDeleterRef b1(new B, delA);
292 a1 = std::move(b1);
293
294 BDeleterRef b2(new B, delA);
295
296 ADeleterRef a2(std::move(b2));
297
298 return true;
299}
300
301static bool TestReferenceDeleter() {
302 gADestructorCalls = 0;
303 gBDestructorCalls = 0;
304
305 CHECK(TestReferenceDeleterGuts())do { bool cond = !!(TestReferenceDeleterGuts()); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "TestReferenceDeleterGuts()" ")"
, "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp", 305); do
{ } while (false); do { MOZ_CrashSequence(__null, 305); __attribute__
((nomerge)) ::abort(); } while (false); } } while (false); } while
(false)
;
306
307 CHECK(gADestructorCalls == 4)do { bool cond = !!(gADestructorCalls == 4); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 4" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 307); do { } while (false); do { MOZ_CrashSequence(__null, 307
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
308 CHECK(gBDestructorCalls == 3)do { bool cond = !!(gBDestructorCalls == 3); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 3" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 308); do { } while (false); do { MOZ_CrashSequence(__null, 308
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
309
310 gADestructorCalls = 0;
311 gBDestructorCalls = 0;
312 return true;
313}
314
315struct Free {
316 void operator()(void* aPtr) { free(aPtr); }
317};
318
319static size_t DeleteIntFunctionCallCount = 0;
320struct DeleteIntFunction {
321 void operator()(void* aPtr) {
322 DeleteIntFunctionCallCount++;
323 delete[] static_cast<int*>(aPtr);
324 }
325};
326
327static void SetMallocedInt(UniquePtr<int, Free>& aPtr, int aI) {
328 int* newPtr = static_cast<int*>(malloc(sizeof(int)));
329 *newPtr = aI;
330 aPtr.reset(newPtr);
331}
332
333static UniquePtr<int, Free> MallocedInt(int aI) {
334 UniquePtr<int, Free> ptr(static_cast<int*>(malloc(sizeof(int))), Free{});
335 *ptr = aI;
336 return ptr;
337}
338static bool TestFunctionReferenceDeleter() {
339 // Look for allocator mismatches and leaks to verify these bits
340 UniquePtr<int, Free> i1(MallocedInt(17));
341 CHECK(*i1 == 17)do { bool cond = !!(*i1 == 17); do { static_assert( mozilla::
detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "*i1 == 17" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 341); do { } while (false); do { MOZ_CrashSequence(__null, 341
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
342
343 SetMallocedInt(i1, 42);
344 CHECK(*i1 == 42)do { bool cond = !!(*i1 == 42); do { static_assert( mozilla::
detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "*i1 == 42" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 344); do { } while (false); do { MOZ_CrashSequence(__null, 344
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
345
346 // These bits use a custom deleter so we can instrument deletion.
347 {
348 UniquePtr<int, DeleteIntFunction> i2 =
349 UniquePtr<int, DeleteIntFunction>(new int[42], DeleteIntFunction{});
350 CHECK(DeleteIntFunctionCallCount == 0)do { bool cond = !!(DeleteIntFunctionCallCount == 0); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "DeleteIntFunctionCallCount == 0"
")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp", 350
); do { } while (false); do { MOZ_CrashSequence(__null, 350);
__attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
351
352 i2.reset(new int[76]);
353 CHECK(DeleteIntFunctionCallCount == 1)do { bool cond = !!(DeleteIntFunctionCallCount == 1); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "DeleteIntFunctionCallCount == 1"
")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp", 353
); do { } while (false); do { MOZ_CrashSequence(__null, 353);
__attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
354 }
355
356 CHECK(DeleteIntFunctionCallCount == 2)do { bool cond = !!(DeleteIntFunctionCallCount == 2); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "DeleteIntFunctionCallCount == 2"
")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp", 356
); do { } while (false); do { MOZ_CrashSequence(__null, 356);
__attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
357
358 return true;
359}
360
361template <typename T>
362struct AppendNullptrTwice {
363 AppendNullptrTwice() = default;
364
365 bool operator()(Vector<T>& vec) {
366 CHECK(vec.append(nullptr))do { bool cond = !!(vec.append(nullptr)); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "vec.append(nullptr)" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 366); do { } while (false); do { MOZ_CrashSequence(__null, 366
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
367 CHECK(vec.append(nullptr))do { bool cond = !!(vec.append(nullptr)); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "vec.append(nullptr)" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 367); do { } while (false); do { MOZ_CrashSequence(__null, 367
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
368 return true;
369 }
370};
371
372static size_t AAfter;
373static size_t BAfter;
374
375static bool TestVectorGuts() {
376 Vector<UniqueA> vec;
377 CHECK(vec.append(new B))do { bool cond = !!(vec.append(new B)); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "vec.append(new B)" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 377); do { } while (false); do { MOZ_CrashSequence(__null, 377
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
378 CHECK(vec.append(new A))do { bool cond = !!(vec.append(new A)); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "vec.append(new A)" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 378); do { } while (false); do { MOZ_CrashSequence(__null, 378
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
379 CHECK(AppendNullptrTwice<UniqueA>()(vec))do { bool cond = !!(AppendNullptrTwice<UniqueA>()(vec))
; do { static_assert( mozilla::detail::AssertionConditionType
<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"AppendNullptrTwice<UniqueA>()(vec)" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 379); do { } while (false); do { MOZ_CrashSequence(__null, 379
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
380 CHECK(vec.append(new B))do { bool cond = !!(vec.append(new B)); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "vec.append(new B)" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 380); do { } while (false); do { MOZ_CrashSequence(__null, 380
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
381
382 size_t initialLength = vec.length();
383
384 UniqueA* begin = vec.begin();
385 bool appendA = true;
386 do {
387 CHECK(appendA ? vec.append(new A) : vec.append(new B))do { bool cond = !!(appendA ? vec.append(new A) : vec.append(
new B)); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"appendA ? vec.append(new A) : vec.append(new B)" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 387); do { } while (false); do { MOZ_CrashSequence(__null, 387
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
388 appendA = !appendA;
389 } while (begin == vec.begin());
390
391 size_t numAppended = vec.length() - initialLength;
392
393 BAfter = numAppended / 2;
394 AAfter = numAppended - numAppended / 2;
395
396 CHECK(gADestructorCalls == 0)do { bool cond = !!(gADestructorCalls == 0); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gADestructorCalls == 0" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 396); do { } while (false); do { MOZ_CrashSequence(__null, 396
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
397 CHECK(gBDestructorCalls == 0)do { bool cond = !!(gBDestructorCalls == 0); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 0" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 397); do { } while (false); do { MOZ_CrashSequence(__null, 397
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
398 return true;
399}
400
401static bool TestVector() {
402 gADestructorCalls = 0;
403 gBDestructorCalls = 0;
404
405 CHECK(TestVectorGuts())do { bool cond = !!(TestVectorGuts()); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "TestVectorGuts()" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 405); do { } while (false); do { MOZ_CrashSequence(__null, 405
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
406
407 CHECK(gADestructorCalls == 3 + AAfter + BAfter)do { bool cond = !!(gADestructorCalls == 3 + AAfter + BAfter)
; do { static_assert( mozilla::detail::AssertionConditionType
<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"gADestructorCalls == 3 + AAfter + BAfter" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 407); do { } while (false); do { MOZ_CrashSequence(__null, 407
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
408 CHECK(gBDestructorCalls == 2 + BAfter)do { bool cond = !!(gBDestructorCalls == 2 + BAfter); do { static_assert
( mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "gBDestructorCalls == 2 + BAfter"
")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp", 408
); do { } while (false); do { MOZ_CrashSequence(__null, 408);
__attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
409 return true;
410}
411
412typedef UniquePtr<int[]> IntArray;
413static_assert(sizeof(IntArray) == sizeof(int*), "stored most efficiently");
414
415static bool TestArray() {
416 static_assert(
417 std::is_same_v<IntArray::deleter_type, std::default_delete<int[]> >,
418 "weird deleter?");
419
420 IntArray n1(new int[5]);
421 CHECK(n1)do { bool cond = !!(n1); do { static_assert( mozilla::detail::
AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"n1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 421); do { } while (false); do { MOZ_CrashSequence(__null, 421
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
1
Taking false branch
2
Loop condition is false. Exiting loop
3
Loop condition is false. Exiting loop
422 CHECK(n1.get() != nullptr)do { bool cond = !!(n1.get() != nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() != nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 422); do { } while (false); do { MOZ_CrashSequence(__null, 422
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
4
Taking false branch
5
Loop condition is false. Exiting loop
6
Loop condition is false. Exiting loop
423
424 n1 = nullptr;
425 CHECK(!n1)do { bool cond = !!(!n1); do { static_assert( mozilla::detail
::AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"!n1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 425); do { } while (false); do { MOZ_CrashSequence(__null, 425
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
7
Taking false branch
8
Loop condition is false. Exiting loop
9
Loop condition is false. Exiting loop
426 CHECK(n1.get() == nullptr)do { bool cond = !!(n1.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 426); do { } while (false); do { MOZ_CrashSequence(__null, 426
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
10
Taking false branch
11
Loop condition is false. Exiting loop
12
Loop condition is false. Exiting loop
427
428 int* p1 = new int[42];
429 n1.reset(p1);
430 CHECK(n1)do { bool cond = !!(n1); do { static_assert( mozilla::detail::
AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"n1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 430); do { } while (false); do { MOZ_CrashSequence(__null, 430
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
13
Taking false branch
14
Loop condition is false. Exiting loop
15
Loop condition is false. Exiting loop
431 IntArray n2(std::move(n1));
16
Object 'n1' is moved
432 CHECK(!n1)do { bool cond = !!(!n1); do { static_assert( mozilla::detail
::AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"!n1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 432); do { } while (false); do { MOZ_CrashSequence(__null, 432
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
17
Taking false branch
18
Loop condition is false. Exiting loop
19
Loop condition is false. Exiting loop
433 CHECK(n1.get() == nullptr)do { bool cond = !!(n1.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 433); do { } while (false); do { MOZ_CrashSequence(__null, 433
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
20
Method called on moved-from object 'n1'
434 CHECK(n2.get() == p1)do { bool cond = !!(n2.get() == p1); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n2.get() == p1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 434); do { } while (false); do { MOZ_CrashSequence(__null, 434
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
435
436 std::swap(n1, n2);
437 CHECK(n1.get() == p1)do { bool cond = !!(n1.get() == p1); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == p1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 437); do { } while (false); do { MOZ_CrashSequence(__null, 437
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
438 CHECK(n2.get() == nullptr)do { bool cond = !!(n2.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n2.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 438); do { } while (false); do { MOZ_CrashSequence(__null, 438
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
439
440 n1.swap(n2);
441 CHECK(n1.get() == nullptr)do { bool cond = !!(n1.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 441); do { } while (false); do { MOZ_CrashSequence(__null, 441
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
442 CHECK(n2.get() == p1)do { bool cond = !!(n2.get() == p1); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n2.get() == p1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 442); do { } while (false); do { MOZ_CrashSequence(__null, 442
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
443 delete[] n2.release();
444
445 CHECK(n1.get() == nullptr)do { bool cond = !!(n1.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 445); do { } while (false); do { MOZ_CrashSequence(__null, 445
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
446 CHECK(n2.get() == nullptr)do { bool cond = !!(n2.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n2.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 446); do { } while (false); do { MOZ_CrashSequence(__null, 446
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
447
448 int* p2 = new int[7];
449 int* p3 = new int[42];
450 n1.reset(p2);
451 n2.reset(p3);
452 CHECK(n1.get() == p2)do { bool cond = !!(n1.get() == p2); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == p2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 452); do { } while (false); do { MOZ_CrashSequence(__null, 452
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
453 CHECK(n2.get() == p3)do { bool cond = !!(n2.get() == p3); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n2.get() == p3" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 453); do { } while (false); do { MOZ_CrashSequence(__null, 453
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
454
455 n1.swap(n2);
456 CHECK(n2.get() == p2)do { bool cond = !!(n2.get() == p2); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n2.get() == p2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 456); do { } while (false); do { MOZ_CrashSequence(__null, 456
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
457 CHECK(n1.get() == p3)do { bool cond = !!(n1.get() == p3); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == p3" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 457); do { } while (false); do { MOZ_CrashSequence(__null, 457
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
458
459 n1 = std::move(n2);
460 CHECK(n1.get() == p2)do { bool cond = !!(n1.get() == p2); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == p2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 460); do { } while (false); do { MOZ_CrashSequence(__null, 460
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
461 n1 = std::move(n2);
462 CHECK(n1.get() == nullptr)do { bool cond = !!(n1.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "n1.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 462); do { } while (false); do { MOZ_CrashSequence(__null, 462
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
463
464 UniquePtr<A[]> a1(new A[17]);
465 static_assert(sizeof(a1) == sizeof(A*), "stored most efficiently");
466
467 UniquePtr<A[]> a2(new A[5], std::default_delete<A[]>());
468 a2.reset(nullptr);
469 a2.reset(new A[17]);
470 a2 = nullptr;
471
472 UniquePtr<A[]> a3(nullptr);
473 a3.reset(new A[7]);
474
475 return true;
476}
477
478struct Q {
479 Q() = default;
480 Q(const Q&) = default;
481
482 Q(Q&, char) {}
483
484 template <typename T>
485 Q(Q, T&&, int) {}
486
487 Q(int, long, double, void*) {}
488};
489
490static int randomInt() { return 4; }
491
492static bool TestMakeUnique() {
493 auto a1 = std::make_unique<int>();
494 auto a2 = std::make_unique<long>(4);
495
496 // no args, easy
497 auto q0 = std::make_unique<Q>();
498
499 // temporary bound to const lval ref
500 auto q1 = std::make_unique<Q>(Q());
501
502 // passing through a non-const lval ref
503 auto q2 = std::make_unique<Q>(*q1, 'c');
504
505 // pass by copying, forward a temporary, pass by value
506 auto q3 = std::make_unique<Q>(Q(), UniquePtr<int>(), randomInt());
507
508 // various type mismatching to test "fuzzy" forwarding
509 auto q4 = std::make_unique<Q>('s', 66LL, 3.141592654, &q3);
510
511 auto c1 = std::make_unique<char[]>(5);
512
513 return true;
514}
515
516static bool TestVoid() {
517 // UniquePtr<void> supports all operations except operator*() and
518 // operator->().
519 UniqueFreePtr<void> p1(malloc(1));
520 UniqueFreePtr<void> p2;
521
522 auto x = p1.get();
523 CHECK(x != nullptr)do { bool cond = !!(x != nullptr); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "x != nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 523); do { } while (false); do { MOZ_CrashSequence(__null, 523
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
524 CHECK((std::is_same_v<decltype(x), void*>))do { bool cond = !!((std::is_same_v<decltype(x), void*>
)); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"(std::is_same_v<decltype(x), void*>)" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 524); do { } while (false); do { MOZ_CrashSequence(__null, 524
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
525
526 p2.reset(p1.release());
527 CHECK(p1.get() == nullptr)do { bool cond = !!(p1.get() == nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "p1.get() == nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 527); do { } while (false); do { MOZ_CrashSequence(__null, 527
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
528 CHECK(p2.get() != nullptr)do { bool cond = !!(p2.get() != nullptr); do { static_assert(
mozilla::detail::AssertionConditionType<decltype(cond)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "p2.get() != nullptr" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 528); do { } while (false); do { MOZ_CrashSequence(__null, 528
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
529
530 p1 = std::move(p2);
531 CHECK(p1)do { bool cond = !!(p1); do { static_assert( mozilla::detail::
AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"p1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 531); do { } while (false); do { MOZ_CrashSequence(__null, 531
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
532 CHECK(!p2)do { bool cond = !!(!p2); do { static_assert( mozilla::detail
::AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"!p2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 532); do { } while (false); do { MOZ_CrashSequence(__null, 532
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
533
534 p1.swap(p2);
535 CHECK(!p1)do { bool cond = !!(!p1); do { static_assert( mozilla::detail
::AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"!p1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 535); do { } while (false); do { MOZ_CrashSequence(__null, 535
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
536 CHECK(p2)do { bool cond = !!(p2); do { static_assert( mozilla::detail::
AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"p2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 536); do { } while (false); do { MOZ_CrashSequence(__null, 536
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
537
538 p2 = nullptr;
539 CHECK(!p2)do { bool cond = !!(!p2); do { static_assert( mozilla::detail
::AssertionConditionType<decltype(cond)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(cond))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("cond" " (" "Test failed: "
"!p2" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 539); do { } while (false); do { MOZ_CrashSequence(__null, 539
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
540
541 return true;
542}
543
544static bool TestTempPtrToSetter() {
545 static int sFooRefcount = 0;
546 struct Foo {
547 Foo() { sFooRefcount += 1; }
548
549 ~Foo() { sFooRefcount -= 1; }
550 };
551
552 const auto AllocByOutvar = [](Foo** out) -> bool {
553 *out = new Foo;
554 return true;
555 };
556
557 {
558 UniquePtr<Foo> f;
559 (void)AllocByOutvar(mozilla::TempPtrToSetter(&f));
560 CHECK(sFooRefcount == 1)do { bool cond = !!(sFooRefcount == 1); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "sFooRefcount == 1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 560); do { } while (false); do { MOZ_CrashSequence(__null, 560
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
561 }
562 CHECK(sFooRefcount == 0)do { bool cond = !!(sFooRefcount == 0); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "sFooRefcount == 0" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 562); do { } while (false); do { MOZ_CrashSequence(__null, 562
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
563
564 {
565 std::unique_ptr<Foo> f;
566 (void)AllocByOutvar(mozilla::TempPtrToSetter(&f));
567 CHECK(sFooRefcount == 1)do { bool cond = !!(sFooRefcount == 1); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "sFooRefcount == 1" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 567); do { } while (false); do { MOZ_CrashSequence(__null, 567
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
568 }
569 CHECK(sFooRefcount == 0)do { bool cond = !!(sFooRefcount == 0); do { static_assert( mozilla
::detail::AssertionConditionType<decltype(cond)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(cond))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("cond" " (" "Test failed: " "sFooRefcount == 0" ")", "/root/firefox-clang/mfbt/tests/TestUniquePtr.cpp"
, 569); do { } while (false); do { MOZ_CrashSequence(__null, 569
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); } while (false)
;
570
571 return true;
572}
573
574int main() {
575 TestDeleterType();
576
577 if (!TestDefaultFree()) {
578 return 1;
579 }
580 if (!TestFreeClass()) {
581 return 1;
582 }
583 if (!TestReferenceDeleter()) {
584 return 1;
585 }
586 if (!TestFunctionReferenceDeleter()) {
587 return 1;
588 }
589 if (!TestVector()) {
590 return 1;
591 }
592 if (!TestArray()) {
593 return 1;
594 }
595 if (!TestMakeUnique()) {
596 return 1;
597 }
598 if (!TestVoid()) {
599 return 1;
600 }
601 if (!TestTempPtrToSetter()) {
602 return 1;
603 }
604 return 0;
605}