summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authormostynb <mostynb@opera.com>2015-01-07 12:30:27 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-07 20:31:47 +0000
commit21c4d643577ee408e3ba75c32698d86be769ed9c (patch)
tree33e024de003115249a19f87e915f25b2f81e14db /sync
parent86b1767026733087fcfd04cc282b371f96e99957 (diff)
downloadchromium_src-21c4d643577ee408e3ba75c32698d86be769ed9c.zip
chromium_src-21c4d643577ee408e3ba75c32698d86be769ed9c.tar.gz
chromium_src-21c4d643577ee408e3ba75c32698d86be769ed9c.tar.bz2
replace COMPILE_ASSERT with static_assert in sync/
BUG=442514 Review URL: https://codereview.chromium.org/809073005 Cr-Commit-Position: refs/heads/master@{#310352}
Diffstat (limited to 'sync')
-rw-r--r--sync/api/string_ordinal.h28
-rw-r--r--sync/internal_api/public/base/enum_set.h4
-rw-r--r--sync/internal_api/public/base/node_ordinal.h28
-rw-r--r--sync/internal_api/public/base/ordinal.h16
-rw-r--r--sync/internal_api/public/base/ordinal_unittest.cc88
-rw-r--r--sync/protocol/proto_enum_conversions.cc10
-rw-r--r--sync/syncable/model_type.cc4
-rw-r--r--sync/syncable/nigori_util.cc4
-rw-r--r--sync/syncable/syncable_columns.h4
-rw-r--r--sync/syncable/syncable_enum_conversions.cc12
10 files changed, 98 insertions, 100 deletions
diff --git a/sync/api/string_ordinal.h b/sync/api/string_ordinal.h
index 8952d47..8fe9986 100644
--- a/sync/api/string_ordinal.h
+++ b/sync/api/string_ordinal.h
@@ -27,20 +27,20 @@ struct StringOrdinalTraits {
typedef Ordinal<StringOrdinalTraits> StringOrdinal;
-COMPILE_ASSERT(StringOrdinal::kZeroDigit == 'a',
- StringOrdinalHasCorrectZeroDigit);
-COMPILE_ASSERT(StringOrdinal::kOneDigit == 'b',
- StringOrdinalHasCorrectOneDigit);
-COMPILE_ASSERT(StringOrdinal::kMidDigit == 'n',
- StringOrdinalHasCorrectMidDigit);
-COMPILE_ASSERT(StringOrdinal::kMaxDigit == 'z',
- StringOrdinalHasCorrectMaxDigit);
-COMPILE_ASSERT(StringOrdinal::kMidDigitValue == 13,
- StringOrdinalHasCorrectMidDigitValue);
-COMPILE_ASSERT(StringOrdinal::kMaxDigitValue == 25,
- StringOrdinalHasCorrectMaxDigitValue);
-COMPILE_ASSERT(StringOrdinal::kRadix == 26,
- StringOrdinalHasCorrectRadix);
+static_assert(StringOrdinal::kZeroDigit == 'a',
+ "StringOrdinal has incorrect zero digit");
+static_assert(StringOrdinal::kOneDigit == 'b',
+ "StringOrdinal has incorrect one digit");
+static_assert(StringOrdinal::kMidDigit == 'n',
+ "StringOrdinal has incorrect mid digit");
+static_assert(StringOrdinal::kMaxDigit == 'z',
+ "StringOrdinal has incorrect max digit");
+static_assert(StringOrdinal::kMidDigitValue == 13,
+ "StringOrdinal has incorrect mid digit value");
+static_assert(StringOrdinal::kMaxDigitValue == 25,
+ "StringOrdinal has incorrect max digit value");
+static_assert(StringOrdinal::kRadix == 26,
+ "StringOrdinal has incorrect radix");
} // namespace syncer
diff --git a/sync/internal_api/public/base/enum_set.h b/sync/internal_api/public/base/enum_set.h
index 85d9a54..4061a03 100644
--- a/sync/internal_api/public/base/enum_set.h
+++ b/sync/internal_api/public/base/enum_set.h
@@ -46,8 +46,8 @@ class EnumSet {
static const E kMinValue = MinEnumValue;
static const E kMaxValue = MaxEnumValue;
static const size_t kValueCount = kMaxValue - kMinValue + 1;
- COMPILE_ASSERT(kMinValue < kMaxValue,
- min_value_must_be_less_than_max_value);
+ static_assert(kMinValue < kMaxValue,
+ "min value must be less than max value");
private:
// Declaration needed by Iterator.
diff --git a/sync/internal_api/public/base/node_ordinal.h b/sync/internal_api/public/base/node_ordinal.h
index bc9a04b..35afec7 100644
--- a/sync/internal_api/public/base/node_ordinal.h
+++ b/sync/internal_api/public/base/node_ordinal.h
@@ -24,20 +24,20 @@ struct NodeOrdinalTraits {
typedef Ordinal<NodeOrdinalTraits> NodeOrdinal;
-COMPILE_ASSERT(static_cast<char>(NodeOrdinal::kZeroDigit) == '\x00',
- NodeOrdinalHasCorrectZeroDigit);
-COMPILE_ASSERT(static_cast<char>(NodeOrdinal::kOneDigit) == '\x01',
- NodeOrdinalHasCorrectOneDigit);
-COMPILE_ASSERT(static_cast<char>(NodeOrdinal::kMidDigit) == '\x80',
- NodeOrdinalHasCorrectMidDigit);
-COMPILE_ASSERT(static_cast<char>(NodeOrdinal::kMaxDigit) == '\xff',
- NodeOrdinalHasCorrectMaxDigit);
-COMPILE_ASSERT(NodeOrdinal::kMidDigitValue == 128,
- NodeOrdinalHasCorrectMidDigitValue);
-COMPILE_ASSERT(NodeOrdinal::kMaxDigitValue == 255,
- NodeOrdinalHasCorrectMaxDigitValue);
-COMPILE_ASSERT(NodeOrdinal::kRadix == 256,
- NodeOrdinalHasCorrectRadix);
+static_assert(static_cast<char>(NodeOrdinal::kZeroDigit) == '\x00',
+ "NodeOrdinal has incorrect zero digit");
+static_assert(static_cast<char>(NodeOrdinal::kOneDigit) == '\x01',
+ "NodeOrdinal has incorrect one digit");
+static_assert(static_cast<char>(NodeOrdinal::kMidDigit) == '\x80',
+ "NodeOrdinal has incorrect mid digit");
+static_assert(static_cast<char>(NodeOrdinal::kMaxDigit) == '\xff',
+ "NodeOrdinal has incorrect max digit");
+static_assert(NodeOrdinal::kMidDigitValue == 128,
+ "NodeOrdinal has incorrect mid digit value");
+static_assert(NodeOrdinal::kMaxDigitValue == 255,
+ "NodeOrdinal has incorrect max digit value");
+static_assert(NodeOrdinal::kRadix == 256,
+ "NodeOrdinal has incorrect radix");
// Converts an int64 position (usually from the position_in_parent
// field of SyncEntity) to a NodeOrdinal. This transformation
diff --git a/sync/internal_api/public/base/ordinal.h b/sync/internal_api/public/base/ordinal.h
index cb67b45..32d2ff6 100644
--- a/sync/internal_api/public/base/ordinal.h
+++ b/sync/internal_api/public/base/ordinal.h
@@ -141,15 +141,13 @@ class Ordinal {
static const unsigned int kMaxDigitValue = kMaxDigit - kZeroDigit;
static const unsigned int kRadix = kMaxDigitValue + 1;
- COMPILE_ASSERT(kOneDigit > kZeroDigit, OrdinalOneDigitGreaterThanMinDigit);
- COMPILE_ASSERT(kMidDigit > kOneDigit, OrdinalMidDigitGreaterThanOneDigit);
- COMPILE_ASSERT(kMaxDigit > kMidDigit, OrdinalMaxDigitGreaterThanMidDigit);
- COMPILE_ASSERT(kMinLength > 0, OrdinalMinLengthIsPositive);
- COMPILE_ASSERT(kMidDigitValue > 1, OrdinalMidDigitValueGreaterThanOne);
- COMPILE_ASSERT(kMaxDigitValue > kMidDigitValue,
- OrdinalMaxDigitValueGreaterThanMidDigitValue);
- COMPILE_ASSERT(kRadix == kMaxDigitValue + 1,
- OrdinalRadixIsMaxDigitValuePlusOne);
+ static_assert(kOneDigit > kZeroDigit, "incorrect ordinal one digit");
+ static_assert(kMidDigit > kOneDigit, "incorrect ordinal mid digit");
+ static_assert(kMaxDigit > kMidDigit, "incorrect ordinal max digit");
+ static_assert(kMinLength > 0, "incorrect ordinal min length");
+ static_assert(kMidDigitValue > 1, "incorrect ordinal mid digit");
+ static_assert(kMaxDigitValue > kMidDigitValue, "incorrect ordinal max digit");
+ static_assert(kRadix == kMaxDigitValue + 1, "incorrect ordinal radix");
private:
// Returns true iff the given byte string satisfies the criteria for
diff --git a/sync/internal_api/public/base/ordinal_unittest.cc b/sync/internal_api/public/base/ordinal_unittest.cc
index 8c77d6d..7401e83 100644
--- a/sync/internal_api/public/base/ordinal_unittest.cc
+++ b/sync/internal_api/public/base/ordinal_unittest.cc
@@ -38,50 +38,50 @@ typedef Ordinal<TestOrdinalTraits> TestOrdinal;
typedef Ordinal<LongOrdinalTraits> LongOrdinal;
typedef Ordinal<LargeOrdinalTraits> LargeOrdinal;
-COMPILE_ASSERT(TestOrdinal::kZeroDigit == '0',
- TestOrdinalHasCorrectZeroDigit);
-COMPILE_ASSERT(TestOrdinal::kOneDigit == '1',
- TestOrdinalHasCorrectOneDigit);
-COMPILE_ASSERT(TestOrdinal::kMidDigit == '2',
- TestOrdinalHasCorrectMidDigit);
-COMPILE_ASSERT(TestOrdinal::kMaxDigit == '3',
- TestOrdinalHasCorrectMaxDigit);
-COMPILE_ASSERT(TestOrdinal::kMidDigitValue == 2,
- TestOrdinalHasCorrectMidDigitValue);
-COMPILE_ASSERT(TestOrdinal::kMaxDigitValue == 3,
- TestOrdinalHasCorrectMaxDigitValue);
-COMPILE_ASSERT(TestOrdinal::kRadix == 4,
- TestOrdinalHasCorrectRadix);
-
-COMPILE_ASSERT(LongOrdinal::kZeroDigit == '0',
- LongOrdinalkZeroDigit_incorrect);
-COMPILE_ASSERT(LongOrdinal::kOneDigit == '1',
- LongOrdinalkOneDigit_incorrect);
-COMPILE_ASSERT(LongOrdinal::kMidDigit == '5',
- LongOrdinalkMidDigit_incorrect);
-COMPILE_ASSERT(LongOrdinal::kMaxDigit == '9',
- LongOrdinalkMaxDigit_incorrect);
-COMPILE_ASSERT(LongOrdinal::kMidDigitValue == 5,
- LongOrdinalkMidDigitValue_incorrect);
-COMPILE_ASSERT(LongOrdinal::kMaxDigitValue == 9,
- LongOrdinalkMaxDigitValue_incorrect);
-COMPILE_ASSERT(LongOrdinal::kRadix == 10,
- LongOrdinalkRadix_incorrect);
-
-COMPILE_ASSERT(static_cast<char>(LargeOrdinal::kZeroDigit) == '\x00',
- LargeOrdinalkZeroDigit_incorrect);
-COMPILE_ASSERT(static_cast<char>(LargeOrdinal::kOneDigit) == '\x01',
- LargeOrdinalkOneDigit_incorrect);
-COMPILE_ASSERT(static_cast<char>(LargeOrdinal::kMidDigit) == '\x80',
- LargeOrdinalkMidDigit_incorrect);
-COMPILE_ASSERT(static_cast<char>(LargeOrdinal::kMaxDigit) == '\xff',
- LargeOrdinalkMaxDigit_incorrect);
-COMPILE_ASSERT(LargeOrdinal::kMidDigitValue == 128,
- LargeOrdinalkMidDigitValue_incorrect);
-COMPILE_ASSERT(LargeOrdinal::kMaxDigitValue == 255,
- LargeOrdinalkMaxDigitValue_incorrect);
-COMPILE_ASSERT(LargeOrdinal::kRadix == 256,
- LargeOrdinalkRadix_incorrect);
+static_assert(TestOrdinal::kZeroDigit == '0',
+ "incorrect TestOrdinal zero digit");
+static_assert(TestOrdinal::kOneDigit == '1',
+ "incorrect TestOrdinal one digit");
+static_assert(TestOrdinal::kMidDigit == '2',
+ "incorrect TestOrdinal min digit");
+static_assert(TestOrdinal::kMaxDigit == '3',
+ "incorrect TestOrdinal max digit");
+static_assert(TestOrdinal::kMidDigitValue == 2,
+ "incorrect TestOrdinal mid digit value");
+static_assert(TestOrdinal::kMaxDigitValue == 3,
+ "incorrect TestOrdinal max digit value");
+static_assert(TestOrdinal::kRadix == 4,
+ "incorrect TestOrdinal radix");
+
+static_assert(LongOrdinal::kZeroDigit == '0',
+ "incorrect LongOrdinal zero digit");
+static_assert(LongOrdinal::kOneDigit == '1',
+ "incorrect LongOrdinal one digit");
+static_assert(LongOrdinal::kMidDigit == '5',
+ "incorrect LongOrdinal mid digit");
+static_assert(LongOrdinal::kMaxDigit == '9',
+ "incorrect LongOrdinal max digit");
+static_assert(LongOrdinal::kMidDigitValue == 5,
+ "incorrect LongOrdinal mid digit value");
+static_assert(LongOrdinal::kMaxDigitValue == 9,
+ "incorrect LongOrdinal max digit value");
+static_assert(LongOrdinal::kRadix == 10,
+ "incorrect LongOrdinal radix");
+
+static_assert(static_cast<char>(LargeOrdinal::kZeroDigit) == '\x00',
+ "incorrect LargeOrdinal zero digit");
+static_assert(static_cast<char>(LargeOrdinal::kOneDigit) == '\x01',
+ "incorrect LargeOrdinal one digit");
+static_assert(static_cast<char>(LargeOrdinal::kMidDigit) == '\x80',
+ "incorrect LargeOrdinal mid digit");
+static_assert(static_cast<char>(LargeOrdinal::kMaxDigit) == '\xff',
+ "incorrect LargeOrdinal max digit");
+static_assert(LargeOrdinal::kMidDigitValue == 128,
+ "incorrect LargeOrdinal mid digit value");
+static_assert(LargeOrdinal::kMaxDigitValue == 255,
+ "incorrect LargeOrdinal max digit value");
+static_assert(LargeOrdinal::kRadix == 256,
+ "incorrect LargeOrdinal radix");
// Create Ordinals that satisfy all but one criterion for validity.
// IsValid() should return false for all of them.
diff --git a/sync/protocol/proto_enum_conversions.cc b/sync/protocol/proto_enum_conversions.cc
index eff952f..e531533 100644
--- a/sync/protocol/proto_enum_conversions.cc
+++ b/sync/protocol/proto_enum_conversions.cc
@@ -11,11 +11,11 @@
namespace syncer {
-#define ASSERT_ENUM_BOUNDS(enum_parent, enum_type, enum_min, enum_max) \
- COMPILE_ASSERT(enum_parent::enum_type##_MIN == enum_parent::enum_min, \
- enum_type##_MIN_not_##enum_min); \
- COMPILE_ASSERT(enum_parent::enum_type##_MAX == enum_parent::enum_max, \
- enum_type##_MAX_not_##enum_max);
+#define ASSERT_ENUM_BOUNDS(enum_parent, enum_type, enum_min, enum_max) \
+ static_assert(enum_parent::enum_type##_MIN == enum_parent::enum_min, \
+ #enum_type "_MIN should be " #enum_min); \
+ static_assert(enum_parent::enum_type##_MAX == enum_parent::enum_max, \
+ #enum_type "_MAX should be " #enum_max);
#define ENUM_CASE(enum_parent, enum_value) \
case enum_parent::enum_value: return #enum_value
diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc
index c7a4aa5..3f1abcb 100644
--- a/sync/syncable/model_type.cc
+++ b/sync/syncable/model_type.cc
@@ -43,9 +43,9 @@ const char* kUserSelectableDataTypeNames[] = {
"tabs",
};
-COMPILE_ASSERT(
+static_assert(
34 == MODEL_TYPE_COUNT,
- update_kUserSelectableDataTypeNames_to_match_UserSelectableTypes);
+ "update kUserSelectableDataTypeName to match UserSelectableTypes");
void AddDefaultFieldValue(ModelType datatype,
sync_pb::EntitySpecifics* specifics) {
diff --git a/sync/syncable/nigori_util.cc b/sync/syncable/nigori_util.cc
index b43acfa..18b8fce 100644
--- a/sync/syncable/nigori_util.cc
+++ b/sync/syncable/nigori_util.cc
@@ -243,7 +243,7 @@ void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types,
bool encrypt_everything,
sync_pb::NigoriSpecifics* nigori) {
nigori->set_encrypt_everything(encrypt_everything);
- COMPILE_ASSERT(34 == MODEL_TYPE_COUNT, UpdateEncryptedTypes);
+ static_assert(34 == MODEL_TYPE_COUNT, "update encrypted types");
nigori->set_encrypt_bookmarks(
encrypted_types.Has(BOOKMARKS));
nigori->set_encrypt_preferences(
@@ -279,7 +279,7 @@ ModelTypeSet GetEncryptedTypesFromNigori(
return ModelTypeSet::All();
ModelTypeSet encrypted_types;
- COMPILE_ASSERT(34 == MODEL_TYPE_COUNT, UpdateEncryptedTypes);
+ static_assert(34 == MODEL_TYPE_COUNT, "update encrypted types");
if (nigori.encrypt_bookmarks())
encrypted_types.Put(BOOKMARKS);
if (nigori.encrypt_preferences())
diff --git a/sync/syncable/syncable_columns.h b/sync/syncable/syncable_columns.h
index 7d3a967..8b3bd9e 100644
--- a/sync/syncable/syncable_columns.h
+++ b/sync/syncable/syncable_columns.h
@@ -72,8 +72,8 @@ static const ColumnSpec g_metas_columns[] = {
};
// At least enforce that there are equal number of column names and fields.
-COMPILE_ASSERT(arraysize(g_metas_columns) >= FIELD_COUNT, missing_column_name);
-COMPILE_ASSERT(arraysize(g_metas_columns) <= FIELD_COUNT, extra_column_names);
+static_assert(arraysize(g_metas_columns) >= FIELD_COUNT, "missing column name");
+static_assert(arraysize(g_metas_columns) <= FIELD_COUNT, "extra column names");
static inline const char* ColumnName(int field) {
DCHECK(field < BEGIN_TEMPS);
diff --git a/sync/syncable/syncable_enum_conversions.cc b/sync/syncable/syncable_enum_conversions.cc
index 7e0a8c9..b98500f 100644
--- a/sync/syncable/syncable_enum_conversions.cc
+++ b/sync/syncable/syncable_enum_conversions.cc
@@ -15,12 +15,12 @@ namespace syncable {
// We can't tokenize expected_min/expected_max since it can be a
// general expression.
#define ASSERT_ENUM_BOUNDS(enum_min, enum_max, expected_min, expected_max) \
- COMPILE_ASSERT(static_cast<int>(enum_min) == \
- static_cast<int>(expected_min), \
- enum_min##_not_expected_min); \
- COMPILE_ASSERT(static_cast<int>(enum_max) == \
- static_cast<int>(expected_max), \
- enum_max##_not_expected_max);
+ static_assert(static_cast<int>(enum_min) == \
+ static_cast<int>(expected_min), \
+ #enum_min " not " #expected_min); \
+ static_assert(static_cast<int>(enum_max) == \
+ static_cast<int>(expected_max), \
+ #enum_max " not " #expected_max);
#define ENUM_CASE(enum_value) case enum_value: return #enum_value