Fix clang-tidy warnings in aapt and aapt2.
* Add explicit keyword to conversion constructors.
* Add NOLINT(implicit) comments for implicit conversion constructors.
Bug: 28341362
* Use const reference type for read-only parameters.
Bug: 30407689
* Use const reference type to avoid unnecessary copy.
Bug: 30413862
Test: build with WITH_TIDY=1
Change-Id: Id6d21961f313a1ad92b15a37fdaa5be9e8ab48e1
Merged-In: Id6d21961f313a1ad92b15a37fdaa5be9e8ab48e1
diff --git a/tools/aapt2/ResourceValues.h b/tools/aapt2/ResourceValues.h
index ef6594e..2635e34 100644
--- a/tools/aapt2/ResourceValues.h
+++ b/tools/aapt2/ResourceValues.h
@@ -128,8 +128,8 @@
bool privateReference = false;
Reference();
- Reference(const ResourceNameRef& n, Type type = Type::kResource);
- Reference(const ResourceId& i, Type type = Type::kResource);
+ Reference(const ResourceNameRef& n, Type type = Type::kResource); // NOLINT(implicit)
+ explicit Reference(const ResourceId& i, Type type = Type::kResource);
bool flatten(android::Res_value& outValue) const override;
Reference* clone(StringPool* newPool) const override;
@@ -154,7 +154,7 @@
struct RawString : public BaseItem<RawString> {
StringPool::Ref value;
- RawString(const StringPool::Ref& ref);
+ explicit RawString(const StringPool::Ref& ref);
bool flatten(android::Res_value& outValue) const override;
RawString* clone(StringPool* newPool) const override;
@@ -164,7 +164,7 @@
struct String : public BaseItem<String> {
StringPool::Ref value;
- String(const StringPool::Ref& ref);
+ explicit String(const StringPool::Ref& ref);
bool flatten(android::Res_value& outValue) const override;
String* clone(StringPool* newPool) const override;
@@ -174,7 +174,7 @@
struct StyledString : public BaseItem<StyledString> {
StringPool::StyleRef value;
- StyledString(const StringPool::StyleRef& ref);
+ explicit StyledString(const StringPool::StyleRef& ref);
bool flatten(android::Res_value& outValue) const override;
StyledString* clone(StringPool* newPool) const override;
@@ -185,7 +185,7 @@
StringPool::Ref path;
FileReference() = default;
- FileReference(const StringPool::Ref& path);
+ explicit FileReference(const StringPool::Ref& path);
bool flatten(android::Res_value& outValue) const override;
FileReference* clone(StringPool* newPool) const override;
@@ -199,7 +199,7 @@
android::Res_value value;
BinaryPrimitive() = default;
- BinaryPrimitive(const android::Res_value& val);
+ explicit BinaryPrimitive(const android::Res_value& val);
bool flatten(android::Res_value& outValue) const override;
BinaryPrimitive* clone(StringPool* newPool) const override;
@@ -218,7 +218,7 @@
uint32_t maxInt;
std::vector<Symbol> symbols;
- Attribute(bool w, uint32_t t = 0u);
+ explicit Attribute(bool w, uint32_t t = 0u);
bool isWeak() const override;
virtual Attribute* clone(StringPool* newPool) const override;
@@ -388,7 +388,7 @@
struct ValueVisitorFunc : ValueVisitor {
TFunc func;
- ValueVisitorFunc(TFunc f) : func(f) {
+ explicit ValueVisitorFunc(TFunc f) : func(f) {
}
void visit(T& value, ValueVisitorArgs&) override {
@@ -403,7 +403,7 @@
struct ConstValueVisitorFunc : ConstValueVisitor {
TFunc func;
- ConstValueVisitorFunc(TFunc f) : func(f) {
+ explicit ConstValueVisitorFunc(TFunc f) : func(f) {
}
void visit(const T& value, ValueVisitorArgs&) override {