summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chih-Hung Hsieh <chh@google.com> 2018-12-20 13:37:44 -0800
committer Chih-hung Hsieh <chh@google.com> 2019-01-04 17:38:13 +0000
commit1fc78e1814d6e1ad8d49e905a569d2589bbb2b8f (patch)
treeaed2dad2df847dd375759f3ab6378466a9abe482
parentbd7379858523c4e06175ee6cd92b46750d05b1dd (diff)
Fix/suppress aapt/aapt2 google-explicit-constructor warnings
* Add explicit to conversion constructors/operators * Use NOLINT or NOLINTNEXTLINE to suppress warnings on intended converters Bug: 28341362 Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,google-explicit-constructor Change-Id: Ie02101ea7c422e8add535c111a30a2f21ead0ace
-rw-r--r--tools/aapt/ConfigDescription.h2
-rw-r--r--tools/aapt2/Debug.cpp2
-rw-r--r--tools/aapt2/Resource.h4
-rw-r--r--tools/aapt2/cmd/Compile.cpp2
-rw-r--r--tools/aapt2/cmd/Link.cpp4
-rw-r--r--tools/aapt2/java/ProguardRules.h2
-rw-r--r--tools/aapt2/link/XmlCompatVersioner.h4
-rw-r--r--tools/aapt2/process/SymbolTable.h2
-rw-r--r--tools/aapt2/test/Common.h4
-rw-r--r--tools/aapt2/util/Maybe.h8
10 files changed, 19 insertions, 15 deletions
diff --git a/tools/aapt/ConfigDescription.h b/tools/aapt/ConfigDescription.h
index 09430f2532fa..b4ea624524b3 100644
--- a/tools/aapt/ConfigDescription.h
+++ b/tools/aapt/ConfigDescription.h
@@ -29,7 +29,7 @@ struct ConfigDescription : public android::ResTable_config {
size = sizeof(android::ResTable_config);
}
- ConfigDescription(const android::ResTable_config&o) { // NOLINT(implicit)
+ ConfigDescription(const android::ResTable_config&o) { // NOLINT(google-explicit-constructor)
*static_cast<android::ResTable_config*>(this) = o;
size = sizeof(android::ResTable_config);
}
diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp
index f064cb14248f..e0d7abe4cf43 100644
--- a/tools/aapt2/Debug.cpp
+++ b/tools/aapt2/Debug.cpp
@@ -414,7 +414,7 @@ class XmlPrinter : public xml::ConstVisitor {
public:
using xml::ConstVisitor::Visit;
- XmlPrinter(Printer* printer) : printer_(printer) {
+ explicit XmlPrinter(Printer* printer) : printer_(printer) {
}
void Visit(const xml::Element* el) override {
diff --git a/tools/aapt2/Resource.h b/tools/aapt2/Resource.h
index 1c1aeddf158a..a8ba202d08f7 100644
--- a/tools/aapt2/Resource.h
+++ b/tools/aapt2/Resource.h
@@ -108,7 +108,7 @@ struct ResourceNameRef {
ResourceNameRef() = default;
ResourceNameRef(const ResourceNameRef&) = default;
ResourceNameRef(ResourceNameRef&&) = default;
- ResourceNameRef(const ResourceName& rhs); // NOLINT(implicit)
+ ResourceNameRef(const ResourceName& rhs); // NOLINT(google-explicit-constructor)
ResourceNameRef(const android::StringPiece& p, ResourceType t, const android::StringPiece& e);
ResourceNameRef& operator=(const ResourceNameRef& rhs) = default;
ResourceNameRef& operator=(ResourceNameRef&& rhs) = default;
@@ -139,7 +139,7 @@ struct ResourceId {
ResourceId();
ResourceId(const ResourceId& rhs);
- ResourceId(uint32_t res_id); // NOLINT(implicit)
+ ResourceId(uint32_t res_id); // NOLINT(google-explicit-constructor)
ResourceId(uint8_t p, uint8_t t, uint16_t e);
bool is_valid() const;
diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp
index 0b43c5d4a808..7144985e80dc 100644
--- a/tools/aapt2/cmd/Compile.cpp
+++ b/tools/aapt2/cmd/Compile.cpp
@@ -645,7 +645,7 @@ static bool CompileFile(IAaptContext* context, const CompileOptions& options,
class CompileContext : public IAaptContext {
public:
- CompileContext(IDiagnostics* diagnostics) : diagnostics_(diagnostics) {
+ explicit CompileContext(IDiagnostics* diagnostics) : diagnostics_(diagnostics) {
}
PackageType GetPackageType() override {
diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp
index 60cab5db1b1f..623ba120903d 100644
--- a/tools/aapt2/cmd/Link.cpp
+++ b/tools/aapt2/cmd/Link.cpp
@@ -141,7 +141,7 @@ struct LinkOptions {
class LinkContext : public IAaptContext {
public:
- LinkContext(IDiagnostics* diagnostics)
+ explicit LinkContext(IDiagnostics* diagnostics)
: diagnostics_(diagnostics), name_mangler_({}), symbols_(&name_mangler_) {
}
@@ -226,7 +226,7 @@ class LinkContext : public IAaptContext {
// See b/37498913.
class FeatureSplitSymbolTableDelegate : public DefaultSymbolTableDelegate {
public:
- FeatureSplitSymbolTableDelegate(IAaptContext* context) : context_(context) {
+ explicit FeatureSplitSymbolTableDelegate(IAaptContext* context) : context_(context) {
}
virtual ~FeatureSplitSymbolTableDelegate() = default;
diff --git a/tools/aapt2/java/ProguardRules.h b/tools/aapt2/java/ProguardRules.h
index 46827ee7cf93..c53f3076d85e 100644
--- a/tools/aapt2/java/ProguardRules.h
+++ b/tools/aapt2/java/ProguardRules.h
@@ -44,7 +44,7 @@ class KeepSet {
public:
KeepSet() = default;
- KeepSet(bool conditional_keep_rules) : conditional_keep_rules_(conditional_keep_rules) {
+ explicit KeepSet(bool conditional_keep_rules) : conditional_keep_rules_(conditional_keep_rules) {
}
inline void AddManifestClass(const UsageLocation& file, const std::string& class_name) {
diff --git a/tools/aapt2/link/XmlCompatVersioner.h b/tools/aapt2/link/XmlCompatVersioner.h
index 099e23c9e479..998061806279 100644
--- a/tools/aapt2/link/XmlCompatVersioner.h
+++ b/tools/aapt2/link/XmlCompatVersioner.h
@@ -55,7 +55,7 @@ class XmlCompatVersioner {
public:
using Rules = std::unordered_map<ResourceId, std::unique_ptr<IDegradeRule>>;
- XmlCompatVersioner(const Rules* rules);
+ explicit XmlCompatVersioner(const Rules* rules);
std::vector<std::unique_ptr<xml::XmlResource>> Process(IAaptContext* context,
xml::XmlResource* doc,
@@ -83,7 +83,7 @@ struct ReplacementAttr {
class DegradeToManyRule : public IDegradeRule {
public:
- DegradeToManyRule(std::vector<ReplacementAttr> attrs);
+ explicit DegradeToManyRule(std::vector<ReplacementAttr> attrs);
virtual ~DegradeToManyRule() = default;
std::vector<DegradeResult> Degrade(const xml::Element& src_el, const xml::Attribute& src_attr,
diff --git a/tools/aapt2/process/SymbolTable.h b/tools/aapt2/process/SymbolTable.h
index 51a2e373596a..2d8bd02a3799 100644
--- a/tools/aapt2/process/SymbolTable.h
+++ b/tools/aapt2/process/SymbolTable.h
@@ -71,7 +71,7 @@ class SymbolTable {
bool is_dynamic = false;
};
- SymbolTable(NameMangler* mangler);
+ explicit SymbolTable(NameMangler* mangler);
// Overrides the default ISymbolTableDelegate, which allows a custom defined strategy for
// looking up resources from a set of sources.
diff --git a/tools/aapt2/test/Common.h b/tools/aapt2/test/Common.h
index 50b41f1cb1e8..777ca5c72619 100644
--- a/tools/aapt2/test/Common.h
+++ b/tools/aapt2/test/Common.h
@@ -173,10 +173,12 @@ class ValueEqImpl : public ::testing::MatcherInterface<T> {
template <typename TValue>
class ValueEqMatcher {
public:
+ // NOLINTNEXTLINE(google-explicit-constructor)
ValueEqMatcher(TValue expected) : expected_(std::move(expected)) {
}
template <typename T>
+ // NOLINTNEXTLINE(google-explicit-constructor)
operator ::testing::Matcher<T>() const {
return ::testing::Matcher<T>(new ValueEqImpl<T>(&expected_));
}
@@ -188,10 +190,12 @@ class ValueEqMatcher {
template <typename TValue>
class ValueEqPointerMatcher {
public:
+ // NOLINTNEXTLINE(google-explicit-constructor)
ValueEqPointerMatcher(const TValue* expected) : expected_(expected) {
}
template <typename T>
+ // NOLINTNEXTLINE(google-explicit-constructor)
operator ::testing::Matcher<T>() const {
return ::testing::Matcher<T>(new ValueEqImpl<T>(expected_));
}
diff --git a/tools/aapt2/util/Maybe.h b/tools/aapt2/util/Maybe.h
index 031276c8b885..047e1a581330 100644
--- a/tools/aapt2/util/Maybe.h
+++ b/tools/aapt2/util/Maybe.h
@@ -44,12 +44,12 @@ class Maybe {
Maybe(const Maybe& rhs);
template <typename U>
- Maybe(const Maybe<U>& rhs); // NOLINT(implicit)
+ Maybe(const Maybe<U>& rhs); // NOLINT(google-explicit-constructor)
Maybe(Maybe&& rhs) noexcept;
template <typename U>
- Maybe(Maybe<U>&& rhs); // NOLINT(implicit)
+ Maybe(Maybe<U>&& rhs); // NOLINT(google-explicit-constructor)
Maybe& operator=(const Maybe& rhs);
@@ -64,12 +64,12 @@ class Maybe {
/**
* Construct a Maybe holding a value.
*/
- Maybe(const T& value); // NOLINT(implicit)
+ Maybe(const T& value); // NOLINT(google-explicit-constructor)
/**
* Construct a Maybe holding a value.
*/
- Maybe(T&& value); // NOLINT(implicit)
+ Maybe(T&& value); // NOLINT(google-explicit-constructor)
/**
* True if this holds a value, false if