Index: util/misc/initialization_state_dcheck.h |
diff --git a/util/misc/initialization_state_dcheck.h b/util/misc/initialization_state_dcheck.h |
index 88f7ac1e9a946da993f348078a30c5ec111c2cd5..96d7cf1b4af09c287b3f3b293504489e07cf04e0 100644 |
--- a/util/misc/initialization_state_dcheck.h |
+++ b/util/misc/initialization_state_dcheck.h |
@@ -18,6 +18,7 @@ |
//! \file |
#include "base/basictypes.h" |
+#include "base/compiler_specific.h" |
#include "base/logging.h" |
#include "util/misc/initialization_state.h" |
@@ -155,14 +156,9 @@ class InitializationStateDcheck : public InitializationState { |
#else |
// Since this is to be used as a DCHECK (for debugging), it should be |
-// non-intrusive in non-DCHECK (non-debug, release) builds. An empty struct |
-// would still have a nonzero size (rationale: |
Mark Mentovai
2015/02/11 20:47:12
This comment explains why this wasn’t done before.
scottmg
2015/02/11 21:03:31
Done.
It seemed unnecessarily tricky to me given
|
-// http://www.stroustrup.com/bs_faq2.html#sizeof-empty). Zero-length arrays are |
-// technically invalid according to the standard, but clang and g++ accept them |
-// without complaint even with warnings turned up. They take up no space at all, |
-// and they can be “initialized” with the same () syntax used to initialize |
-// objects of the DCHECK_IS_ON InitializationStateDcheck class above. |
-using InitializationStateDcheck = bool[0]; |
+// non-intrusive in non-DCHECK (non-debug, release) builds. |
+struct InitializationStateDcheck { |
+}; |
namespace internal { |
@@ -175,18 +171,14 @@ inline bool EatInitializationState(const InitializationStateDcheck*) { |
} // namepspace internal |
-// The contents of these DCHECKs will never be evaluated, but they make use of |
-// initialization_state_dcheck to avoid triggering -Wunused-private-field |
-// warnings. |
+// Avoid triggering warnings by making repurposing these macros when DCHECKs are |
+// disabled. |
#define INITIALIZATION_STATE_SET_INITIALIZING(initialization_state_dcheck) \ |
- DCHECK(::crashpad::internal::EatInitializationState( \ |
- &(initialization_state_dcheck))) |
+ ALLOW_UNUSED_LOCAL(initialization_state_dcheck) |
#define INITIALIZATION_STATE_SET_VALID(initialization_state_dcheck) \ |
- DCHECK(::crashpad::internal::EatInitializationState( \ |
- &(initialization_state_dcheck))) |
+ ALLOW_UNUSED_LOCAL(initialization_state_dcheck) |
#define INITIALIZATION_STATE_DCHECK_VALID(initialization_state_dcheck) \ |
- DCHECK(::crashpad::internal::EatInitializationState( \ |
- &(initialization_state_dcheck))) |
+ ALLOW_UNUSED_LOCAL(initialization_state_dcheck) |
#endif |