Fix the build when DCHECK_IS_CONFIGURABLE is used
We have to check with define() whether the variable is defined instead
looking at its value as it couldn't be defined. It's defined with:
if (dcheck_is_configurable) {
defines += [ "DCHECK_IS_CONFIGURABLE=1" ]
}
And the compilation failure:
In file included from gen/modules/desktop_capture/linux/pipewire_stubs.cc:3:
In file included from gen/modules/desktop_capture/linux/pipewire_stubs.h:11:
../../base/logging.h:846:5: error: 'DCHECK_IS_CONFIGURABLE' is not defined, evaluates to 0 [-Werror,-Wundef]
^
\#if DCHECK_IS_CONFIGURABLE
Change-Id: I85137252cb3ebd6965037b747574804a3c837f40
Reviewed-on: https://chromium-review.googlesource.com/c/1312948
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Tomáš Popela <tomas.popela@gmail.com>
Cr-Commit-Position: refs/heads/master@{#606230}
diff --git a/base/feature_list.cc b/base/feature_list.cc
index 1610eec..18097be 100644
--- a/base/feature_list.cc
+++ b/base/feature_list.cc
@@ -76,10 +76,10 @@
} // namespace
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DHECK_IS_CONFIGURABLE)
const Feature kDCheckIsFatalFeature{"DcheckIsFatal",
base::FEATURE_DISABLED_BY_DEFAULT};
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DHECK_IS_CONFIGURABLE)
FeatureList::FeatureList() = default;
@@ -263,7 +263,7 @@
// Note: Intentional leak of global singleton.
g_feature_list_instance = instance.release();
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DHECK_IS_CONFIGURABLE)
// Update the behaviour of LOG_DCHECK to match the Feature configuration.
// DCHECK is also forced to be FATAL if we are running a death-test.
// TODO(asvitkine): If we find other use-cases that need integrating here
@@ -275,7 +275,7 @@
} else {
logging::LOG_DCHECK = logging::LOG_INFO;
}
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DHECK_IS_CONFIGURABLE)
}
// static
diff --git a/base/feature_list.h b/base/feature_list.h
index 2237507a..2dfeba7 100644
--- a/base/feature_list.h
+++ b/base/feature_list.h
@@ -43,12 +43,12 @@
const FeatureState default_state;
};
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DHECK_IS_CONFIGURABLE)
// DCHECKs have been built-in, and are configurable at run-time to be fatal, or
// not, via a DcheckIsFatal feature. We define the Feature here since it is
// checked in FeatureList::SetInstance(). See https://crbug.com/596231.
extern BASE_EXPORT const Feature kDCheckIsFatalFeature;
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DHECK_IS_CONFIGURABLE)
// The FeatureList class is used to determine whether a given feature is on or
// off. It provides an authoritative answer, taking into account command-line
diff --git a/base/logging.cc b/base/logging.cc
index b5c21a5..cd46649 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -387,12 +387,12 @@
} // namespace
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DHECK_IS_CONFIGURABLE)
// In DCHECK-enabled Chrome builds, allow the meaning of LOG_DCHECK to be
// determined at run-time. We default it to INFO, to avoid it triggering
// crashes before the run-time has explicitly chosen the behaviour.
BASE_EXPORT logging::LogSeverity LOG_DCHECK = LOG_INFO;
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DHECK_IS_CONFIGURABLE)
// This is never instantiated, it's just used for EAT_STREAM_PARAMETERS to have
// an object of the correct type on the LHS of the unused part of the ternary
diff --git a/base/logging.h b/base/logging.h
index d73c2b6..e115aeb 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -843,7 +843,7 @@
#if DCHECK_IS_ON()
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DHECK_IS_CONFIGURABLE)
BASE_EXPORT extern LogSeverity LOG_DCHECK;
#else
const LogSeverity LOG_DCHECK = LOG_FATAL;
diff --git a/base/logging_unittest.cc b/base/logging_unittest.cc
index df2d425..c3c697b8 100644
--- a/base/logging_unittest.cc
+++ b/base/logging_unittest.cc
@@ -540,7 +540,7 @@
}
void DcheckEmptyFunction2() {}
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DHECK_IS_CONFIGURABLE)
class ScopedDcheckSeverity {
public:
ScopedDcheckSeverity(LogSeverity new_severity) : old_severity_(LOG_DCHECK) {
@@ -552,7 +552,7 @@
private:
LogSeverity old_severity_;
};
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DHECK_IS_CONFIGURABLE)
// https://crbug.com/709067 tracks test flakiness on iOS.
#if defined(OS_IOS)
@@ -561,12 +561,12 @@
#define MAYBE_Dcheck Dcheck
#endif
TEST_F(LoggingTest, MAYBE_Dcheck) {
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DHECK_IS_CONFIGURABLE)
// DCHECKs are enabled, and LOG_DCHECK is mutable, but defaults to non-fatal.
// Set it to LOG_FATAL to get the expected behavior from the rest of this
// test.
ScopedDcheckSeverity dcheck_severity(LOG_FATAL);
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DHECK_IS_CONFIGURABLE)
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
// Release build.
@@ -727,7 +727,7 @@
}
} // namespace nested_test
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DHECK_IS_CONFIGURABLE)
TEST_F(LoggingTest, ConfigurableDCheck) {
// Verify that DCHECKs default to non-fatal in configurable-DCHECK builds.
// Note that we require only that DCHECK is non-fatal by default, rather
@@ -777,7 +777,7 @@
EXPECT_LT(LOG_DCHECK, LOG_FATAL);
}
}
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DHECK_IS_CONFIGURABLE)
#if defined(OS_FUCHSIA)
TEST_F(LoggingTest, FuchsiaLogging) {
diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn
index eb163bf..ecb6683 100644
--- a/build/config/BUILD.gn
+++ b/build/config/BUILD.gn
@@ -63,7 +63,7 @@
if (dcheck_always_on) {
defines += [ "DCHECK_ALWAYS_ON=1" ]
if (dcheck_is_configurable) {
- defines += [ "DCHECK_IS_CONFIGURABLE=1" ]
+ defines += [ "DCHECK_IS_CONFIGURABLE" ]
}
}
if (use_udev) {
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 24134362..86d4a8d 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -3563,11 +3563,11 @@
flag_descriptions::kSoundContentSettingDescription, kOsAll,
FEATURE_VALUE_TYPE(features::kSoundContentSetting)},
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DHECK_IS_CONFIGURABLE)
{"dcheck-is-fatal", flag_descriptions::kDcheckIsFatalName,
flag_descriptions::kDcheckIsFatalDescription, kOsWin,
FEATURE_VALUE_TYPE(base::kDCheckIsFatalFeature)},
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DHECK_IS_CONFIGURABLE)
#if defined(OS_CHROMEOS)
{"slide-top-chrome-with-page-scrolls",
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index 33fbb42..934b1be 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -273,12 +273,12 @@
"Store.";
const char kDatasaverPromptDemoMode[] = "Demo mode";
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DHECK_IS_CONFIGURABLE)
const char kDcheckIsFatalName[] = "DCHECKs are fatal";
const char kDcheckIsFatalDescription[] =
"By default Chrome will evaluate in this build, but only log failures, "
"rather than crashing. If enabled, DCHECKs will crash the calling process.";
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DHECK_IS_CONFIGURABLE)
const char kDebugPackedAppName[] = "Debugging for packed apps";
const char kDebugPackedAppDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index fb3ad97d..b98d55a 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -194,10 +194,10 @@
extern const char kDatasaverPromptDescription[];
extern const char kDatasaverPromptDemoMode[];
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DHECK_IS_CONFIGURABLE)
extern const char kDcheckIsFatalName[];
extern const char kDcheckIsFatalDescription[];
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DHECK_IS_CONFIGURABLE)
extern const char kDebugPackedAppName[];
extern const char kDebugPackedAppDescription[];
diff --git a/chrome/common/channel_info_win.cc b/chrome/common/channel_info_win.cc
index 932a94d..618a1f03 100644
--- a/chrome/common/channel_info_win.cc
+++ b/chrome/common/channel_info_win.cc
@@ -14,7 +14,7 @@
std::string GetChannelName() {
#if defined(GOOGLE_CHROME_BUILD)
base::string16 channel(install_static::GetChromeChannelName());
-#if defined(DCHECK_IS_CONFIGURABLE)
+#if defined(DHECK_IS_CONFIGURABLE)
// Adorn the channel when DCHECKs are baked into the build, as there will be
// a performance hit. See https://crbug.com/812058 for details.
channel += L"-dcheck";
diff --git a/content/renderer/render_process_impl.cc b/content/renderer/render_process_impl.cc
index 07d95dd..7d81e62 100644
--- a/content/renderer/render_process_impl.cc
+++ b/content/renderer/render_process_impl.cc
@@ -85,13 +85,13 @@
kSuggestedReclaimTime));
}
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DHECK_IS_CONFIGURABLE)
void V8DcheckCallbackHandler(const char* file, int line, const char* message) {
// TODO(siggi): Set a crash key or a breadcrumb so the fact that we hit a
// V8 DCHECK gets out in the crash report.
::logging::LogMessage(file, line, logging::LOG_DCHECK).stream() << message;
}
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DHECK_IS_CONFIGURABLE)
} // namespace
@@ -101,7 +101,7 @@
std::unique_ptr<base::TaskScheduler::InitParams> task_scheduler_init_params)
: RenderProcess("Renderer", std::move(task_scheduler_init_params)),
enabled_bindings_(0) {
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DHECK_IS_CONFIGURABLE)
// Some official builds ship with DCHECKs compiled in. Failing DCHECKs then
// are either fatal or simply log the error, based on a feature flag.
// Make sure V8 follows suit by setting a Dcheck handler that forwards to
@@ -120,7 +120,7 @@
v8::V8::SetFlagsFromString(kDisabledFlags, sizeof(kDisabledFlags));
}
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DHECK_IS_CONFIGURABLE)
if (base::SysInfo::IsLowEndDevice()) {
std::string optimize_flag("--optimize-for-size");