OSDN Git Service

Fix google-explicit-constructor warnings in art.
authorChih-Hung Hsieh <chh@google.com>
Thu, 1 Sep 2016 22:08:13 +0000 (15:08 -0700)
committerChih-Hung Hsieh <chh@google.com>
Thu, 15 Sep 2016 16:09:35 +0000 (09:09 -0700)
* Add explicit keyword to conversion constructors,
  or NOLINT for implicit converters.
Bug: 28341362
Test: build with WITH_TIDY=1

Change-Id: I1e1ee2661812944904fedadeff97b620506db47d

19 files changed:
compiler/optimizing/instruction_simplifier.h
compiler/optimizing/locations.h
compiler/optimizing/nodes.h
compiler/utils/arm/assembler_arm.h
compiler/utils/intrusive_forward_list.h
compiler/utils/swap_space.h
runtime/base/allocator.h
runtime/base/arena_allocator.h
runtime/base/arena_containers.h
runtime/base/scoped_arena_containers.h
runtime/base/transform_array_ref.h
runtime/base/transform_iterator.h
runtime/experimental_flags.h
runtime/gc/collector/concurrent_copying.h
runtime/gc/collector/garbage_collector.h
runtime/mirror/object_reference.h
runtime/oat.h
runtime/oat_quick_method_header.h
runtime/thread_list.h

