summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorvmpstr <vmpstr@chromium.org>2014-10-02 16:09:13 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-02 23:12:18 +0000
commit0456d13053908dc3929035e4abf8799c6e9627a5 (patch)
tree3ca46e00ed8085ae718cef36ac3dee03ca5447d9 /base
parentba1aa68e3db415a56c2d16e3183c5ffa0a3ddcc3 (diff)
downloadchromium_src-0456d13053908dc3929035e4abf8799c6e9627a5.zip
chromium_src-0456d13053908dc3929035e4abf8799c6e9627a5.tar.gz
chromium_src-0456d13053908dc3929035e4abf8799c6e9627a5.tar.bz2
base: Add CHECK_IMPLIES and DCHECK_IMPLIES.
This patch adds convenience defines for implies relationship. a implies b is equivalent to !a || b. This allows things like the following: CHECK_IMPLIES(ptr, ptr->is_good); instead of the more cumbersome: CHECK(!ptr || ptr->is_good). Review URL: https://codereview.chromium.org/576073007 Cr-Commit-Position: refs/heads/master@{#297941}
Diffstat (limited to 'base')
-rw-r--r--base/logging.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/base/logging.h b/base/logging.h
index 4661f0f..1ca4f46b 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -532,6 +532,7 @@ DEFINE_CHECK_OP_IMPL(GT, > )
#define CHECK_LT(val1, val2) CHECK_OP(LT, < , val1, val2)
#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2)
#define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2)
+#define CHECK_IMPLIES(val1, val2) CHECK(!(val1) || (val2))
#if defined(NDEBUG)
#define ENABLE_DLOG 0
@@ -662,6 +663,7 @@ const LogSeverity LOG_DCHECK = LOG_INFO;
#define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2)
#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
#define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2)
+#define DCHECK_IMPLIES(val1, val2) DCHECK(!(val1) || (val2))
#if defined(NDEBUG) && defined(OS_CHROMEOS)
#define NOTREACHED() LOG(ERROR) << "NOTREACHED() hit in " << \