cpplint: Cleanup errors
Cleanup errors from upstream cpplint in preparation
for moving art's cpplint fork to upstream tip-of-tree cpplint.
Test: cd art && mm
Bug: 68951293
Change-Id: I15faed4594cbcb8399850f8bdee39d42c0c5b956
diff --git a/runtime/base/allocator.cc b/runtime/base/allocator.cc
index 2a2790c..bb00638 100644
--- a/runtime/base/allocator.cc
+++ b/runtime/base/allocator.cc
@@ -26,7 +26,7 @@
class MallocAllocator FINAL : public Allocator {
public:
- explicit MallocAllocator() {}
+ MallocAllocator() {}
~MallocAllocator() {}
void* Alloc(size_t size) {
@@ -45,7 +45,7 @@
class NoopAllocator FINAL : public Allocator {
public:
- explicit NoopAllocator() {}
+ NoopAllocator() {}
~NoopAllocator() {}
void* Alloc(size_t size ATTRIBUTE_UNUSED) {
diff --git a/runtime/base/bit_struct_detail.h b/runtime/base/bit_struct_detail.h
index 824d7df..49d432e 100644
--- a/runtime/base/bit_struct_detail.h
+++ b/runtime/base/bit_struct_detail.h
@@ -31,88 +31,88 @@
static constexpr size_t BitStructSizeOf();
namespace detail {
- // Select the smallest uintX_t that will fit kBitSize bits.
- template <size_t kBitSize>
- struct MinimumTypeUnsignedHelper {
- using type =
- typename std::conditional<kBitSize == 0, void,
- typename std::conditional<kBitSize <= 8, uint8_t,
- typename std::conditional<kBitSize <= 16, uint16_t,
- typename std::conditional<kBitSize <= 32, uint32_t,
- typename std::conditional<kBitSize <= 64, uint64_t,
- typename std::conditional<kBitSize <= BitSizeOf<uintmax_t>(), uintmax_t,
- void>::type>::type>::type>::type>::type>::type;
- };
+// Select the smallest uintX_t that will fit kBitSize bits.
+template <size_t kBitSize>
+struct MinimumTypeUnsignedHelper {
+ using type =
+ typename std::conditional<kBitSize == 0, void, // NOLINT [whitespace/operators] [3]
+ typename std::conditional<kBitSize <= 8, uint8_t, // NOLINT [whitespace/operators] [3]
+ typename std::conditional<kBitSize <= 16, uint16_t, // NOLINT [whitespace/operators] [3]
+ typename std::conditional<kBitSize <= 32, uint32_t,
+ typename std::conditional<kBitSize <= 64, uint64_t,
+ typename std::conditional<kBitSize <= BitSizeOf<uintmax_t>(), uintmax_t,
+ void>::type>::type>::type>::type>::type>::type;
+};
- // Select the smallest [u]intX_t that will fit kBitSize bits.
- // Automatically picks intX_t or uintX_t based on the sign-ness of T.
- template <typename T, size_t kBitSize>
- struct MinimumTypeHelper {
- using type_unsigned = typename MinimumTypeUnsignedHelper<kBitSize>::type;
+// Select the smallest [u]intX_t that will fit kBitSize bits.
+// Automatically picks intX_t or uintX_t based on the sign-ness of T.
+template <typename T, size_t kBitSize>
+struct MinimumTypeHelper {
+ using type_unsigned = typename MinimumTypeUnsignedHelper<kBitSize>::type;
- using type =
- typename std::conditional</* if */ std::is_signed<T>::value,
- /* then */ typename std::make_signed<type_unsigned>::type,
- /* else */ type_unsigned>::type;
- };
+ using type =
+ typename std::conditional</* if */ std::is_signed<T>::value,
+ /* then */ typename std::make_signed<type_unsigned>::type,
+ /* else */ type_unsigned>::type;
+};
- // Denotes the beginning of a bit struct.
- //
- // This marker is required by the C++ standard in order to
- // have a "common initial sequence".
- //
- // See C++ 9.5.1 [class.union]:
- // If a standard-layout union contains several standard-layout structs that share a common
- // initial sequence ... it is permitted to inspect the common initial sequence of any of
- // standard-layout struct members.
- template <size_t kSize>
- struct DefineBitStructSize {
- private:
- typename MinimumTypeUnsignedHelper<kSize>::type _;
- };
+// Denotes the beginning of a bit struct.
+//
+// This marker is required by the C++ standard in order to
+// have a "common initial sequence".
+//
+// See C++ 9.5.1 [class.union]:
+// If a standard-layout union contains several standard-layout structs that share a common
+// initial sequence ... it is permitted to inspect the common initial sequence of any of
+// standard-layout struct members.
+template <size_t kSize>
+struct DefineBitStructSize {
+ private:
+ typename MinimumTypeUnsignedHelper<kSize>::type _;
+};
- // Check if type "T" has a member called _ in it.
- template <typename T>
- struct HasUnderscoreField {
- private:
- using TrueT = std::integral_constant<bool, true>::type;
- using FalseT = std::integral_constant<bool, false>::type;
+// Check if type "T" has a member called _ in it.
+template <typename T>
+struct HasUnderscoreField {
+ private:
+ using TrueT = std::integral_constant<bool, true>::type;
+ using FalseT = std::integral_constant<bool, false>::type;
- template <typename C>
- static constexpr auto Test(void*) -> decltype(std::declval<C>()._, TrueT{}); // NOLINT
+ template <typename C>
+ static constexpr auto Test(void*) -> decltype(std::declval<C>()._, TrueT{}); // NOLINT
- template <typename>
- static constexpr FalseT Test(...);
+ template <typename>
+ static constexpr FalseT Test(...);
- public:
- static constexpr bool value = decltype(Test<T>(0))::value;
- };
+ public:
+ static constexpr bool value = decltype(Test<T>(0))::value;
+};
- // Infer the type of the member of &T::M.
- template <typename T, typename M>
- M GetMemberType(M T:: *);
+// Infer the type of the member of &T::M.
+template <typename T, typename M>
+M GetMemberType(M T:: *);
- // Ensure the minimal type storage for 'T' matches its declared BitStructSizeOf.
- // Nominally used by the BITSTRUCT_DEFINE_END macro.
- template <typename T>
- static constexpr bool ValidateBitStructSize() {
- static_assert(std::is_union<T>::value, "T must be union");
- static_assert(std::is_standard_layout<T>::value, "T must be standard-layout");
- static_assert(HasUnderscoreField<T>::value, "T must have the _ DefineBitStructSize");
+// Ensure the minimal type storage for 'T' matches its declared BitStructSizeOf.
+// Nominally used by the BITSTRUCT_DEFINE_END macro.
+template <typename T>
+static constexpr bool ValidateBitStructSize() {
+ static_assert(std::is_union<T>::value, "T must be union");
+ static_assert(std::is_standard_layout<T>::value, "T must be standard-layout");
+ static_assert(HasUnderscoreField<T>::value, "T must have the _ DefineBitStructSize");
- const size_t kBitStructSizeOf = BitStructSizeOf<T>();
- static_assert(std::is_same<decltype(GetMemberType(&T::_)),
- DefineBitStructSize<kBitStructSizeOf>>::value,
- "T::_ must be a DefineBitStructSize of the same size");
+ const size_t kBitStructSizeOf = BitStructSizeOf<T>();
+ static_assert(std::is_same<decltype(GetMemberType(&T::_)),
+ DefineBitStructSize<kBitStructSizeOf>>::value,
+ "T::_ must be a DefineBitStructSize of the same size");
- const size_t kExpectedSize = (BitStructSizeOf<T>() < kBitsPerByte)
- ? kBitsPerByte
- : RoundUpToPowerOfTwo(kBitStructSizeOf);
+ const size_t kExpectedSize = (BitStructSizeOf<T>() < kBitsPerByte)
+ ? kBitsPerByte
+ : RoundUpToPowerOfTwo(kBitStructSizeOf);
- // Ensure no extra fields were added in between START/END.
- const size_t kActualSize = sizeof(T) * kBitsPerByte;
- return kExpectedSize == kActualSize;
- }
+ // Ensure no extra fields were added in between START/END.
+ const size_t kActualSize = sizeof(T) * kBitsPerByte;
+ return kExpectedSize == kActualSize;
+}
} // namespace detail
} // namespace art
diff --git a/runtime/base/hash_set.h b/runtime/base/hash_set.h
index bc25b36..c743342 100644
--- a/runtime/base/hash_set.h
+++ b/runtime/base/hash_set.h
@@ -261,7 +261,7 @@
}
HashSet& operator=(HashSet&& other) noexcept {
- HashSet(std::move(other)).swap(*this);
+ HashSet(std::move(other)).swap(*this); // NOLINT [runtime/explicit] [5]
return *this;
}
diff --git a/runtime/base/hash_set_test.cc b/runtime/base/hash_set_test.cc
index 31b28eb..ff745b4 100644
--- a/runtime/base/hash_set_test.cc
+++ b/runtime/base/hash_set_test.cc
@@ -294,7 +294,7 @@
hash = hash * 2 + *iter;
}
return hash;
-};
+}
struct VectorIntHashEquals {
std::size_t operator()(const std::vector<int>& item) const {
diff --git a/runtime/base/mutex_test.cc b/runtime/base/mutex_test.cc
index 752e77a..7eba50b 100644
--- a/runtime/base/mutex_test.cc
+++ b/runtime/base/mutex_test.cc
@@ -97,7 +97,7 @@
struct RecursiveLockWait {
- explicit RecursiveLockWait()
+ RecursiveLockWait()
: mu("test mutex", kDefaultMutexLevel, true), cv("test condition variable", mu) {
}
diff --git a/runtime/base/variant_map.h b/runtime/base/variant_map.h
index 71a1018..fe332d1 100644
--- a/runtime/base/variant_map.h
+++ b/runtime/base/variant_map.h
@@ -74,62 +74,62 @@
// Implementation details for VariantMap.
namespace detail {
- // Allocate a unique counter value each time it's called.
- struct VariantMapKeyCounterAllocator {
- static size_t AllocateCounter() {
- static size_t counter = 0;
- counter++;
+// Allocate a unique counter value each time it's called.
+struct VariantMapKeyCounterAllocator {
+ static size_t AllocateCounter() {
+ static size_t counter = 0;
+ counter++;
- return counter;
+ return counter;
+ }
+};
+
+// Type-erased version of VariantMapKey<T>
+struct VariantMapKeyRaw {
+ // TODO: this may need to call a virtual function to support string comparisons
+ bool operator<(const VariantMapKeyRaw& other) const {
+ return key_counter_ < other.key_counter_;
+ }
+
+ // The following functions need to be virtual since we don't know the compile-time type anymore:
+
+ // Clone the key, creating a copy of the contents.
+ virtual VariantMapKeyRaw* Clone() const = 0;
+
+ // Delete a value whose runtime type is that of the non-erased key's TValue.
+ virtual void ValueDelete(void* value) const = 0;
+
+ // Clone a value whose runtime type is that of the non-erased key's TValue.
+ virtual void* ValueClone(void* value) const = 0;
+
+ // Compare one key to another (same as operator<).
+ virtual bool Compare(const VariantMapKeyRaw* other) const {
+ if (other == nullptr) {
+ return false;
}
- };
+ return key_counter_ < other->key_counter_;
+ }
- // Type-erased version of VariantMapKey<T>
- struct VariantMapKeyRaw {
- // TODO: this may need to call a virtual function to support string comparisons
- bool operator<(const VariantMapKeyRaw& other) const {
- return key_counter_ < other.key_counter_;
- }
+ virtual ~VariantMapKeyRaw() {}
- // The following functions need to be virtual since we don't know the compile-time type anymore:
+ protected:
+ VariantMapKeyRaw()
+ : key_counter_(VariantMapKeyCounterAllocator::AllocateCounter()) {}
+ // explicit VariantMapKeyRaw(size_t counter)
+ // : key_counter_(counter) {}
- // Clone the key, creating a copy of the contents.
- virtual VariantMapKeyRaw* Clone() const = 0;
+ size_t GetCounter() const {
+ return key_counter_;
+ }
- // Delete a value whose runtime type is that of the non-erased key's TValue.
- virtual void ValueDelete(void* value) const = 0;
+ protected:
+ // Avoid the object slicing problem; use Clone() instead.
+ VariantMapKeyRaw(const VariantMapKeyRaw&) = default;
+ VariantMapKeyRaw(VariantMapKeyRaw&&) = default;
- // Clone a value whose runtime type is that of the non-erased key's TValue.
- virtual void* ValueClone(void* value) const = 0;
-
- // Compare one key to another (same as operator<).
- virtual bool Compare(const VariantMapKeyRaw* other) const {
- if (other == nullptr) {
- return false;
- }
- return key_counter_ < other->key_counter_;
- }
-
- virtual ~VariantMapKeyRaw() {}
-
- protected:
- VariantMapKeyRaw()
- : key_counter_(VariantMapKeyCounterAllocator::AllocateCounter()) {}
- // explicit VariantMapKeyRaw(size_t counter)
- // : key_counter_(counter) {}
-
- size_t GetCounter() const {
- return key_counter_;
- }
-
- protected:
- // Avoid the object slicing problem; use Clone() instead.
- VariantMapKeyRaw(const VariantMapKeyRaw&) = default;
- VariantMapKeyRaw(VariantMapKeyRaw&&) = default;
-
- private:
- size_t key_counter_; // Runtime type ID. Unique each time a new type is reified.
- };
+ private:
+ size_t key_counter_; // Runtime type ID. Unique each time a new type is reified.
+};
} // namespace detail
// The base type for keys used by the VariantMap. Users must subclass this type.
@@ -189,9 +189,9 @@
// Implementation details for a stringified VariantMapStringKey.
namespace detail {
- struct VariantMapStringKeyRegistry {
- // TODO
- };
+struct VariantMapStringKeyRegistry {
+ // TODO
+};
} // namespace detail
// Alternative base type for all keys used by VariantMap, supports runtime strings as the name.
@@ -329,7 +329,7 @@
}
// Construct an empty map.
- explicit VariantMap() {}
+ VariantMap() {}
template <typename ... TKeyValue>
explicit VariantMap(const TKeyValue& ... key_value_list) {
diff --git a/runtime/base/variant_map_test.cc b/runtime/base/variant_map_test.cc
index 93336e0..9dd29ba 100644
--- a/runtime/base/variant_map_test.cc
+++ b/runtime/base/variant_map_test.cc
@@ -23,27 +23,27 @@
namespace art {
namespace {
+template <typename TValue>
+struct FruitMapKey : VariantMapKey<TValue> {
+ FruitMapKey() {}
+};
+
+struct FruitMap : VariantMap<FruitMap, FruitMapKey> {
+ // This 'using' line is necessary to inherit the variadic constructor.
+ using VariantMap<FruitMap, FruitMapKey>::VariantMap;
+
+ // Make the next '4' usages of Key slightly shorter to type.
template <typename TValue>
- struct FruitMapKey : VariantMapKey<TValue> {
- FruitMapKey() {}
- };
+ using Key = FruitMapKey<TValue>;
- struct FruitMap : VariantMap<FruitMap, FruitMapKey> {
- // This 'using' line is necessary to inherit the variadic constructor.
- using VariantMap<FruitMap, FruitMapKey>::VariantMap;
+ static const Key<int> Apple;
+ static const Key<double> Orange;
+ static const Key<std::string> Label;
+};
- // Make the next '4' usages of Key slightly shorter to type.
- template <typename TValue>
- using Key = FruitMapKey<TValue>;
-
- static const Key<int> Apple;
- static const Key<double> Orange;
- static const Key<std::string> Label;
- };
-
- const FruitMap::Key<int> FruitMap::Apple;
- const FruitMap::Key<double> FruitMap::Orange;
- const FruitMap::Key<std::string> FruitMap::Label;
+const FruitMap::Key<int> FruitMap::Apple;
+const FruitMap::Key<double> FruitMap::Orange;
+const FruitMap::Key<std::string> FruitMap::Label;
} // namespace
TEST(VariantMaps, BasicReadWrite) {