Simplify optimized-CHECK conditional

This optimizes CHECK() only in an official build where DCHECKs are
disabled. An assertion is kept in place to make sure NDEBUG is always
set in this state (DCHECKs are always enabled for is_debug=true) rather
than key on it). We don't currently have a build with DCHECKs where
CHECKs are optimized so this conditional is simpler.

Bug: None
Change-Id: I5e4eb26965305629b8c1515ba9a84f6e9d82a40b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3990631
Commit-Queue: Peter Boström <[email protected]>
Reviewed-by: Lei Zhang <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1065143}
diff --git a/base/check.h b/base/check.h
index 910c1ab4..3fbd09c 100644
--- a/base/check.h
+++ b/base/check.h
@@ -109,9 +109,11 @@
   LAZY_CHECK_STREAM(check_function(__FILE__, __LINE__, #condition), \
                     !ANALYZER_ASSUME_TRUE(condition))
 
-#if defined(OFFICIAL_BUILD) && defined(NDEBUG) && \
-    !BUILDFLAG(DCHECK_IS_CONFIGURABLE)
+#if defined(OFFICIAL_BUILD) && !defined(NDEBUG)
+#error "Debug builds are not expected to be optimized as official builds."
+#endif  // defined(OFFICIAL_BUILD) && !defined(NDEBUG)
 
+#if defined(OFFICIAL_BUILD) && !DCHECK_IS_ON()
 // Note that this uses IMMEDIATE_CRASH_ALWAYS_INLINE to force-inline in debug
 // mode as well. See LoggingTest.CheckCausesDistinctBreakpoints.
 [[noreturn]] IMMEDIATE_CRASH_ALWAYS_INLINE void CheckFailure() {