OpenCoverage

CheckedArithmetic.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/3rdparty/masm/wtf/CheckedArithmetic.h
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright (C) 2011 Apple Inc. All rights reserved.-
3 *-
4 * Redistribution and use in source and binary forms, with or without-
5 * modification, are permitted provided that the following conditions-
6 * are met:-
7 * 1. Redistributions of source code must retain the above copyright-
8 * notice, this list of conditions and the following disclaimer.-
9 * 2. Redistributions in binary form must reproduce the above copyright-
10 * notice, this list of conditions and the following disclaimer in the-
11 * documentation and/or other materials provided with the distribution.-
12 *-
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY-
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR-
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR-
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,-
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,-
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR-
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY-
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE-
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -
24 */-
25-
26#ifndef CheckedArithmetic_h-
27#define CheckedArithmetic_h-
28-
29#include <wtf/Assertions.h>-
30#include <wtf/EnumClass.h>-
31#include <wtf/TypeTraits.h>-
32-
33#include <limits>-
34#include <stdint.h>-
35-
36/* Checked<T>-
37 *-
38 * This class provides a mechanism to perform overflow-safe integer arithmetic-
39 * without having to manually ensure that you have all the required bounds checks-
40 * directly in your code.-
41 *-
42 * There are two modes of operation:-
43 * - The default is Checked<T, CrashOnOverflow>, and crashes at the point-
44 * and overflow has occurred.-
45 * - The alternative is Checked<T, RecordOverflow>, which uses an additional-
46 * byte of storage to track whether an overflow has occurred, subsequent-
47 * unchecked operations will crash if an overflow has occured-
48 *-
49 * It is possible to provide a custom overflow handler, in which case you need-
50 * to support these functions:-
51 * - void overflowed();-
52 * This function is called when an operation has produced an overflow.-
53 * - bool hasOverflowed();-
54 * This function must return true if overflowed() has been called on an-
55 * instance and false if it has not.-
56 * - void clearOverflow();-
57 * Used to reset overflow tracking when a value is being overwritten with-
58 * a new value.-
59 *-
60 * Checked<T> works for all integer types, with the following caveats:-
61 * - Mixing signedness of operands is only supported for types narrower than-
62 * 64bits.-
63 * - It does have a performance impact, so tight loops may want to be careful-
64 * when using it.-
65 *-
66 */-
67-
68namespace WTF {-
69-
70ENUM_CLASS(CheckedState)-
71{-
72 DidOverflow,-
73 DidNotOverflow-
74} ENUM_CLASS_END(CheckedState);-
75 -
76class CrashOnOverflow {-
77public:-
78 static NO_RETURN_DUE_TO_CRASH void overflowed()-
79 {-
80 CRASH();-
81 }
never executed: end of block
0
82-
83 void clearOverflow() { }-
84-
85public:-
86 bool hasOverflowed() const { return false; }
executed 16160016 times by 153 tests: return false;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
16160016
87};-
88-
89class RecordOverflow {-
90protected:-
91 RecordOverflow()-
92 : m_overflowed(false)-
93 {-
94 }
never executed: end of block
0
95-
96 void overflowed()-
97 {-
98 m_overflowed = true;-
99 }
never executed: end of block
0
100-
101 void clearOverflow()-
102 {-
103 m_overflowed = false;-
104 }
never executed: end of block
0
105-
106public:-
107 bool hasOverflowed() const { return m_overflowed; }
never executed: return m_overflowed;
0
108-
109private:-
110 unsigned char m_overflowed;-
111};-
112-
113template <typename T, class OverflowHandler = CrashOnOverflow> class Checked;-
114template <typename T> struct RemoveChecked;-
115template <typename T> struct RemoveChecked<Checked<T> >;-
116-
117template <typename Target, typename Source, bool targetSigned = std::numeric_limits<Target>::is_signed, bool sourceSigned = std::numeric_limits<Source>::is_signed> struct BoundsChecker;-
118template <typename Target, typename Source> struct BoundsChecker<Target, Source, false, false> {-
119 static bool inBounds(Source value)-
120 {-
121 // Same signedness so implicit type conversion will always increase precision-
122 // to widest type-
123 return value <= std::numeric_limits<Target>::max();
never executed: return value <= std::numeric_limits<Target>::max();
0
124 }-
125};-
126-
127template <typename Target, typename Source> struct BoundsChecker<Target, Source, true, true> {-
128 static bool inBounds(Source value)-
129 {-
130 // Same signedness so implicit type conversion will always increase precision-
131 // to widest type-
132 return std::numeric_limits<Target>::min() <= value && value <= std::numeric_limits<Target>::max();
executed 325 times by 3 tests: return std::numeric_limits<Target>::min() <= value && value <= std::numeric_limits<Target>::max();
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
325
133 }-
134};-
135-
136template <typename Target, typename Source> struct BoundsChecker<Target, Source, false, true> {-
137 static bool inBounds(Source value)-
138 {-
139 // Target is unsigned so any value less than zero is clearly unsafe-
140 if (value < 0)
value < 0Description
TRUEnever evaluated
FALSEevaluated 2379627 times by 9 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
0-2379627
141 return false;
never executed: return false;
0
142 // If our (unsigned) Target is the same or greater width we can-
143 // convert value to type Target without losing precision-
144 if (sizeof(Target) >= sizeof(Source))
sizeof(Target)...sizeof(Source)Description
TRUEevaluated 2379720 times by 9 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
FALSEnever evaluated
0-2379720
145 return static_cast<Target>(value) <= std::numeric_limits<Target>::max();
executed 2379713 times by 9 tests: return static_cast<Target>(value) <= std::numeric_limits<Target>::max();
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
2379713
146 // The signed Source type has greater precision than the target so-
147 // max(Target) -> Source will widen.-
148 return value <= static_cast<Source>(std::numeric_limits<Target>::max());
never executed: return value <= static_cast<Source>(std::numeric_limits<Target>::max());
0
149 }-
150};-
151-
152template <typename Target, typename Source> struct BoundsChecker<Target, Source, true, false> {-
153 static bool inBounds(Source value)-
154 {-
155 // Signed target with an unsigned source-
156 if (sizeof(Target) <= sizeof(Source))
sizeof(Target)...sizeof(Source)Description
TRUEnever evaluated
FALSEnever evaluated
0
157 return value <= static_cast<Source>(std::numeric_limits<Target>::max());
never executed: return value <= static_cast<Source>(std::numeric_limits<Target>::max());
0
158 // Target is Wider than Source so we're guaranteed to fit any value in-
159 // unsigned Source-
160 return true;
never executed: return true;
0
161 }-
162};-
163-
164template <typename Target, typename Source, bool CanElide = IsSameType<Target, Source>::value || (sizeof(Target) > sizeof(Source)) > struct BoundsCheckElider;-
165template <typename Target, typename Source> struct BoundsCheckElider<Target, Source, true> {-
166 static bool inBounds(Source) { return true; }
executed 3472520 times by 153 tests: return true;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
3472520
167};-
168template <typename Target, typename Source> struct BoundsCheckElider<Target, Source, false> : public BoundsChecker<Target, Source> {-
169};-
170-
171template <typename Target, typename Source> static inline bool isInBounds(Source value)-
172{-
173 return BoundsCheckElider<Target, Source>::inBounds(value);
executed 5851156 times by 153 tests: return BoundsCheckElider<Target, Source>::inBounds(value);
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
5851156
174}-
175-
176template <typename T> struct RemoveChecked {-
177 typedef T CleanType;-
178 static const CleanType DefaultValue = 0; -
179};-
180-
181template <typename T> struct RemoveChecked<Checked<T, CrashOnOverflow> > {-
182 typedef typename RemoveChecked<T>::CleanType CleanType;-
183 static const CleanType DefaultValue = 0;-
184};-
185-
186template <typename T> struct RemoveChecked<Checked<T, RecordOverflow> > {-
187 typedef typename RemoveChecked<T>::CleanType CleanType;-
188 static const CleanType DefaultValue = 0;-
189};-
190-
191// The ResultBase and SignednessSelector are used to workaround typeof not being-
192// available in MSVC-
193template <typename U, typename V, bool uIsBigger = (sizeof(U) > sizeof(V)), bool sameSize = (sizeof(U) == sizeof(V))> struct ResultBase;-
194template <typename U, typename V> struct ResultBase<U, V, true, false> {-
195 typedef U ResultType;-
196};-
197-
198template <typename U, typename V> struct ResultBase<U, V, false, false> {-
199 typedef V ResultType;-
200};-
201-
202template <typename U> struct ResultBase<U, U, false, true> {-
203 typedef U ResultType;-
204};-
205-
206template <typename U, typename V, bool uIsSigned = std::numeric_limits<U>::is_signed, bool vIsSigned = std::numeric_limits<V>::is_signed> struct SignednessSelector;-
207template <typename U, typename V> struct SignednessSelector<U, V, true, true> {-
208 typedef U ResultType;-
209};-
210-
211template <typename U, typename V> struct SignednessSelector<U, V, false, false> {-
212 typedef U ResultType;-
213};-
214-
215template <typename U, typename V> struct SignednessSelector<U, V, true, false> {-
216 typedef V ResultType;-
217};-
218-
219template <typename U, typename V> struct SignednessSelector<U, V, false, true> {-
220 typedef U ResultType;-
221};-
222-
223template <typename U, typename V> struct ResultBase<U, V, false, true> {-
224 typedef typename SignednessSelector<U, V>::ResultType ResultType;-
225};-
226-
227template <typename U, typename V> struct Result : ResultBase<typename RemoveChecked<U>::CleanType, typename RemoveChecked<V>::CleanType> {-
228};-
229-
230template <typename LHS, typename RHS, typename ResultType = typename Result<LHS, RHS>::ResultType, -
231 bool lhsSigned = std::numeric_limits<LHS>::is_signed, bool rhsSigned = std::numeric_limits<RHS>::is_signed> struct ArithmeticOperations;-
232-
233template <typename LHS, typename RHS, typename ResultType> struct ArithmeticOperations<LHS, RHS, ResultType, true, true> {-
234 // LHS and RHS are signed types-
235-
236 // Helper function-
237 static inline bool signsMatch(LHS lhs, RHS rhs)-
238 {-
239 return (lhs ^ rhs) >= 0;
executed 647 times by 3 tests: return (lhs ^ rhs) >= 0;
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
647
240 }-
241-
242 static inline bool add(LHS lhs, RHS rhs, ResultType& result) WARN_UNUSED_RETURN-
243 {-
244 if (signsMatch(lhs, rhs)) {
signsMatch(lhs, rhs)Description
TRUEnever evaluated
FALSEevaluated 326 times by 3 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
0-326
245 if (lhs >= 0) {
lhs >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
246 if ((std::numeric_limits<ResultType>::max() - rhs) < lhs)
(std::numeric_...) - rhs) < lhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
247 return false;
never executed: return false;
0
248 } else {
never executed: end of block
0
249 ResultType temp = lhs - std::numeric_limits<ResultType>::min();-
250 if (rhs < -temp)
rhs < -tempDescription
TRUEnever evaluated
FALSEnever evaluated
0
251 return false;
never executed: return false;
0
252 }
never executed: end of block
0
253 } // if the signs do not match this operation can't overflow-
254 result = lhs + rhs;-
255 return true;
executed 323 times by 3 tests: return true;
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
323
256 }-
257-
258 static inline bool sub(LHS lhs, RHS rhs, ResultType& result) WARN_UNUSED_RETURN-
259 {-
260 if (!signsMatch(lhs, rhs)) {
!signsMatch(lhs, rhs)Description
TRUEnever evaluated
FALSEnever evaluated
0
261 if (lhs >= 0) {
lhs >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
262 if (lhs > std::numeric_limits<ResultType>::max() + rhs)
lhs > std::num...>::max() + rhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
263 return false;
never executed: return false;
0
264 } else {
never executed: end of block
0
265 if (rhs > std::numeric_limits<ResultType>::max() + lhs)
rhs > std::num...>::max() + lhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
266 return false;
never executed: return false;
0
267 }
never executed: end of block
0
268 } // if the signs match this operation can't overflow-
269 result = lhs - rhs;-
270 return true;
never executed: return true;
0
271 }-
272-
273 static inline bool multiply(LHS lhs, RHS rhs, ResultType& result) WARN_UNUSED_RETURN-
274 {-
275 if (signsMatch(lhs, rhs)) {
signsMatch(lhs, rhs)Description
TRUEevaluated 230 times by 3 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
FALSEevaluated 92 times by 1 test
Evaluated by:
  • tst_ecmascripttests
92-230
276 if (lhs >= 0) {
lhs >= 0Description
TRUEevaluated 233 times by 3 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
FALSEnever evaluated
0-233
277 if (lhs && (std::numeric_limits<ResultType>::max() / lhs) < rhs)
lhsDescription
TRUEnever evaluated
FALSEevaluated 230 times by 3 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
(std::numeric_...) / lhs) < rhsDescription
TRUEnever evaluated
FALSEnever evaluated
0-230
278 return false;
never executed: return false;
0
279 } else {
executed 230 times by 3 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
230
280 if (static_cast<ResultType>(lhs) == std::numeric_limits<ResultType>::min() || static_cast<ResultType>(rhs) == std::numeric_limits<ResultType>::min())
static_cast<Re...ltType>::min()Description
TRUEnever evaluated
FALSEnever evaluated
static_cast<Re...ltType>::min()Description
TRUEnever evaluated
FALSEnever evaluated
0
281 return false;
never executed: return false;
0
282 if ((std::numeric_limits<ResultType>::max() / -lhs) < -rhs)
(std::numeric_.../ -lhs) < -rhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
283 return false;
never executed: return false;
0
284 }
never executed: end of block
0
285 } else {-
286 if (lhs < 0) {
lhs < 0Description
TRUEevaluated 92 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-92
287 if (rhs && lhs < (std::numeric_limits<ResultType>::min() / rhs))
rhsDescription
TRUEevaluated 92 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
lhs < (std::nu...::min() / rhs)Description
TRUEnever evaluated
FALSEevaluated 92 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-92
288 return false;
never executed: return false;
0
289 } else {
executed 92 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
92
290 if (lhs && rhs < (std::numeric_limits<ResultType>::min() / lhs))
lhsDescription
TRUEnever evaluated
FALSEnever evaluated
rhs < (std::nu...::min() / lhs)Description
TRUEnever evaluated
FALSEnever evaluated
0
291 return false;
never executed: return false;
0
292 }
never executed: end of block
0
293 }-
294 result = lhs * rhs;-
295 return true;
executed 322 times by 3 tests: return true;
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
322
296 }-
297-
298 static inline bool equals(LHS lhs, RHS rhs) { return lhs == rhs; }
never executed: return lhs == rhs;
0
299-
300};-
301-
302template <typename LHS, typename RHS, typename ResultType> struct ArithmeticOperations<LHS, RHS, ResultType, false, false> {-
303 // LHS and RHS are unsigned types so bounds checks are nice and easy-
304 static inline bool add(LHS lhs, RHS rhs, ResultType& result) WARN_UNUSED_RETURN-
305 {-
306 ResultType temp = lhs + rhs;-
307 if (temp < lhs)
temp < lhsDescription
TRUEnever evaluated
FALSEevaluated 2374303 times by 9 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
0-2374303
308 return false;
never executed: return false;
0
309 result = temp;-
310 return true;
executed 2374285 times by 9 tests: return true;
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
2374285
311 }-
312-
313 static inline bool sub(LHS lhs, RHS rhs, ResultType& result) WARN_UNUSED_RETURN-
314 {-
315 ResultType temp = lhs - rhs;-
316 if (temp > lhs)
temp > lhsDescription
TRUEnever evaluated
FALSEevaluated 1154659 times by 153 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
0-1154659
317 return false;
never executed: return false;
0
318 result = temp;-
319 return true;
executed 1154827 times by 153 tests: return true;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
1154827
320 }-
321-
322 static inline bool multiply(LHS lhs, RHS rhs, ResultType& result) WARN_UNUSED_RETURN-
323 {-
324 if (!lhs || !rhs) {
!lhsDescription
TRUEnever evaluated
FALSEnever evaluated
!rhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
325 result = 0;-
326 return true;
never executed: return true;
0
327 }-
328 if (std::numeric_limits<ResultType>::max() / lhs < rhs)
std::numeric_l...() / lhs < rhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
329 return false;
never executed: return false;
0
330 result = lhs * rhs;-
331 return true;
never executed: return true;
0
332 }-
333-
334 static inline bool equals(LHS lhs, RHS rhs) { return lhs == rhs; }
executed 2199 times by 8 tests: return lhs == rhs;
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
2199
335-
336};-
337-
338template <typename ResultType> struct ArithmeticOperations<int, unsigned, ResultType, true, false> {-
339 static inline bool add(int64_t lhs, int64_t rhs, ResultType& result)-
340 {-
341 int64_t temp = lhs + rhs;-
342 if (temp < std::numeric_limits<ResultType>::min())
temp < std::nu...ltType>::min()Description
TRUEnever evaluated
FALSEnever evaluated
0
343 return false;
never executed: return false;
0
344 if (temp > std::numeric_limits<ResultType>::max())
temp > std::nu...ltType>::max()Description
TRUEnever evaluated
FALSEnever evaluated
0
345 return false;
never executed: return false;
0
346 result = static_cast<ResultType>(temp);-
347 return true;
never executed: return true;
0
348 }-
349 -
350 static inline bool sub(int64_t lhs, int64_t rhs, ResultType& result)-
351 {-
352 int64_t temp = lhs - rhs;-
353 if (temp < std::numeric_limits<ResultType>::min())
temp < std::nu...ltType>::min()Description
TRUEnever evaluated
FALSEnever evaluated
0
354 return false;
never executed: return false;
0
355 if (temp > std::numeric_limits<ResultType>::max())
temp > std::nu...ltType>::max()Description
TRUEnever evaluated
FALSEnever evaluated
0
356 return false;
never executed: return false;
0
357 result = static_cast<ResultType>(temp);-
358 return true;
never executed: return true;
0
359 }-
360-
361 static inline bool multiply(int64_t lhs, int64_t rhs, ResultType& result)-
362 {-
363 int64_t temp = lhs * rhs;-
364 if (temp < std::numeric_limits<ResultType>::min())
temp < std::nu...ltType>::min()Description
TRUEnever evaluated
FALSEnever evaluated
0
365 return false;
never executed: return false;
0
366 if (temp > std::numeric_limits<ResultType>::max())
temp > std::nu...ltType>::max()Description
TRUEnever evaluated
FALSEnever evaluated
0
367 return false;
never executed: return false;
0
368 result = static_cast<ResultType>(temp);-
369 return true;
never executed: return true;
0
370 }-
371-
372 static inline bool equals(int lhs, unsigned rhs)-
373 {-
374 return static_cast<int64_t>(lhs) == static_cast<int64_t>(rhs);
executed 5548009 times by 9 tests: return static_cast<int64_t>(lhs) == static_cast<int64_t>(rhs);
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
5548009
375 }-
376};-
377-
378template <typename ResultType> struct ArithmeticOperations<unsigned, int, ResultType, false, true> {-
379 static inline bool add(int64_t lhs, int64_t rhs, ResultType& result)-
380 {-
381 return ArithmeticOperations<int, unsigned, ResultType>::add(rhs, lhs, result);
never executed: return ArithmeticOperations<int, unsigned, ResultType>::add(rhs, lhs, result);
0
382 }-
383 -
384 static inline bool sub(int64_t lhs, int64_t rhs, ResultType& result)-
385 {-
386 return ArithmeticOperations<int, unsigned, ResultType>::sub(lhs, rhs, result);
never executed: return ArithmeticOperations<int, unsigned, ResultType>::sub(lhs, rhs, result);
0
387 }-
388-
389 static inline bool multiply(int64_t lhs, int64_t rhs, ResultType& result)-
390 {-
391 return ArithmeticOperations<int, unsigned, ResultType>::multiply(rhs, lhs, result);
never executed: return ArithmeticOperations<int, unsigned, ResultType>::multiply(rhs, lhs, result);
0
392 }-
393-
394 static inline bool equals(unsigned lhs, int rhs)-
395 {-
396 return ArithmeticOperations<int, unsigned, ResultType>::equals(rhs, lhs);
executed 5549732 times by 9 tests: return ArithmeticOperations<int, unsigned, ResultType>::equals(rhs, lhs);
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
5549732
397 }-
398};-
399-
400template <typename U, typename V, typename R> static inline bool safeAdd(U lhs, V rhs, R& result)-
401{-
402 return ArithmeticOperations<U, V, R>::add(lhs, rhs, result);
executed 2374703 times by 9 tests: return ArithmeticOperations<U, V, R>::add(lhs, rhs, result);
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
2374703
403}-
404-
405template <typename U, typename V, typename R> static inline bool safeSub(U lhs, V rhs, R& result)-
406{-
407 return ArithmeticOperations<U, V, R>::sub(lhs, rhs, result);
executed 1154956 times by 153 tests: return ArithmeticOperations<U, V, R>::sub(lhs, rhs, result);
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
1154956
408}-
409-
410template <typename U, typename V, typename R> static inline bool safeMultiply(U lhs, V rhs, R& result)-
411{-
412 return ArithmeticOperations<U, V, R>::multiply(lhs, rhs, result);
executed 324 times by 3 tests: return ArithmeticOperations<U, V, R>::multiply(lhs, rhs, result);
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
324
413}-
414-
415template <typename U, typename V> static inline bool safeEquals(U lhs, V rhs)-
416{-
417 return ArithmeticOperations<U, V>::equals(lhs, rhs);
executed 5551264 times by 9 tests: return ArithmeticOperations<U, V>::equals(lhs, rhs);
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
5551264
418}-
419-
420enum ResultOverflowedTag { ResultOverflowed };-
421 -
422// FIXME: Needed to workaround http://llvm.org/bugs/show_bug.cgi?id=10801-
423static
never executed: return true;
inline bool workAroundClangBug() { return true; }
never executed: return true;
0
424-
425template <typename T, class OverflowHandler> class Checked : public OverflowHandler {-
426public:-
427 template <typename _T, class _OverflowHandler> friend class Checked;-
428 Checked()-
429 : m_value(0)-
430 {-
431 }
executed 2379668 times by 9 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
2379668
432-
433 Checked(ResultOverflowedTag)-
434 : m_value(0)-
435 {-
436 // FIXME: Remove this when clang fixes http://llvm.org/bugs/show_bug.cgi?id=10801-
437 if (workAroundClangBug())
workAroundClangBug()Description
TRUEnever evaluated
FALSEnever evaluated
0
438 this->overflowed();
never executed: this->overflowed();
0
439 }
never executed: end of block
0
440-
441 template <typename U> Checked(U value)-
442 {-
443 if (!isInBounds<T>(value))
!isInBounds<T>(value)Description
TRUEnever evaluated
FALSEevaluated 5851402 times by 153 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
0-5851402
444 this->overflowed();
never executed: this->overflowed();
0
445 m_value = static_cast<T>(value);-
446 }
executed 5851010 times by 153 tests: end of block
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
5851010
447 -
448 template <typename V> Checked(const Checked<T, V>& rhs)-
449 : m_value(rhs.m_value)-
450 {-
451 if (rhs.hasOverflowed())
rhs.hasOverflowed()Description
TRUEnever evaluated
FALSEnever evaluated
0
452 this->overflowed();
never executed: this->overflowed();
0
453 }
never executed: end of block
0
454 -
455 template <typename U> Checked(const Checked<U, OverflowHandler>& rhs)-
456 : OverflowHandler(rhs)-
457 {-
458 if (!isInBounds<T>(rhs.m_value))
!isInBounds<T>(rhs.m_value)Description
TRUEnever evaluated
FALSEevaluated 649 times by 3 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
0-649
459 this->overflowed();
never executed: this->overflowed();
0
460 m_value = static_cast<T>(rhs.m_value);-
461 }
executed 650 times by 3 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
650
462 -
463 template <typename U, typename V> Checked(const Checked<U, V>& rhs)-
464 {-
465 if (rhs.hasOverflowed())
rhs.hasOverflowed()Description
TRUEnever evaluated
FALSEnever evaluated
0
466 this->overflowed();
never executed: this->overflowed();
0
467 if (!isInBounds<T>(rhs.m_value))
!isInBounds<T>(rhs.m_value)Description
TRUEnever evaluated
FALSEnever evaluated
0
468 this->overflowed();
never executed: this->overflowed();
0
469 m_value = static_cast<T>(rhs.m_value);-
470 }
never executed: end of block
0
471 -
472 const Checked& operator=(Checked rhs)-
473 {-
474 this->clearOverflow();-
475 if (rhs.hasOverflowed())
rhs.hasOverflowed()Description
TRUEnever evaluated
FALSEevaluated 2386172 times by 9 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
0-2386172
476 this->overflowed();
never executed: this->overflowed();
0
477 m_value = static_cast<T>(rhs.m_value);-
478 return *this;
executed 2386201 times by 9 tests: return *this;
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
2386201
479 }-
480 -
481 template <typename U> const Checked& operator=(U value)-
482 {-
483 return *this = Checked(value);
executed 2384862 times by 9 tests: return *this = Checked(value);
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
2384862
484 }-
485 -
486 template <typename U, typename V> const Checked& operator=(const Checked<U, V>& rhs)-
487 {-
488 return *this = Checked(rhs);
never executed: return *this = Checked(rhs);
0
489 }-
490 -
491 // prefix-
492 const Checked& operator++()-
493 {-
494 if (m_value == std::numeric_limits<T>::max())
m_value == std...mits<T>::max()Description
TRUEnever evaluated
FALSEnever evaluated
0
495 this->overflowed();
never executed: this->overflowed();
0
496 m_value++;-
497 return *this;
never executed: return *this;
0
498 }-
499 -
500 const Checked& operator--()-
501 {-
502 if (m_value == std::numeric_limits<T>::min())
m_value == std...mits<T>::min()Description
TRUEnever evaluated
FALSEnever evaluated
0
503 this->overflowed();
never executed: this->overflowed();
0
504 m_value--;-
505 return *this;
never executed: return *this;
0
506 }-
507 -
508 // postfix operators-
509 const Checked operator++(int)-
510 {-
511 if (m_value == std::numeric_limits<T>::max())
m_value == std...mits<T>::max()Description
TRUEnever evaluated
FALSEnever evaluated
0
512 this->overflowed();
never executed: this->overflowed();
0
513 return Checked(m_value++);
never executed: return Checked(m_value++);
0
514 }-
515 -
516 const Checked operator--(int)-
517 {-
518 if (m_value == std::numeric_limits<T>::min())
m_value == std...mits<T>::min()Description
TRUEnever evaluated
FALSEnever evaluated
0
519 this->overflowed();
never executed: this->overflowed();
0
520 return Checked(m_value--);
never executed: return Checked(m_value--);
0
521 }-
522 -
523 // Boolean operators-
524 bool operator!() const-
525 {-
526 if (this->hasOverflowed())
this->hasOverflowed()Description
TRUEnever evaluated
FALSEnever evaluated
0
527 CRASH();
never executed: (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap());
0
528 return !m_value;
never executed: return !m_value;
0
529 }-
530-
531 typedef void* (Checked::*UnspecifiedBoolType);-
532 operator UnspecifiedBoolType*() const-
533 {-
534 if (this->hasOverflowed())
this->hasOverflowed()Description
TRUEnever evaluated
FALSEnever evaluated
0
535 CRASH();
never executed: (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap());
0
536 return (m_value) ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0;
never executed: return (m_value) ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0;
0
537 }-
538-
539 // Value accessors. unsafeGet() will crash if there's been an overflow.-
540 T unsafeGet() const-
541 {-
542 if (this->hasOverflowed())
this->hasOverflowed()Description
TRUEnever evaluated
FALSEevaluated 3545872 times by 153 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
0-3545872
543 CRASH();
never executed: (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap());
0
544 return m_value;
executed 3545940 times by 153 tests: return m_value;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
3545940
545 }-
546 -
547 inline CheckedState safeGet(T& value) const WARN_UNUSED_RETURN-
548 {-
549 value = m_value;-
550 if (this->hasOverflowed())
this->hasOverflowed()Description
TRUEnever evaluated
FALSEevaluated 2310717 times by 153 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
0-2310717
551 return CheckedState::DidOverflow;
never executed: return CheckedState::DidOverflow;
0
552 return CheckedState::DidNotOverflow;
executed 2310801 times by 153 tests: return CheckedState::DidNotOverflow;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
2310801
553 }-
554-
555 // Mutating assignment-
556 template <typename U> const Checked operator+=(U rhs)-
557 {-
558 if (!safeAdd(m_value, rhs, m_value))
!safeAdd(m_val... rhs, m_value)Description
TRUEnever evaluated
FALSEevaluated 2374335 times by 9 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
0-2374335
559 this->overflowed();
never executed: this->overflowed();
0
560 return *this;
executed 2374282 times by 9 tests: return *this;
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
2374282
561 }-
562-
563 template <typename U> const Checked operator-=(U rhs)-
564 {-
565 if (!safeSub(m_value, rhs, m_value))
!safeSub(m_val... rhs, m_value)Description
TRUEnever evaluated
FALSEnever evaluated
0
566 this->overflowed();
never executed: this->overflowed();
0
567 return *this;
never executed: return *this;
0
568 }-
569-
570 template <typename U> const Checked operator*=(U rhs)-
571 {-
572 if (!safeMultiply(m_value, rhs, m_value))
!safeMultiply(... rhs, m_value)Description
TRUEnever evaluated
FALSEnever evaluated
0
573 this->overflowed();
never executed: this->overflowed();
0
574 return *this;
never executed: return *this;
0
575 }-
576-
577 const Checked operator*=(double rhs)-
578 {-
579 double result = rhs * m_value;-
580 // Handle +/- infinity and NaN-
581 if (!(std::numeric_limits<T>::min() <= result && std::numeric_limits<T>::max() >= result))
std::numeric_l...in() <= resultDescription
TRUEnever evaluated
FALSEnever evaluated
std::numeric_l...ax() >= resultDescription
TRUEnever evaluated
FALSEnever evaluated
0
582 this->overflowed();
never executed: this->overflowed();
0
583 m_value = (T)result;-
584 return *this;
never executed: return *this;
0
585 }-
586-
587 const Checked operator*=(float rhs)-
588 {-
589 return *this *= (double)rhs;
never executed: return *this *= (double)rhs;
0
590 }-
591 -
592 template <typename U, typename V> const Checked operator+=(Checked<U, V> rhs)-
593 {-
594 if (rhs.hasOverflowed())
rhs.hasOverflowed()Description
TRUEnever evaluated
FALSEevaluated 2371625 times by 9 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
0-2371625
595 this->overflowed();
never executed: this->overflowed();
0
596 return *this += rhs.m_value;
executed 2371600 times by 9 tests: return *this += rhs.m_value;
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
2371600
597 }-
598-
599 template <typename U, typename V> const Checked operator-=(Checked<U, V> rhs)-
600 {-
601 if (rhs.hasOverflowed())
rhs.hasOverflowed()Description
TRUEnever evaluated
FALSEnever evaluated
0
602 this->overflowed();
never executed: this->overflowed();
0
603 return *this -= rhs.m_value;
never executed: return *this -= rhs.m_value;
0
604 }-
605-
606 template <typename U, typename V> const Checked operator*=(Checked<U, V> rhs)-
607 {-
608 if (rhs.hasOverflowed())
rhs.hasOverflowed()Description
TRUEnever evaluated
FALSEnever evaluated
0
609 this->overflowed();
never executed: this->overflowed();
0
610 return *this *= rhs.m_value;
never executed: return *this *= rhs.m_value;
0
611 }-
612-
613 // Equality comparisons-
614 template <typename V> bool operator==(Checked<T, V> rhs)-
615 {-
616 return unsafeGet() == rhs.unsafeGet();
never executed: return unsafeGet() == rhs.unsafeGet();
0
617 }-
618-
619 template <typename U> bool operator==(U rhs)-
620 {-
621 if (this->hasOverflowed())
this->hasOverflowed()Description
TRUEnever evaluated
FALSEevaluated 5551254 times by 9 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
0-5551254
622 this->overflowed();
never executed: this->overflowed();
0
623 return safeEquals(m_value, rhs);
executed 5551322 times by 9 tests: return safeEquals(m_value, rhs);
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
5551322
624 }-
625 -
626 template <typename U, typename V> const Checked operator==(Checked<U, V> rhs)-
627 {-
628 return unsafeGet() == Checked(rhs.unsafeGet());
never executed: return unsafeGet() == Checked(rhs.unsafeGet());
0
629 }-
630-
631 template <typename U> bool operator!=(U rhs)-
632 {-
633 return !(*this == rhs);
executed 791344 times by 8 tests: return !(*this == rhs);
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquicktextinput
  • tst_qquickworkerscript
791344
634 }-
635-
636private:-
637 // Disallow implicit conversion of floating point to integer types-
638 Checked(float);-
639 Checked(double);-
640 void operator=(float);-
641 void operator=(double);-
642 void operator+=(float);-
643 void operator+=(double);-
644 void operator-=(float);-
645 void operator-=(double);-
646 T m_value;-
647};-
648-
649template <typename U, typename V, typename OverflowHandler> static inline Checked<typename Result<U, V>::ResultType, OverflowHandler> operator+(Checked<U, OverflowHandler> lhs, Checked<V, OverflowHandler> rhs)-
650{-
651 U x = 0;-
652 V y = 0;-
653 bool overflowed = lhs.safeGet(x) == CheckedState::DidOverflow || rhs.safeGet(y) == CheckedState::DidOverflow;
lhs.safeGet(x)...e::DidOverflowDescription
TRUEnever evaluated
FALSEevaluated 323 times by 3 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
rhs.safeGet(y)...e::DidOverflowDescription
TRUEnever evaluated
FALSEevaluated 325 times by 3 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
0-325
654 typename Result<U, V>::ResultType result = 0;-
655 overflowed |= !safeAdd(x, y, result);-
656 if (overflowed)
overflowedDescription
TRUEnever evaluated
FALSEevaluated 323 times by 3 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
0-323
657 return ResultOverflowed;
never executed: return ResultOverflowed;
0
658 return result;
executed 325 times by 3 tests: return result;
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
325
659}-
660-
661template <typename U, typename V, typename OverflowHandler> static inline Checked<typename Result<U, V>::ResultType, OverflowHandler> operator-(Checked<U, OverflowHandler> lhs, Checked<V, OverflowHandler> rhs)-
662{-
663 U x = 0;-
664 V y = 0;-
665 bool overflowed = lhs.safeGet(x) == CheckedState::DidOverflow || rhs.safeGet(y) == CheckedState::DidOverflow;
lhs.safeGet(x)...e::DidOverflowDescription
TRUEnever evaluated
FALSEevaluated 1154537 times by 153 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
rhs.safeGet(y)...e::DidOverflowDescription
TRUEnever evaluated
FALSEevaluated 1155001 times by 153 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
0-1155001
666 typename Result<U, V>::ResultType result = 0;-
667 overflowed |= !safeSub(x, y, result);-
668 if (overflowed)
overflowedDescription
TRUEnever evaluated
FALSEevaluated 1154104 times by 153 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
0-1154104
669 return ResultOverflowed;
never executed: return ResultOverflowed;
0
670 return result;
executed 1154018 times by 153 tests: return result;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
1154018
671}-
672-
673template <typename U, typename V, typename OverflowHandler> static inline Checked<typename Result<U, V>::ResultType, OverflowHandler> operator*(Checked<U, OverflowHandler> lhs, Checked<V, OverflowHandler> rhs)-
674{-
675 U x = 0;-
676 V y = 0;-
677 bool overflowed = lhs.safeGet(x) == CheckedState::DidOverflow || rhs.safeGet(y) == CheckedState::DidOverflow;
lhs.safeGet(x)...e::DidOverflowDescription
TRUEnever evaluated
FALSEevaluated 323 times by 3 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
rhs.safeGet(y)...e::DidOverflowDescription
TRUEnever evaluated
FALSEevaluated 322 times by 3 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
0-323
678 typename Result<U, V>::ResultType result = 0;-
679 overflowed |= !safeMultiply(x, y, result);-
680 if (overflowed)
overflowedDescription
TRUEnever evaluated
FALSEevaluated 322 times by 3 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
0-322
681 return ResultOverflowed;
never executed: return ResultOverflowed;
0
682 return result;
executed 323 times by 3 tests: return result;
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
323
683}-
684-
685template <typename U, typename V, typename OverflowHandler> static inline Checked<typename Result<U, V>::ResultType, OverflowHandler> operator+(Checked<U, OverflowHandler> lhs, V rhs)-
686{-
687 return lhs + Checked<V, OverflowHandler>(rhs);
never executed: return lhs + Checked<V, OverflowHandler>(rhs);
0
688}-
689-
690template <typename U, typename V, typename OverflowHandler> static inline Checked<typename Result<U, V>::ResultType, OverflowHandler> operator-(Checked<U, OverflowHandler> lhs, V rhs)-
691{-
692 return lhs - Checked<V, OverflowHandler>(rhs);
executed 1154917 times by 153 tests: return lhs - Checked<V, OverflowHandler>(rhs);
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
1154917
693}-
694-
695template <typename U, typename V, typename OverflowHandler> static inline Checked<typename Result<U, V>::ResultType, OverflowHandler> operator*(Checked<U, OverflowHandler> lhs, V rhs)-
696{-
697 return lhs * Checked<V, OverflowHandler>(rhs);
executed 323 times by 3 tests: return lhs * Checked<V, OverflowHandler>(rhs);
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
323
698}-
699-
700template <typename U, typename V, typename OverflowHandler> static inline Checked<typename Result<U, V>::ResultType, OverflowHandler> operator+(U lhs, Checked<V, OverflowHandler> rhs)-
701{-
702 return Checked<U, OverflowHandler>(lhs) + rhs;
executed 324 times by 3 tests: return Checked<U, OverflowHandler>(lhs) + rhs;
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qquicktextinput
324
703}-
704-
705template <typename U, typename V, typename OverflowHandler> static inline Checked<typename Result<U, V>::ResultType, OverflowHandler> operator-(U lhs, Checked<V, OverflowHandler> rhs)-
706{-
707 return Checked<U, OverflowHandler>(lhs) - rhs;
never executed: return Checked<U, OverflowHandler>(lhs) - rhs;
0
708}-
709-
710template <typename U, typename V, typename OverflowHandler> static inline Checked<typename Result<U, V>::ResultType, OverflowHandler> operator*(U lhs, Checked<V, OverflowHandler> rhs)-
711{-
712 return Checked<U, OverflowHandler>(lhs) * rhs;
never executed: return Checked<U, OverflowHandler>(lhs) * rhs;
0
713}-
714-
715}-
716-
717using WTF::Checked;-
718using WTF::CheckedState;-
719using WTF::RecordOverflow;-
720-
721#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0