diff options
author | dmichael <dmichael@chromium.org> | 2014-12-18 14:30:11 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-18 22:31:04 +0000 |
commit | 7d09007efbb714fbb8da0a46a0bbb9e08b18d6ed (patch) | |
tree | 47fb26032a981cb0306d52c083df09d1e09a1768 /base | |
parent | b640c0a432f8bd41875b4accacabad60b4caaa1a (diff) | |
download | chromium_src-7d09007efbb714fbb8da0a46a0bbb9e08b18d6ed.zip chromium_src-7d09007efbb714fbb8da0a46a0bbb9e08b18d6ed.tar.gz chromium_src-7d09007efbb714fbb8da0a46a0bbb9e08b18d6ed.tar.bz2 |
Fixes for Clang plugin checks in base/
The Clang Chromium "FindBadConstructs" plugin currently ignores templates
and PODs (see the bug). This fixes some of the latent issues found in base/.
BUG=441916
Review URL: https://codereview.chromium.org/806223004
Cr-Commit-Position: refs/heads/master@{#309088}
Diffstat (limited to 'base')
-rw-r--r-- | base/BUILD.gn | 1 | ||||
-rw-r--r-- | base/base.gypi | 1 | ||||
-rw-r--r-- | base/bind_internal.h | 62 | ||||
-rw-r--r-- | base/bind_internal.h.pump | 14 | ||||
-rw-r--r-- | base/callback_unittest.cc | 4 | ||||
-rw-r--r-- | base/json/json_value_converter.cc | 37 | ||||
-rw-r--r-- | base/json/json_value_converter.h | 35 | ||||
-rw-r--r-- | base/timer/timer.h | 2 |
8 files changed, 104 insertions, 52 deletions
diff --git a/base/BUILD.gn b/base/BUILD.gn index de464f9..5a922e4 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -261,6 +261,7 @@ component("base") { "json/json_reader.h", "json/json_string_value_serializer.cc", "json/json_string_value_serializer.h", + "json/json_value_converter.cc", "json/json_value_converter.h", "json/json_writer.cc", "json/json_writer.h", diff --git a/base/base.gypi b/base/base.gypi index 5ec4142..349308c 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -263,6 +263,7 @@ 'json/json_reader.h', 'json/json_string_value_serializer.cc', 'json/json_string_value_serializer.h', + 'json/json_value_converter.cc', 'json/json_value_converter.h', 'json/json_writer.cc', 'json/json_writer.h', diff --git a/base/bind_internal.h b/base/bind_internal.h index 1d8efec..b568c16 100644 --- a/base/bind_internal.h +++ b/base/bind_internal.h @@ -1850,9 +1850,11 @@ struct BindState<Runnable, RunType, void()> : public BindStateBase { : runnable_(runnable) { } - virtual ~BindState() { } - RunnableType runnable_; + + private: + ~BindState() override { } + }; template <typename Runnable, typename RunType, typename P1> @@ -1871,11 +1873,13 @@ struct BindState<Runnable, RunType, void(P1)> : public BindStateBase { MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_); } - virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value, - P1>::Release(p1_); } - RunnableType runnable_; P1 p1_; + + private: + ~BindState() override { MaybeRefcount<HasIsMethodTag<Runnable>::value, + P1>::Release(p1_); } + }; template <typename Runnable, typename RunType, typename P1, typename P2> @@ -1896,12 +1900,14 @@ struct BindState<Runnable, RunType, void(P1, P2)> : public BindStateBase { MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_); } - virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value, - P1>::Release(p1_); } - RunnableType runnable_; P1 p1_; P2 p2_; + + private: + ~BindState() override { MaybeRefcount<HasIsMethodTag<Runnable>::value, + P1>::Release(p1_); } + }; template <typename Runnable, typename RunType, typename P1, typename P2, @@ -1925,13 +1931,15 @@ struct BindState<Runnable, RunType, void(P1, P2, P3)> : public BindStateBase { MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_); } - virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value, - P1>::Release(p1_); } - RunnableType runnable_; P1 p1_; P2 p2_; P3 p3_; + + private: + ~BindState() override { MaybeRefcount<HasIsMethodTag<Runnable>::value, + P1>::Release(p1_); } + }; template <typename Runnable, typename RunType, typename P1, typename P2, @@ -1959,14 +1967,16 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_); } - virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value, - P1>::Release(p1_); } - RunnableType runnable_; P1 p1_; P2 p2_; P3 p3_; P4 p4_; + + private: + ~BindState() override { MaybeRefcount<HasIsMethodTag<Runnable>::value, + P1>::Release(p1_); } + }; template <typename Runnable, typename RunType, typename P1, typename P2, @@ -1996,15 +2006,17 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4, MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_); } - virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value, - P1>::Release(p1_); } - RunnableType runnable_; P1 p1_; P2 p2_; P3 p3_; P4 p4_; P5 p5_; + + private: + ~BindState() override { MaybeRefcount<HasIsMethodTag<Runnable>::value, + P1>::Release(p1_); } + }; template <typename Runnable, typename RunType, typename P1, typename P2, @@ -2036,9 +2048,6 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_); } - virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value, - P1>::Release(p1_); } - RunnableType runnable_; P1 p1_; P2 p2_; @@ -2046,6 +2055,11 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P4 p4_; P5 p5_; P6 p6_; + + private: + ~BindState() override { MaybeRefcount<HasIsMethodTag<Runnable>::value, + P1>::Release(p1_); } + }; template <typename Runnable, typename RunType, typename P1, typename P2, @@ -2079,9 +2093,6 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6, MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_); } - virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value, - P1>::Release(p1_); } - RunnableType runnable_; P1 p1_; P2 p2_; @@ -2090,6 +2101,11 @@ struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6, P5 p5_; P6 p6_; P7 p7_; + + private: + ~BindState() override { MaybeRefcount<HasIsMethodTag<Runnable>::value, + P1>::Release(p1_); } + }; } // namespace internal diff --git a/base/bind_internal.h.pump b/base/bind_internal.h.pump index 559c184..0ed3ca2 100644 --- a/base/bind_internal.h.pump +++ b/base/bind_internal.h.pump @@ -492,18 +492,20 @@ $if ARITY == 0 [[ ]] } - virtual ~BindState() { -$if ARITY > 0 [[ - MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::Release(p1_); -]] - } - RunnableType runnable_; $for ARG [[ P$(ARG) p$(ARG)_; ]] + + private: + ~BindState() override { +$if ARITY > 0 [[ + MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::Release(p1_); +]] + } + }; ]] $$ for ARITY diff --git a/base/callback_unittest.cc b/base/callback_unittest.cc index 6103b2e..e2a5d38 100644 --- a/base/callback_unittest.cc +++ b/base/callback_unittest.cc @@ -36,6 +36,8 @@ struct BindState<void(void), void(void), void(FakeInvoker)> : public BindStateBase { public: typedef FakeInvoker InvokerType; + private: + ~BindState() override {} }; template <> @@ -44,6 +46,8 @@ struct BindState<void(void), void(void), : public BindStateBase { public: typedef FakeInvoker InvokerType; + private: + ~BindState() override {} }; } // namespace internal diff --git a/base/json/json_value_converter.cc b/base/json/json_value_converter.cc new file mode 100644 index 0000000..6f772f3 --- /dev/null +++ b/base/json/json_value_converter.cc @@ -0,0 +1,37 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/json/json_value_converter.h" + +namespace base { +namespace internal { + +bool BasicValueConverter<int>::Convert( + const base::Value& value, int* field) const { + return value.GetAsInteger(field); +} + +bool BasicValueConverter<std::string>::Convert( + const base::Value& value, std::string* field) const { + return value.GetAsString(field); +} + +bool BasicValueConverter<string16>::Convert( + const base::Value& value, string16* field) const { + return value.GetAsString(field); +} + +bool BasicValueConverter<double>::Convert( + const base::Value& value, double* field) const { + return value.GetAsDouble(field); +} + +bool BasicValueConverter<bool>::Convert( + const base::Value& value, bool* field) const { + return value.GetAsBoolean(field); +} + +} // namespace internal +} // namespace base + diff --git a/base/json/json_value_converter.h b/base/json/json_value_converter.h index f049d9a..c4bfe61 100644 --- a/base/json/json_value_converter.h +++ b/base/json/json_value_converter.h @@ -8,6 +8,7 @@ #include <string> #include <vector> +#include "base/base_export.h" #include "base/basictypes.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" @@ -137,67 +138,57 @@ template <typename FieldType> class BasicValueConverter; template <> -class BasicValueConverter<int> : public ValueConverter<int> { +class BASE_EXPORT BasicValueConverter<int> : public ValueConverter<int> { public: BasicValueConverter() {} - virtual bool Convert(const base::Value& value, int* field) const override { - return value.GetAsInteger(field); - } + bool Convert(const base::Value& value, int* field) const override; private: DISALLOW_COPY_AND_ASSIGN(BasicValueConverter); }; template <> -class BasicValueConverter<std::string> : public ValueConverter<std::string> { +class BASE_EXPORT BasicValueConverter<std::string> + : public ValueConverter<std::string> { public: BasicValueConverter() {} - virtual bool Convert( - const base::Value& value, std::string* field) const override { - return value.GetAsString(field); - } + bool Convert(const base::Value& value, std::string* field) const override; private: DISALLOW_COPY_AND_ASSIGN(BasicValueConverter); }; template <> -class BasicValueConverter<string16> : public ValueConverter<string16> { +class BASE_EXPORT BasicValueConverter<string16> + : public ValueConverter<string16> { public: BasicValueConverter() {} - virtual bool Convert( - const base::Value& value, string16* field) const override { - return value.GetAsString(field); - } + bool Convert(const base::Value& value, string16* field) const override; private: DISALLOW_COPY_AND_ASSIGN(BasicValueConverter); }; template <> -class BasicValueConverter<double> : public ValueConverter<double> { +class BASE_EXPORT BasicValueConverter<double> : public ValueConverter<double> { public: BasicValueConverter() {} - virtual bool Convert(const base::Value& value, double* field) const override { - return value.GetAsDouble(field); - } + bool Convert(const base::Value& value, double* field) const override; private: DISALLOW_COPY_AND_ASSIGN(BasicValueConverter); }; template <> -class BasicValueConverter<bool> : public ValueConverter<bool> { +class BASE_EXPORT BasicValueConverter<bool> : public ValueConverter<bool> { public: BasicValueConverter() {} - virtual bool Convert(const base::Value& value, bool* field) const override { - return value.GetAsBoolean(field); - } + bool Convert(const base::Value& value, bool* field) const override; private: DISALLOW_COPY_AND_ASSIGN(BasicValueConverter); diff --git a/base/timer/timer.h b/base/timer/timer.h index 7e2c1d4..ea34a9f 100644 --- a/base/timer/timer.h +++ b/base/timer/timer.h @@ -259,7 +259,7 @@ class DelayTimer : protected Timer { base::Bind(method, base::Unretained(receiver)), false) {} - void Reset() { Timer::Reset(); } + void Reset() override { Timer::Reset(); } }; } // namespace base |