Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: src/base/logging.h

Issue 2642383002: Fix CHECK_OP implementation in Release builds (Closed)
Patch Set: Add tests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/unittests/base/logging-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/logging.h
diff --git a/src/base/logging.h b/src/base/logging.h
index cb2ff8f92fa1f63aac99d31d1962e93289cb81e2..e852dde8dda7b4d0bc6fe10c4ce87ac778515f4e 100644
--- a/src/base/logging.h
+++ b/src/base/logging.h
@@ -43,13 +43,13 @@ namespace base {
//
// We make sure CHECK et al. always evaluates their arguments, as
// doing CHECK(FunctionWithSideEffect()) is a common idiom.
-#define CHECK(condition) \
- do { \
- if (V8_UNLIKELY(!(condition))) { \
- V8_Fatal(__FILE__, __LINE__, "Check failed: %s.", #condition); \
- } \
+#define CHECK_WITH_MSG(condition, message) \
+ do { \
+ if (V8_UNLIKELY(!(condition))) { \
+ V8_Fatal(__FILE__, __LINE__, "Check failed: %s.", message); \
+ } \
} while (0)
-
+#define CHECK(condition) CHECK_WITH_MSG(condition, #condition)
#ifdef DEBUG
@@ -70,7 +70,12 @@ namespace base {
// Make all CHECK functions discard their log strings to reduce code
// bloat for official release builds.
-#define CHECK_OP(name, op, lhs, rhs) CHECK((lhs)op(rhs))
+#define CHECK_OP(name, op, lhs, rhs) \
+ do { \
+ bool _cmp = \
+ ::v8::base::Cmp##name##Impl<decltype(lhs), decltype(rhs)>(lhs, rhs); \
+ CHECK_WITH_MSG(_cmp, #lhs " " #op " " #rhs); \
+ } while (0)
#endif
@@ -199,7 +204,8 @@ DEFINE_CHECK_OP_IMPL(GT, > )
#define CHECK_GT(lhs, rhs) CHECK_OP(GT, >, lhs, rhs)
#define CHECK_NULL(val) CHECK((val) == nullptr)
#define CHECK_NOT_NULL(val) CHECK((val) != nullptr)
-#define CHECK_IMPLIES(lhs, rhs) CHECK(!(lhs) || (rhs))
+#define CHECK_IMPLIES(lhs, rhs) \
+ CHECK_WITH_MSG(!(lhs) || (rhs), #lhs " implies " #rhs)
} // namespace base
} // namespace v8
« no previous file with comments | « no previous file | test/unittests/base/logging-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698