index 7905104..7fe1067 100644 (file)
@@ -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";
index 4384042..c97c4a6 100644 (file)
@@ -488,9 +488,9 @@ class LocationSummary : public ArenaObject<kArenaAllocLocationSummary> {
     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;
index 7c3ca5c..caecc57 100644 (file)
@@ -837,7 +837,7 @@ static constexpr uint32_t kInvalidBlockId = static_cast<uint32_t>(-1);
 
 class HBasicBlock : public ArenaObject<kArenaAllocBasicBlock> {
  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<kFlagUpperCanBeNull>(true);
index 3084e6e..aefbf26 100644 (file)
@@ -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) {
   }
index ec2c087..b5fc2f2 100644 (file)
@@ -59,7 +59,7 @@ class IntrusiveForwardListIterator : public std::iterator<std::forward_iterator_
   // Conversion from iterator to const_iterator.
   template <typename OtherT,
             typename = typename std::enable_if<std::is_same<T, const OtherT>::value>::type>
-  IntrusiveForwardListIterator(const IntrusiveForwardListIterator<OtherT, HookTraits>& src)
+  IntrusiveForwardListIterator(const IntrusiveForwardListIterator<OtherT, HookTraits>& src)  // NOLINT, implicit
       : hook_(src.hook_) { }
 
   // Iteration.
index bf06675..9600907 100644 (file)
@@ -114,7 +114,8 @@ class SwapAllocator<void> {
   explicit SwapAllocator(SwapSpace* swap_space) : swap_space_(swap_space) {}
 
   template <typename U>
-  SwapAllocator(const SwapAllocator<U>& other) : swap_space_(other.swap_space_) {}
+  SwapAllocator(const SwapAllocator<U>& 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 <typename U>
-  SwapAllocator(const SwapAllocator<U>& other) : swap_space_(other.swap_space_) {}
+  SwapAllocator(const SwapAllocator<U>& other)  // NOLINT, implicit
+      : swap_space_(other.swap_space_) {}
 
   SwapAllocator(const SwapAllocator& other) = default;
   SwapAllocator& operator=(const SwapAllocator& other) = default;
index e48eca9..8d1c982 100644 (file)
@@ -116,7 +116,8 @@ class TrackingAllocatorImpl : public std::allocator<T> {
 
   // Used internally by STL data structures.
   template <class U>
-  TrackingAllocatorImpl(const TrackingAllocatorImpl<U, kTag>& alloc ATTRIBUTE_UNUSED) noexcept {}
+  TrackingAllocatorImpl( // NOLINT, implicit
+      const TrackingAllocatorImpl<U, kTag>& alloc ATTRIBUTE_UNUSED) noexcept {}
 
   // Used internally by STL data structures.
   TrackingAllocatorImpl() noexcept {
index 3fad96b..31dbb36 100644 (file)
@@ -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_);
index 68cacd5..2c8aa28 100644 (file)
@@ -132,7 +132,7 @@ class ArenaAllocatorAdapter<void> : private ArenaAllocatorAdapterKind {
         arena_allocator_(arena_allocator) {
   }
   template <typename U>
-  ArenaAllocatorAdapter(const ArenaAllocatorAdapter<U>& other)
+  ArenaAllocatorAdapter(const ArenaAllocatorAdapter<U>& other)  // NOLINT, implicit
       : ArenaAllocatorAdapterKind(other),
         arena_allocator_(other.arena_allocator_) {
   }
@@ -168,7 +168,7 @@ class ArenaAllocatorAdapter : private ArenaAllocatorAdapterKind {
         arena_allocator_(arena_allocator) {
   }
   template <typename U>
-  ArenaAllocatorAdapter(const ArenaAllocatorAdapter<U>& other)
+  ArenaAllocatorAdapter(const ArenaAllocatorAdapter<U>& other)  // NOLINT, implicit
       : ArenaAllocatorAdapterKind(other),
         arena_allocator_(other.arena_allocator_) {
   }
index bd19d00..7964705 100644 (file)
@@ -87,7 +87,7 @@ class ScopedArenaAllocatorAdapter<void>
         arena_stack_(arena_allocator->arena_stack_) {
   }
   template <typename U>
-  ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter<U>& other)
+  ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter<U>& other)  // NOLINT, implicit
       : DebugStackReference(other),
         DebugStackIndirectTopRef(other),
         ArenaAllocatorAdapterKind(other),
@@ -130,7 +130,7 @@ class ScopedArenaAllocatorAdapter
         arena_stack_(arena_allocator->arena_stack_) {
   }
   template <typename U>
-  ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter<U>& other)
+  ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter<U>& other)  // NOLINT, implicit
       : DebugStackReference(other),
         DebugStackIndirectTopRef(other),
         ArenaAllocatorAdapterKind(other),
index a4e0bc2..b432f86 100644 (file)
@@ -72,7 +72,7 @@ class TransformArrayRef {
 
   template <typename OtherBT,
             typename = typename std::enable_if<std::is_same<BaseType, const OtherBT>::value>::type>
-  TransformArrayRef(const TransformArrayRef<OtherBT, Function>& other)
+  TransformArrayRef(const TransformArrayRef<OtherBT, Function>& other)  // NOLINT, implicit
       : TransformArrayRef(other.base(), other.GetFunction()) { }
 
   // Assignment operators.
index 9c8f822..f1a8a52 100644 (file)
@@ -62,7 +62,7 @@ class TransformIterator {
       : data_(base, fn) { }
 
   template <typename OtherBI>
-  TransformIterator(const TransformIterator<OtherBI, Function>& other)
+  TransformIterator(const TransformIterator<OtherBI, Function>& other)  // NOLINT, implicit
       : data_(other.base(), other.GetFunction()) {
   }
 
index 7faa2dc..54d2c35 100644 (file)
@@ -31,7 +31,8 @@ struct ExperimentalFlags {
   };
 
   constexpr ExperimentalFlags() : value_(0x0000) {}
-  constexpr ExperimentalFlags(decltype(kNone) t) : value_(static_cast<uint32_t>(t)) {}
+  constexpr ExperimentalFlags(decltype(kNone) t)  // NOLINT, implicit
+      : value_(static_cast<uint32_t>(t)) {}
 
   constexpr operator decltype(kNone)() const {
     return static_cast<decltype(kNone)>(value_);
index 1ef0aea..53473f0 100644 (file)
@@ -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
index 6afe876..4ffa254 100644 (file)
@@ -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;
index 583cfc3..f4a3580 100644 (file)
@@ -55,7 +55,7 @@ class MANAGED ObjectReference {
   }
 
  protected:
-  ObjectReference<kPoisonReferences, MirrorType>(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<kPoisonHeapReferences, Mirr
     return HeapReference<MirrorType>(mirror_ptr);
   }
  private:
-  HeapReference<MirrorType>(MirrorType* mirror_ptr) REQUIRES_SHARED(Locks::mutator_lock_)
+  explicit HeapReference(MirrorType* mirror_ptr) REQUIRES_SHARED(Locks::mutator_lock_)
       : ObjectReference<kPoisonHeapReferences, MirrorType>(mirror_ptr) {}
 };
 
@@ -104,7 +104,7 @@ class MANAGED CompressedReference : public mirror::ObjectReference<false, Mirror
   }
 
  private:
-  CompressedReference<MirrorType>(MirrorType* p) REQUIRES_SHARED(Locks::mutator_lock_)
+  explicit CompressedReference(MirrorType* p) REQUIRES_SHARED(Locks::mutator_lock_)
       : mirror::ObjectReference<false, MirrorType>(p) {}
 };
 
index 35d0c92..12a8298 100644 (file)
@@ -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();
 
index abddc6d..ee5002f 100644 (file)
@@ -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();
 
index 5880085..cef4ed1 100644 (file)
@@ -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_,