Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2318)

Unified Diff: base/metrics/histogram_macros_internal.h

Issue 2469993002: Assert enum type equivalence in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: add no-compile tests Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/BUILD.gn ('k') | base/metrics/histogram_unittest.nc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram_macros_internal.h
diff --git a/base/metrics/histogram_macros_internal.h b/base/metrics/histogram_macros_internal.h
index 35a1021afac8f33b4f3938c483515f66354eaf25..2deb9284a177fa26a4e3ecdd155addcb96422f6e 100644
--- a/base/metrics/histogram_macros_internal.h
+++ b/base/metrics/histogram_macros_internal.h
@@ -100,10 +100,17 @@
// values >= boundary_value so that mistakes in calling the UMA enumeration
// macros can be detected.
#define INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary, flag) \
+ do { \
+ static_assert( \
+ !std::is_enum<decltype(sample)>::value || \
+ !std::is_enum<decltype(boundary)>::value || \
+ std::is_same<std::remove_const<decltype(sample)>::type, \
+ std::remove_const<decltype(boundary)>::type>::value, \
+ "|sample| and |boundary| shouldn't be of different enums"); \
STATIC_HISTOGRAM_POINTER_BLOCK( \
- name, Add(sample), \
- base::LinearHistogram::FactoryGet( \
- name, 1, boundary, boundary + 1, flag))
+ name, Add(sample), base::LinearHistogram::FactoryGet( \
+ name, 1, boundary, boundary + 1, flag)); \
dcheng 2016/11/17 05:09:55 I know the ship has sailed (and we're migrating of
+ } while (0)
// This is a helper macro used by other macros and shouldn't be used directly.
// This is necessary to expand __COUNTER__ to an actual value.
« no previous file with comments | « base/BUILD.gn ('k') | base/metrics/histogram_unittest.nc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698