Add .clang-format and run clang-format on runtime/platform.
R=johnmccutchan@google.com Review URL: https://codereview.chromium.org/2470663006 .
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
# Defines the Chromium style for automatic reformatting.
|
||||
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||
BasedOnStyle: Chromium
|
||||
|
||||
# Keep up to 2 blank lines. More blank lines are removed.
|
||||
MaxEmptyLinesToKeep: 2
|
||||
|
||||
# clang-format doesn't seem to do a good job of this for longer comments.
|
||||
ReflowComments: 'false'
|
||||
|
||||
# We have lots of these. Though we need to put them all in curly braces,
|
||||
# clang-format can't do that.
|
||||
AllowShortIfStatementsOnASingleLine: 'true'
|
||||
|
||||
# Put escaped newlines into the rightmost column.
|
||||
AlignEscapedNewlinesLeft: false
|
||||
@@ -14,10 +14,14 @@
|
||||
extern "C" void __asan_unpoison_memory_region(void*, size_t);
|
||||
#define ASAN_UNPOISON(ptr, len) __asan_unpoison_memory_region(ptr, len)
|
||||
#else // __has_feature(address_sanitizer)
|
||||
#define ASAN_UNPOISON(ptr, len) do {} while (false && (ptr) == 0 && (len) == 0)
|
||||
#define ASAN_UNPOISON(ptr, len) \
|
||||
do { \
|
||||
} while (false && (ptr) == 0 && (len) == 0)
|
||||
#endif // __has_feature(address_sanitizer)
|
||||
#else // defined(__has_feature)
|
||||
#define ASAN_UNPOISON(ptr, len) do {} while (false && (ptr) == 0 && (len) == 0)
|
||||
#define ASAN_UNPOISON(ptr, len) \
|
||||
do { \
|
||||
} while (false && (ptr) == 0 && (len) == 0)
|
||||
#endif // defined(__has_feature)
|
||||
|
||||
#endif // RUNTIME_PLATFORM_ADDRESS_SANITIZER_H_
|
||||
|
||||
@@ -28,9 +28,7 @@ void DynamicAssertionHelper::Fail(const char* format, ...) {
|
||||
va_list arguments;
|
||||
va_start(arguments, format);
|
||||
vsnprintf(buffer + file_and_line_length,
|
||||
sizeof(buffer) - file_and_line_length,
|
||||
format,
|
||||
arguments);
|
||||
sizeof(buffer) - file_and_line_length, format, arguments);
|
||||
va_end(arguments);
|
||||
|
||||
// Print the buffer on stderr and/or syslog.
|
||||
|
||||
+28
-42
@@ -26,10 +26,7 @@ namespace dart {
|
||||
|
||||
class DynamicAssertionHelper {
|
||||
public:
|
||||
enum Kind {
|
||||
ASSERT,
|
||||
EXPECT
|
||||
};
|
||||
enum Kind { ASSERT, EXPECT };
|
||||
|
||||
DynamicAssertionHelper(const char* file, int line, Kind kind)
|
||||
: file_(file), line_(line), kind_(kind) {}
|
||||
@@ -113,8 +110,7 @@ void DynamicAssertionHelper::Equals(const E& expected, const A& actual) {
|
||||
|
||||
|
||||
template <typename E, typename A>
|
||||
void DynamicAssertionHelper::NotEquals(const E& not_expected,
|
||||
const A& actual) {
|
||||
void DynamicAssertionHelper::NotEquals(const E& not_expected, const A& actual) {
|
||||
if (actual != not_expected) return;
|
||||
std::ostringstream ness;
|
||||
ness << not_expected;
|
||||
@@ -135,16 +131,14 @@ void DynamicAssertionHelper::FloatEquals(const E& expected,
|
||||
ass << actual;
|
||||
tolss << tol;
|
||||
std::string es = ess.str(), as = ass.str(), tols = tolss.str();
|
||||
Fail("expected: <%s> but was: <%s> (tolerance: <%s>)",
|
||||
es.c_str(),
|
||||
as.c_str(),
|
||||
Fail("expected: <%s> but was: <%s> (tolerance: <%s>)", es.c_str(), as.c_str(),
|
||||
tols.c_str());
|
||||
}
|
||||
|
||||
|
||||
template <typename E, typename A>
|
||||
NO_SANITIZE_MEMORY
|
||||
void DynamicAssertionHelper::StringEquals(const E& expected, const A& actual) {
|
||||
NO_SANITIZE_MEMORY void DynamicAssertionHelper::StringEquals(const E& expected,
|
||||
const A& actual) {
|
||||
std::ostringstream ess, ass;
|
||||
ess << expected;
|
||||
ass << actual;
|
||||
@@ -155,29 +149,29 @@ void DynamicAssertionHelper::StringEquals(const E& expected, const A& actual) {
|
||||
|
||||
|
||||
template <typename E, typename A>
|
||||
NO_SANITIZE_MEMORY
|
||||
void DynamicAssertionHelper::IsSubstring(const E& needle, const A& haystack) {
|
||||
NO_SANITIZE_MEMORY void DynamicAssertionHelper::IsSubstring(const E& needle,
|
||||
const A& haystack) {
|
||||
std::ostringstream ess, ass;
|
||||
ess << needle;
|
||||
ass << haystack;
|
||||
std::string es = ess.str(), as = ass.str();
|
||||
if (as.find(es) != std::string::npos) return;
|
||||
Fail("expected <\"%s\"> to be a substring of <\"%s\">",
|
||||
es.c_str(), as.c_str());
|
||||
Fail("expected <\"%s\"> to be a substring of <\"%s\">", es.c_str(),
|
||||
as.c_str());
|
||||
}
|
||||
|
||||
|
||||
template <typename E, typename A>
|
||||
NO_SANITIZE_MEMORY
|
||||
void DynamicAssertionHelper::IsNotSubstring(const E& needle,
|
||||
NO_SANITIZE_MEMORY void DynamicAssertionHelper::IsNotSubstring(
|
||||
const E& needle,
|
||||
const A& haystack) {
|
||||
std::ostringstream ess, ass;
|
||||
ess << needle;
|
||||
ass << haystack;
|
||||
std::string es = ess.str(), as = ass.str();
|
||||
if (as.find(es) == std::string::npos) return;
|
||||
Fail("expected <\"%s\"> to not be a substring of <\"%s\">",
|
||||
es.c_str(), as.c_str());
|
||||
Fail("expected <\"%s\"> to not be a substring of <\"%s\">", es.c_str(),
|
||||
as.c_str());
|
||||
}
|
||||
|
||||
|
||||
@@ -236,11 +230,9 @@ T DynamicAssertionHelper::NotNull(const T p) {
|
||||
} // namespace dart
|
||||
|
||||
|
||||
#define FATAL(error) \
|
||||
dart::Assert(__FILE__, __LINE__).Fail("%s", error)
|
||||
#define FATAL(error) dart::Assert(__FILE__, __LINE__).Fail("%s", error)
|
||||
|
||||
#define FATAL1(format, p1) \
|
||||
dart::Assert(__FILE__, __LINE__).Fail(format, (p1))
|
||||
#define FATAL1(format, p1) dart::Assert(__FILE__, __LINE__).Fail(format, (p1))
|
||||
|
||||
#define FATAL2(format, p1, p2) \
|
||||
dart::Assert(__FILE__, __LINE__).Fail(format, (p1), (p2))
|
||||
@@ -248,14 +240,11 @@ T DynamicAssertionHelper::NotNull(const T p) {
|
||||
#define FATAL3(format, p1, p2, p3) \
|
||||
dart::Assert(__FILE__, __LINE__).Fail(format, (p1), (p2), (p3))
|
||||
|
||||
#define UNIMPLEMENTED() \
|
||||
FATAL("unimplemented code")
|
||||
#define UNIMPLEMENTED() FATAL("unimplemented code")
|
||||
|
||||
#define UNREACHABLE() \
|
||||
FATAL("unreachable code")
|
||||
#define UNREACHABLE() FATAL("unreachable code")
|
||||
|
||||
#define OUT_OF_MEMORY() \
|
||||
FATAL("Out of memory.")
|
||||
#define OUT_OF_MEMORY() FATAL("Out of memory.")
|
||||
|
||||
|
||||
#if defined(DEBUG)
|
||||
@@ -275,15 +264,16 @@ T DynamicAssertionHelper::NotNull(const T p) {
|
||||
|
||||
// Returns 'ptr'; useful for initializer lists:
|
||||
// class Foo { Foo(int* ptr) : ptr_(ASSERT_NOTNULL(ptr)) ...
|
||||
#define ASSERT_NOTNULL(ptr) \
|
||||
dart::Assert(__FILE__, __LINE__).NotNull((ptr))
|
||||
#define ASSERT_NOTNULL(ptr) dart::Assert(__FILE__, __LINE__).NotNull((ptr))
|
||||
|
||||
#else // if defined(DEBUG)
|
||||
|
||||
// In order to avoid variable unused warnings for code that only uses
|
||||
// a variable in an ASSERT or EXPECT, we make sure to use the macro
|
||||
// argument.
|
||||
#define ASSERT(condition) do {} while (false && (condition))
|
||||
#define ASSERT(condition) \
|
||||
do { \
|
||||
} while (false && (condition))
|
||||
|
||||
#define DEBUG_ASSERT(cond)
|
||||
|
||||
@@ -310,8 +300,7 @@ T DynamicAssertionHelper::NotNull(const T p) {
|
||||
//
|
||||
|
||||
template <bool>
|
||||
struct CompileAssert {
|
||||
};
|
||||
struct CompileAssert {};
|
||||
// Macro to concatenate two tokens. The helper is need to proper expansion
|
||||
// in case an argument is a macro itself.
|
||||
#if !defined(COMPILE_ASSERT)
|
||||
@@ -319,8 +308,8 @@ struct CompileAssert {
|
||||
#define COMPILE_ASSERT_JOIN_HELPER(a, b) a##b
|
||||
#define COMPILE_ASSERT(expr) \
|
||||
DART_UNUSED typedef CompileAssert<(static_cast<bool>(expr))> \
|
||||
COMPILE_ASSERT_JOIN(CompileAssertTypeDef, __LINE__)[static_cast<bool>(expr) \
|
||||
? 1 : -1]
|
||||
COMPILE_ASSERT_JOIN(CompileAssertTypeDef, \
|
||||
__LINE__)[static_cast<bool>(expr) ? 1 : -1]
|
||||
#endif // !defined(COMPILE_ASSERT)
|
||||
|
||||
#if defined(TESTING)
|
||||
@@ -365,14 +354,11 @@ struct CompileAssert {
|
||||
#define EXPECT_GE(left, right) \
|
||||
dart::Expect(__FILE__, __LINE__).GreaterEqual((left), (right))
|
||||
|
||||
#define EXPECT_NOTNULL(ptr) \
|
||||
dart::Expect(__FILE__, __LINE__).NotNull((ptr))
|
||||
#define EXPECT_NOTNULL(ptr) dart::Expect(__FILE__, __LINE__).NotNull((ptr))
|
||||
|
||||
#define FAIL(error) \
|
||||
dart::Expect(__FILE__, __LINE__).Fail("%s", error)
|
||||
#define FAIL(error) dart::Expect(__FILE__, __LINE__).Fail("%s", error)
|
||||
|
||||
#define FAIL1(format, p1) \
|
||||
dart::Expect(__FILE__, __LINE__).Fail(format, (p1))
|
||||
#define FAIL1(format, p1) dart::Expect(__FILE__, __LINE__).Fail(format, (p1))
|
||||
|
||||
#define FAIL2(format, p1, p2) \
|
||||
dart::Expect(__FILE__, __LINE__).Fail(format, (p1), (p2))
|
||||
|
||||
@@ -24,8 +24,7 @@ static const unsigned __int64 kQuietNaNMask =
|
||||
#endif /* va_copy */
|
||||
|
||||
|
||||
#define NAN \
|
||||
*reinterpret_cast<const double*>(&kQuietNaNMask)
|
||||
#define NAN *reinterpret_cast<const double*>(&kQuietNaNMask)
|
||||
|
||||
namespace std {
|
||||
|
||||
|
||||
@@ -5,7 +5,11 @@
|
||||
#ifndef RUNTIME_PLATFORM_FLOATING_POINT_H_
|
||||
#define RUNTIME_PLATFORM_FLOATING_POINT_H_
|
||||
|
||||
inline double fmod_ieee(double x, double y) { return fmod(x, y); }
|
||||
inline double atan2_ieee(double y, double x) { return atan2(y, x); }
|
||||
inline double fmod_ieee(double x, double y) {
|
||||
return fmod(x, y);
|
||||
}
|
||||
inline double atan2_ieee(double y, double x) {
|
||||
return atan2(y, x);
|
||||
}
|
||||
|
||||
#endif // RUNTIME_PLATFORM_FLOATING_POINT_H_
|
||||
|
||||
@@ -38,9 +38,8 @@ double atan2_ieee(double x, double y) {
|
||||
// Same is with index_y.
|
||||
int index_x = (cls_x & _FPCLASS_PINF) != 0 ? 0 : 1;
|
||||
int index_y = (cls_y & _FPCLASS_PINF) != 0 ? 0 : 1;
|
||||
static double atans_at_infinities[2][2] =
|
||||
{ { atan2(1., 1.), atan2(1., -1.) },
|
||||
{ atan2(-1., 1.), atan2(-1., -1.) } };
|
||||
static double atans_at_infinities[2][2] = {
|
||||
{atan2(1., 1.), atan2(1., -1.)}, {atan2(-1., 1.), atan2(-1., -1.)}};
|
||||
return atans_at_infinities[index_x][index_y];
|
||||
} else {
|
||||
return atan2(x, y);
|
||||
|
||||
+12
-17
@@ -195,9 +195,7 @@ struct simd128_value_t {
|
||||
v[0] = double_storage[0];
|
||||
v[1] = double_storage[1];
|
||||
}
|
||||
void writeTo(simd128_value_t* v) {
|
||||
*v = *this;
|
||||
}
|
||||
void writeTo(simd128_value_t* v) { *v = *this; }
|
||||
};
|
||||
|
||||
// Processor architecture detection. For more info on what's defined, see:
|
||||
@@ -232,8 +230,7 @@ typedef struct {
|
||||
} data_[4];
|
||||
} simd_value_t;
|
||||
typedef simd_value_t fpu_register_t;
|
||||
#define simd_value_safe_load(addr) \
|
||||
(*reinterpret_cast<simd_value_t *>(addr))
|
||||
#define simd_value_safe_load(addr) (*reinterpret_cast<simd_value_t*>(addr))
|
||||
#define simd_value_safe_store(addr, value) \
|
||||
do { \
|
||||
reinterpret_cast<simd_value_t*>(addr)->data_[0] = value.data_[0]; \
|
||||
@@ -335,13 +332,11 @@ typedef simd128_value_t fpu_register_t;
|
||||
|
||||
// Verify that host and target architectures match, we cannot
|
||||
// have a 64 bit Dart VM generating 32 bit code or vice-versa.
|
||||
#if defined(TARGET_ARCH_X64) || \
|
||||
defined(TARGET_ARCH_ARM64)
|
||||
#if defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_ARM64)
|
||||
#if !defined(ARCH_IS_64_BIT)
|
||||
#error Mismatched Host/Target architectures.
|
||||
#endif
|
||||
#elif defined(TARGET_ARCH_IA32) || \
|
||||
defined(TARGET_ARCH_ARM) || \
|
||||
#elif defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) || \
|
||||
defined(TARGET_ARCH_MIPS)
|
||||
#if !defined(ARCH_IS_32_BIT)
|
||||
#error Mismatched Host/Target architectures.
|
||||
@@ -510,13 +505,13 @@ const intptr_t kIntptrMax = ~kIntptrMin;
|
||||
// Time constants.
|
||||
const int kMillisecondsPerSecond = 1000;
|
||||
const int kMicrosecondsPerMillisecond = 1000;
|
||||
const int kMicrosecondsPerSecond = (kMicrosecondsPerMillisecond *
|
||||
kMillisecondsPerSecond);
|
||||
const int kMicrosecondsPerSecond =
|
||||
(kMicrosecondsPerMillisecond * kMillisecondsPerSecond);
|
||||
const int kNanosecondsPerMicrosecond = 1000;
|
||||
const int kNanosecondsPerMillisecond = (kNanosecondsPerMicrosecond *
|
||||
kMicrosecondsPerMillisecond);
|
||||
const int kNanosecondsPerSecond = (kNanosecondsPerMicrosecond *
|
||||
kMicrosecondsPerSecond);
|
||||
const int kNanosecondsPerMillisecond =
|
||||
(kNanosecondsPerMicrosecond * kMicrosecondsPerMillisecond);
|
||||
const int kNanosecondsPerSecond =
|
||||
(kNanosecondsPerMicrosecond * kMicrosecondsPerSecond);
|
||||
|
||||
// Helpers to scale micro second times to human understandable values.
|
||||
inline double MicrosecondsToSeconds(int64_t micros) {
|
||||
@@ -558,6 +553,7 @@ public: \
|
||||
fprintf(stderr, "unreachable code\n"); \
|
||||
abort(); \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
void* operator new(size_t size);
|
||||
#endif // !defined(DISALLOW_ALLOCATION)
|
||||
@@ -651,8 +647,7 @@ template<class D, class S>
|
||||
inline D bit_copy(const S& source) {
|
||||
D destination;
|
||||
// This use of memcpy is safe: source and destination cannot overlap.
|
||||
memcpy(&destination,
|
||||
reinterpret_cast<const void*>(&source),
|
||||
memcpy(&destination, reinterpret_cast<const void*>(&source),
|
||||
sizeof(destination));
|
||||
return destination;
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@ class HashMap {
|
||||
|
||||
~HashMap();
|
||||
|
||||
static bool SamePointerValue(void* key1, void* key2) {
|
||||
return key1 == key2;
|
||||
}
|
||||
static bool SamePointerValue(void* key1, void* key2) { return key1 == key2; }
|
||||
|
||||
static uint32_t StringHash(char* key) {
|
||||
uint32_t hash_ = 0;
|
||||
|
||||
@@ -15,11 +15,15 @@ extern "C" void __msan_unpoison(void *, size_t);
|
||||
#define MSAN_UNPOISON(ptr, len) __msan_unpoison(ptr, len)
|
||||
#define NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory))
|
||||
#else // __has_feature(memory_sanitizer)
|
||||
#define MSAN_UNPOISON(ptr, len) do {} while (false && (ptr) == 0 && (len) == 0)
|
||||
#define MSAN_UNPOISON(ptr, len) \
|
||||
do { \
|
||||
} while (false && (ptr) == 0 && (len) == 0)
|
||||
#define NO_SANITIZE_MEMORY
|
||||
#endif // __has_feature(memory_sanitizer)
|
||||
#else // defined(__has_feature)
|
||||
#define MSAN_UNPOISON(ptr, len) do {} while (false && (ptr) == 0 && (len) == 0)
|
||||
#define MSAN_UNPOISON(ptr, len) \
|
||||
do { \
|
||||
} while (false && (ptr) == 0 && (len) == 0)
|
||||
#define NO_SANITIZE_MEMORY
|
||||
#endif // defined(__has_feature)
|
||||
|
||||
|
||||
@@ -57,12 +57,14 @@ class ThreadSignalBlocker {
|
||||
// errors (type long int changed to intptr_t and do/while split on
|
||||
// separate lines with body in {}s) and to also block signals.
|
||||
#define TEMP_FAILURE_RETRY(expression) \
|
||||
({ ThreadSignalBlocker tsb(SIGPROF); \
|
||||
({ \
|
||||
ThreadSignalBlocker tsb(SIGPROF); \
|
||||
intptr_t __result; \
|
||||
do { \
|
||||
__result = (expression); \
|
||||
} while ((__result == -1L) && (errno == EINTR)); \
|
||||
__result; })
|
||||
__result; \
|
||||
})
|
||||
|
||||
// This is a version of TEMP_FAILURE_RETRY which does not use the value
|
||||
// returned from the expression.
|
||||
@@ -72,33 +74,39 @@ class ThreadSignalBlocker {
|
||||
// This macro can be used to insert checks that a call is made, that
|
||||
// was expected to not return EINTR, but did it anyway.
|
||||
#define NO_RETRY_EXPECTED(expression) \
|
||||
({ intptr_t __result = (expression); \
|
||||
({ \
|
||||
intptr_t __result = (expression); \
|
||||
if (__result == -1L && errno == EINTR) { \
|
||||
FATAL("Unexpected EINTR errno"); \
|
||||
} \
|
||||
__result; })
|
||||
__result; \
|
||||
})
|
||||
|
||||
#define VOID_NO_RETRY_EXPECTED(expression) \
|
||||
(static_cast<void>(NO_RETRY_EXPECTED(expression)))
|
||||
|
||||
// Define to check in debug mode, if a signal is currently being blocked.
|
||||
#define CHECK_IS_BLOCKING(signal) \
|
||||
({ sigset_t signal_mask; \
|
||||
({ \
|
||||
sigset_t signal_mask; \
|
||||
int __r = pthread_sigmask(SIG_BLOCK, NULL, &signal_mask); \
|
||||
USE(__r); \
|
||||
ASSERT(__r == 0); \
|
||||
sigismember(&signal_mask, signal); }) \
|
||||
sigismember(&signal_mask, signal); \
|
||||
})
|
||||
|
||||
|
||||
// Versions of the above, that does not enter a signal blocking scope. Use only
|
||||
// when a signal blocking scope is entered manually.
|
||||
#define TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(expression) \
|
||||
({ intptr_t __result; \
|
||||
({ \
|
||||
intptr_t __result; \
|
||||
ASSERT(CHECK_IS_BLOCKING(SIGPROF)); \
|
||||
do { \
|
||||
__result = (expression); \
|
||||
} while ((__result == -1L) && (errno == EINTR)); \
|
||||
__result; })
|
||||
__result; \
|
||||
})
|
||||
|
||||
#define VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(expression) \
|
||||
(static_cast<void>(TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(expression)))
|
||||
|
||||
@@ -52,8 +52,7 @@ void TextBuffer::AddChar(char ch) {
|
||||
}
|
||||
|
||||
|
||||
void TextBuffer::AddRaw(const uint8_t* buffer,
|
||||
intptr_t buffer_length) {
|
||||
void TextBuffer::AddRaw(const uint8_t* buffer, intptr_t buffer_length) {
|
||||
EnsureCapacity(buffer_length);
|
||||
memmove(&buf_[msg_len_], buffer, buffer_length);
|
||||
msg_len_ += buffer_length;
|
||||
|
||||
@@ -24,8 +24,7 @@ class TextBuffer : ValueObject {
|
||||
void EscapeAndAddCodeUnit(uint32_t cu);
|
||||
void AddString(const char* s);
|
||||
void AddEscapedString(const char* s);
|
||||
void AddRaw(const uint8_t* buffer,
|
||||
intptr_t buffer_length);
|
||||
void AddRaw(const uint8_t* buffer, intptr_t buffer_length);
|
||||
|
||||
void Clear();
|
||||
|
||||
|
||||
@@ -39,11 +39,26 @@ int Utils::HighestBit(int64_t v) {
|
||||
uint64_t x = static_cast<uint64_t>((v > 0) ? v : -v);
|
||||
uint64_t t;
|
||||
int r = 0;
|
||||
if ((t = x >> 32) != 0) { x = t; r += 32; }
|
||||
if ((t = x >> 16) != 0) { x = t; r += 16; }
|
||||
if ((t = x >> 8) != 0) { x = t; r += 8; }
|
||||
if ((t = x >> 4) != 0) { x = t; r += 4; }
|
||||
if ((t = x >> 2) != 0) { x = t; r += 2; }
|
||||
if ((t = x >> 32) != 0) {
|
||||
x = t;
|
||||
r += 32;
|
||||
}
|
||||
if ((t = x >> 16) != 0) {
|
||||
x = t;
|
||||
r += 16;
|
||||
}
|
||||
if ((t = x >> 8) != 0) {
|
||||
x = t;
|
||||
r += 8;
|
||||
}
|
||||
if ((t = x >> 4) != 0) {
|
||||
x = t;
|
||||
r += 4;
|
||||
}
|
||||
if ((t = x >> 2) != 0) {
|
||||
x = t;
|
||||
r += 2;
|
||||
}
|
||||
if (x > 1) r += 1;
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -143,14 +143,11 @@ class Utils {
|
||||
return (static_cast<int64_t>(high) << 32) | (low & 0x0ffffffffLL);
|
||||
}
|
||||
|
||||
static bool IsDecimalDigit(char c) {
|
||||
return ('0' <= c) && (c <= '9');
|
||||
}
|
||||
static bool IsDecimalDigit(char c) { return ('0' <= c) && (c <= '9'); }
|
||||
|
||||
static bool IsHexDigit(char c) {
|
||||
return IsDecimalDigit(c)
|
||||
|| (('A' <= c) && (c <= 'F'))
|
||||
|| (('a' <= c) && (c <= 'f'));
|
||||
return IsDecimalDigit(c) || (('A' <= c) && (c <= 'F')) ||
|
||||
(('a' <= c) && (c <= 'f'));
|
||||
}
|
||||
|
||||
static int HexDigitToInt(char c) {
|
||||
@@ -172,9 +169,7 @@ class Utils {
|
||||
static inline bool RangeCheck(intptr_t offset,
|
||||
intptr_t count,
|
||||
intptr_t length) {
|
||||
return offset >= 0 &&
|
||||
count >= 0 &&
|
||||
length >= 0 &&
|
||||
return offset >= 0 && count >= 0 && length >= 0 &&
|
||||
count <= (length - offset);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user