From: Chih-Hung Hsieh Date: Thu, 1 Sep 2016 22:08:13 +0000 (-0700) Subject: Fix google-explicit-constructor warnings in art. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=a5931185c97c7b17981a9fc5016834a0bdd9480b;p=android-x86%2Fart.git Fix google-explicit-constructor warnings in art. * Add explicit keyword to conversion constructors, or NOLINT for implicit converters. Bug: 28341362 Test: build with WITH_TIDY=1 Change-Id: I1e1ee2661812944904fedadeff97b620506db47d --- diff --git a/compiler/optimizing/instruction_simplifier.h b/compiler/optimizing/instruction_simplifier.h index 7905104ed..7fe1067aa 100644 --- a/compiler/optimizing/instruction_simplifier.h +++ b/compiler/optimizing/instruction_simplifier.h @@ -35,9 +35,9 @@ namespace art { */ class InstructionSimplifier : public HOptimization { public: - InstructionSimplifier(HGraph* graph, - OptimizingCompilerStats* stats = nullptr, - const char* name = kInstructionSimplifierPassName) + explicit InstructionSimplifier(HGraph* graph, + OptimizingCompilerStats* stats = nullptr, + const char* name = kInstructionSimplifierPassName) : HOptimization(graph, name, stats) {} static constexpr const char* kInstructionSimplifierPassName = "instruction_simplifier"; diff --git a/compiler/optimizing/locations.h b/compiler/optimizing/locations.h index 43840422c..c97c4a6c5 100644 --- a/compiler/optimizing/locations.h +++ b/compiler/optimizing/locations.h @@ -488,9 +488,9 @@ class LocationSummary : public ArenaObject { kCallOnMainOnly }; - LocationSummary(HInstruction* instruction, - CallKind call_kind = kNoCall, - bool intrinsified = false); + explicit LocationSummary(HInstruction* instruction, + CallKind call_kind = kNoCall, + bool intrinsified = false); void SetInAt(uint32_t at, Location location) { inputs_[at] = location; diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 7c3ca5cef..caecc578c 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -837,7 +837,7 @@ static constexpr uint32_t kInvalidBlockId = static_cast(-1); class HBasicBlock : public ArenaObject { public: - HBasicBlock(HGraph* graph, uint32_t dex_pc = kNoDexPc) + explicit HBasicBlock(HGraph* graph, uint32_t dex_pc = kNoDexPc) : graph_(graph), predecessors_(graph->GetArena()->Adapter(kArenaAllocPredecessors)), successors_(graph->GetArena()->Adapter(kArenaAllocSuccessors)), @@ -6282,7 +6282,7 @@ class HInstanceOf FINAL : public HExpression<2> { class HBoundType FINAL : public HExpression<1> { public: - HBoundType(HInstruction* input, uint32_t dex_pc = kNoDexPc) + explicit HBoundType(HInstruction* input, uint32_t dex_pc = kNoDexPc) : HExpression(Primitive::kPrimNot, SideEffects::None(), dex_pc), upper_bound_(ReferenceTypeInfo::CreateInvalid()) { SetPackedFlag(true); diff --git a/compiler/utils/arm/assembler_arm.h b/compiler/utils/arm/assembler_arm.h index 3084e6e2b..aefbf26db 100644 --- a/compiler/utils/arm/assembler_arm.h +++ b/compiler/utils/arm/assembler_arm.h @@ -246,7 +246,7 @@ class Address : public ValueObject { NegPostIndex = (0|0|0) << 21 // negative post-indexed with writeback }; - Address(Register rn, int32_t offset = 0, Mode am = Offset) : rn_(rn), rm_(R0), + explicit Address(Register rn, int32_t offset = 0, Mode am = Offset) : rn_(rn), rm_(R0), offset_(offset), am_(am), is_immed_offset_(true), shift_(LSL) { } diff --git a/compiler/utils/intrusive_forward_list.h b/compiler/utils/intrusive_forward_list.h index ec2c08722..b5fc2f245 100644 --- a/compiler/utils/intrusive_forward_list.h +++ b/compiler/utils/intrusive_forward_list.h @@ -59,7 +59,7 @@ class IntrusiveForwardListIterator : public std::iterator::value>::type> - IntrusiveForwardListIterator(const IntrusiveForwardListIterator& src) + IntrusiveForwardListIterator(const IntrusiveForwardListIterator& src) // NOLINT, implicit : hook_(src.hook_) { } // Iteration. diff --git a/compiler/utils/swap_space.h b/compiler/utils/swap_space.h index bf06675d7..960090727 100644 --- a/compiler/utils/swap_space.h +++ b/compiler/utils/swap_space.h @@ -114,7 +114,8 @@ class SwapAllocator { explicit SwapAllocator(SwapSpace* swap_space) : swap_space_(swap_space) {} template - SwapAllocator(const SwapAllocator& other) : swap_space_(other.swap_space_) {} + SwapAllocator(const SwapAllocator& other) // NOLINT, implicit + : swap_space_(other.swap_space_) {} SwapAllocator(const SwapAllocator& other) = default; SwapAllocator& operator=(const SwapAllocator& other) = default; @@ -149,7 +150,8 @@ class SwapAllocator { explicit SwapAllocator(SwapSpace* swap_space) : swap_space_(swap_space) {} template - SwapAllocator(const SwapAllocator& other) : swap_space_(other.swap_space_) {} + SwapAllocator(const SwapAllocator& other) // NOLINT, implicit + : swap_space_(other.swap_space_) {} SwapAllocator(const SwapAllocator& other) = default; SwapAllocator& operator=(const SwapAllocator& other) = default; diff --git a/runtime/base/allocator.h b/runtime/base/allocator.h index e48eca9a2..8d1c982f3 100644 --- a/runtime/base/allocator.h +++ b/runtime/base/allocator.h @@ -116,7 +116,8 @@ class TrackingAllocatorImpl : public std::allocator { // Used internally by STL data structures. template - TrackingAllocatorImpl(const TrackingAllocatorImpl& alloc ATTRIBUTE_UNUSED) noexcept {} + TrackingAllocatorImpl( // NOLINT, implicit + const TrackingAllocatorImpl& alloc ATTRIBUTE_UNUSED) noexcept {} // Used internally by STL data structures. TrackingAllocatorImpl() noexcept { diff --git a/runtime/base/arena_allocator.h b/runtime/base/arena_allocator.h index 3fad96b39..31dbb3682 100644 --- a/runtime/base/arena_allocator.h +++ b/runtime/base/arena_allocator.h @@ -258,9 +258,9 @@ class MemMapArena FINAL : public Arena { class ArenaPool { public: - ArenaPool(bool use_malloc = true, - bool low_4gb = false, - const char* name = "LinearAlloc"); + explicit ArenaPool(bool use_malloc = true, + bool low_4gb = false, + const char* name = "LinearAlloc"); ~ArenaPool(); Arena* AllocArena(size_t size) REQUIRES(!lock_); void FreeArenaChain(Arena* first) REQUIRES(!lock_); diff --git a/runtime/base/arena_containers.h b/runtime/base/arena_containers.h index 68cacd57e..2c8aa2880 100644 --- a/runtime/base/arena_containers.h +++ b/runtime/base/arena_containers.h @@ -132,7 +132,7 @@ class ArenaAllocatorAdapter : private ArenaAllocatorAdapterKind { arena_allocator_(arena_allocator) { } template - ArenaAllocatorAdapter(const ArenaAllocatorAdapter& other) + ArenaAllocatorAdapter(const ArenaAllocatorAdapter& other) // NOLINT, implicit : ArenaAllocatorAdapterKind(other), arena_allocator_(other.arena_allocator_) { } @@ -168,7 +168,7 @@ class ArenaAllocatorAdapter : private ArenaAllocatorAdapterKind { arena_allocator_(arena_allocator) { } template - ArenaAllocatorAdapter(const ArenaAllocatorAdapter& other) + ArenaAllocatorAdapter(const ArenaAllocatorAdapter& other) // NOLINT, implicit : ArenaAllocatorAdapterKind(other), arena_allocator_(other.arena_allocator_) { } diff --git a/runtime/base/scoped_arena_containers.h b/runtime/base/scoped_arena_containers.h index bd19d0054..796470599 100644 --- a/runtime/base/scoped_arena_containers.h +++ b/runtime/base/scoped_arena_containers.h @@ -87,7 +87,7 @@ class ScopedArenaAllocatorAdapter arena_stack_(arena_allocator->arena_stack_) { } template - ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter& other) + ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter& other) // NOLINT, implicit : DebugStackReference(other), DebugStackIndirectTopRef(other), ArenaAllocatorAdapterKind(other), @@ -130,7 +130,7 @@ class ScopedArenaAllocatorAdapter arena_stack_(arena_allocator->arena_stack_) { } template - ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter& other) + ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter& other) // NOLINT, implicit : DebugStackReference(other), DebugStackIndirectTopRef(other), ArenaAllocatorAdapterKind(other), diff --git a/runtime/base/transform_array_ref.h b/runtime/base/transform_array_ref.h index a4e0bc27e..b432f86d7 100644 --- a/runtime/base/transform_array_ref.h +++ b/runtime/base/transform_array_ref.h @@ -72,7 +72,7 @@ class TransformArrayRef { template ::value>::type> - TransformArrayRef(const TransformArrayRef& other) + TransformArrayRef(const TransformArrayRef& other) // NOLINT, implicit : TransformArrayRef(other.base(), other.GetFunction()) { } // Assignment operators. diff --git a/runtime/base/transform_iterator.h b/runtime/base/transform_iterator.h index 9c8f822b7..f1a8a52ce 100644 --- a/runtime/base/transform_iterator.h +++ b/runtime/base/transform_iterator.h @@ -62,7 +62,7 @@ class TransformIterator { : data_(base, fn) { } template - TransformIterator(const TransformIterator& other) + TransformIterator(const TransformIterator& other) // NOLINT, implicit : data_(other.base(), other.GetFunction()) { } diff --git a/runtime/experimental_flags.h b/runtime/experimental_flags.h index 7faa2dc7e..54d2c35b7 100644 --- a/runtime/experimental_flags.h +++ b/runtime/experimental_flags.h @@ -31,7 +31,8 @@ struct ExperimentalFlags { }; constexpr ExperimentalFlags() : value_(0x0000) {} - constexpr ExperimentalFlags(decltype(kNone) t) : value_(static_cast(t)) {} + constexpr ExperimentalFlags(decltype(kNone) t) // NOLINT, implicit + : value_(static_cast(t)) {} constexpr operator decltype(kNone)() const { return static_cast(value_); diff --git a/runtime/gc/collector/concurrent_copying.h b/runtime/gc/collector/concurrent_copying.h index 1ef0aeac2..53473f0c0 100644 --- a/runtime/gc/collector/concurrent_copying.h +++ b/runtime/gc/collector/concurrent_copying.h @@ -61,9 +61,9 @@ class ConcurrentCopying : public GarbageCollector { // pages. static constexpr bool kGrayDirtyImmuneObjects = true; - ConcurrentCopying(Heap* heap, - const std::string& name_prefix = "", - bool measure_read_barrier_slow_path = false); + explicit ConcurrentCopying(Heap* heap, + const std::string& name_prefix = "", + bool measure_read_barrier_slow_path = false); ~ConcurrentCopying(); virtual void RunPhases() OVERRIDE diff --git a/runtime/gc/collector/garbage_collector.h b/runtime/gc/collector/garbage_collector.h index 6afe87671..4ffa254bb 100644 --- a/runtime/gc/collector/garbage_collector.h +++ b/runtime/gc/collector/garbage_collector.h @@ -44,7 +44,7 @@ class Heap; namespace collector { struct ObjectBytePair { - ObjectBytePair(uint64_t num_objects = 0, int64_t num_bytes = 0) + explicit ObjectBytePair(uint64_t num_objects = 0, int64_t num_bytes = 0) : objects(num_objects), bytes(num_bytes) {} void Add(const ObjectBytePair& other) { objects += other.objects; diff --git a/runtime/mirror/object_reference.h b/runtime/mirror/object_reference.h index 583cfc3c7..f4a358018 100644 --- a/runtime/mirror/object_reference.h +++ b/runtime/mirror/object_reference.h @@ -55,7 +55,7 @@ class MANAGED ObjectReference { } protected: - ObjectReference(MirrorType* mirror_ptr) + explicit ObjectReference(MirrorType* mirror_ptr) REQUIRES_SHARED(Locks::mutator_lock_) : reference_(Compress(mirror_ptr)) { } @@ -87,7 +87,7 @@ class MANAGED HeapReference : public ObjectReference(mirror_ptr); } private: - HeapReference(MirrorType* mirror_ptr) REQUIRES_SHARED(Locks::mutator_lock_) + explicit HeapReference(MirrorType* mirror_ptr) REQUIRES_SHARED(Locks::mutator_lock_) : ObjectReference(mirror_ptr) {} }; @@ -104,7 +104,7 @@ class MANAGED CompressedReference : public mirror::ObjectReference(MirrorType* p) REQUIRES_SHARED(Locks::mutator_lock_) + explicit CompressedReference(MirrorType* p) REQUIRES_SHARED(Locks::mutator_lock_) : mirror::ObjectReference(p) {} }; diff --git a/runtime/oat.h b/runtime/oat.h index 35d0c92e8..12a829877 100644 --- a/runtime/oat.h +++ b/runtime/oat.h @@ -171,7 +171,7 @@ std::ostream& operator<<(std::ostream& os, const OatClassType& rhs); class PACKED(4) OatMethodOffsets { public: - OatMethodOffsets(uint32_t code_offset = 0); + explicit OatMethodOffsets(uint32_t code_offset = 0); ~OatMethodOffsets(); diff --git a/runtime/oat_quick_method_header.h b/runtime/oat_quick_method_header.h index abddc6d7a..ee5002f84 100644 --- a/runtime/oat_quick_method_header.h +++ b/runtime/oat_quick_method_header.h @@ -30,11 +30,11 @@ class ArtMethod; // OatQuickMethodHeader precedes the raw code chunk generated by the compiler. class PACKED(4) OatQuickMethodHeader { public: - OatQuickMethodHeader(uint32_t vmap_table_offset = 0U, - uint32_t frame_size_in_bytes = 0U, - uint32_t core_spill_mask = 0U, - uint32_t fp_spill_mask = 0U, - uint32_t code_size = 0U); + explicit OatQuickMethodHeader(uint32_t vmap_table_offset = 0U, + uint32_t frame_size_in_bytes = 0U, + uint32_t core_spill_mask = 0U, + uint32_t fp_spill_mask = 0U, + uint32_t code_size = 0U); ~OatQuickMethodHeader(); diff --git a/runtime/thread_list.h b/runtime/thread_list.h index 588008557..cef4ed168 100644 --- a/runtime/thread_list.h +++ b/runtime/thread_list.h @@ -209,7 +209,7 @@ class ThreadList { // Helper for suspending all threads and class ScopedSuspendAll : public ValueObject { public: - ScopedSuspendAll(const char* cause, bool long_suspend = false) + explicit ScopedSuspendAll(const char* cause, bool long_suspend = false) EXCLUSIVE_LOCK_FUNCTION(Locks::mutator_lock_) REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_,