summaryrefslogtreecommitdiffstats
path: root/base/logging.h
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-11 22:10:17 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-11 22:10:17 +0000
commit94558e636ae78dfaaa996fe5b02416aad67992ca (patch)
tree26d7d1bbda6f197581e664c89b3a45939bf05bd1 /base/logging.h
parente9673155ebe385215c1479125eadba5d7ab111ad (diff)
downloadchromium_src-94558e636ae78dfaaa996fe5b02416aad67992ca.zip
chromium_src-94558e636ae78dfaaa996fe5b02416aad67992ca.tar.gz
chromium_src-94558e636ae78dfaaa996fe5b02416aad67992ca.tar.bz2
Remove DCHECKS from official builds.
We keep the current behavior for regular builds: - debug: DCHECKS enabled. - release: DCHECKS present but inactive; can be activated through the command line. Now we add a new behavior for official builds: - dchecks optimized away. B=4555 Review URL: http://codereview.chromium.org/13231 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6830 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/logging.h')
-rw-r--r--base/logging.h62
1 files changed, 60 insertions, 2 deletions
diff --git a/base/logging.h b/base/logging.h
index 85c57b3..062ce8e 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -258,7 +258,64 @@ std::string* MakeCheckOpString(const int& v1, const int& v2, const char* names)
// foo.CheckThatFoo();
// #endif
+#ifdef OFFICIAL_BUILD
+// We want to have optimized code for an official build so we remove DLOGS and
+// DCHECK from the executable.
+
+#define DLOG(severity) \
+ true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity)
+
+#define DLOG_IF(severity, condition) \
+ true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity)
+
+#define DLOG_ASSERT(condition) \
+ true ? (void) 0 : LOG_ASSERT(condition)
+
+enum { DEBUG_MODE = 0 };
+
+// This macro can be followed by a sequence of stream parameters in
+// non-debug mode. The DCHECK and friends macros use this so that
+// the expanded expression DCHECK(foo) << "asdf" is still syntactically
+// valid, even though the expression will get optimized away.
+#define NDEBUG_EAT_STREAM_PARAMETERS \
+ logging::LogMessage(__FILE__, __LINE__).stream()
+
+#define DCHECK(condition) \
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS
+
+#define DCHECK_EQ(val1, val2) \
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS
+
+#define DCHECK_NE(val1, val2) \
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS
+
+#define DCHECK_LE(val1, val2) \
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS
+
+#define DCHECK_LT(val1, val2) \
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS
+
+#define DCHECK_GE(val1, val2) \
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS
+
+#define DCHECK_GT(val1, val2) \
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS
+
+#define DCHECK_STREQ(str1, str2) \
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS
+
+#define DCHECK_STRCASEEQ(str1, str2) \
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS
+
+#define DCHECK_STRNE(str1, str2) \
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS
+
+#define DCHECK_STRCASENE(str1, str2) \
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS
+
+#else
#ifndef NDEBUG
+// On a regular debug build, we want to have DCHECKS and DLOGS enabled.
#define DLOG(severity) LOG(severity)
#define DLOG_IF(severity, condition) LOG_IF(severity, condition)
@@ -312,7 +369,8 @@ DECLARE_DCHECK_STROP_IMPL(_stricmp, false)
#define DCHECK_BOUND(B,A) DCHECK(B <= (sizeof(A)/sizeof(A[0])))
#else // NDEBUG
-
+// On a regular release build we want to be able to enable DCHECKS through the
+// command line.
#define DLOG(severity) \
true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity)
@@ -407,6 +465,7 @@ DEFINE_DCHECK_OP_IMPL(GT, > )
#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
#define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2)
+#endif // OFFICIAL_BUILD
#define NOTREACHED() DCHECK(false)
@@ -541,4 +600,3 @@ inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) {
#endif
#endif // BASE_LOGGING_H_
-