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
diff --git a/tools/aapt2/ResourceTable.cpp b/tools/aapt2/ResourceTable.cpp
index 4d418d9..460de0e 100644
--- a/tools/aapt2/ResourceTable.cpp
+++ b/tools/aapt2/ResourceTable.cpp
@@ -274,7 +274,7 @@
}
bool ResourceTable::addResource(const ResourceNameRef& name,
- const ResourceId resId,
+ const ResourceId& resId,
const ConfigDescription& config,
const StringPiece& product,
std::unique_ptr<Value> value,
@@ -325,7 +325,7 @@
}
bool ResourceTable::addResourceAllowMangled(const ResourceNameRef& name,
- const ResourceId id,
+ const ResourceId& id,
const ConfigDescription& config,
const StringPiece& product,
std::unique_ptr<Value> value,
@@ -335,12 +335,12 @@
}
bool ResourceTable::addResourceImpl(const ResourceNameRef& name,
- const ResourceId resId,
+ const ResourceId& resId,
const ConfigDescription& config,
const StringPiece& product,
std::unique_ptr<Value> value,
const char* validChars,
- std::function<int(Value*,Value*)> conflictResolver,
+ const std::function<int(Value*,Value*)>& conflictResolver,
IDiagnostics* diag) {
assert(value && "value can't be nullptr");
assert(diag && "diagnostics can't be nullptr");
@@ -426,18 +426,18 @@
return true;
}
-bool ResourceTable::setSymbolState(const ResourceNameRef& name, const ResourceId resId,
+bool ResourceTable::setSymbolState(const ResourceNameRef& name, const ResourceId& resId,
const Symbol& symbol, IDiagnostics* diag) {
return setSymbolStateImpl(name, resId, symbol, kValidNameChars, diag);
}
bool ResourceTable::setSymbolStateAllowMangled(const ResourceNameRef& name,
- const ResourceId resId,
+ const ResourceId& resId,
const Symbol& symbol, IDiagnostics* diag) {
return setSymbolStateImpl(name, resId, symbol, kValidNameMangledChars, diag);
}
-bool ResourceTable::setSymbolStateImpl(const ResourceNameRef& name, const ResourceId resId,
+bool ResourceTable::setSymbolStateImpl(const ResourceNameRef& name, const ResourceId& resId,
const Symbol& symbol, const char* validChars,
IDiagnostics* diag) {
assert(diag && "diagnostics can't be nullptr");