diff options
author | Chih-Hung Hsieh <chh@google.com> | 2016-08-10 14:15:30 -0700 |
---|---|---|
committer | Chih-Hung Hsieh <chh@google.com> | 2016-08-11 15:16:41 -0700 |
commit | 9b8528fee4eed35b8e887ded0851d08eb2b10db6 (patch) | |
tree | 36df1cee89b3689454e6b09a6bfa5eabfb3214b1 | |
parent | 7310353aeb771c109e5aea2c5415fa502eb13a7b (diff) |
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
36 files changed, 70 insertions, 70 deletions
diff --git a/tools/aapt/ApkBuilder.h b/tools/aapt/ApkBuilder.h index 0d7f06b1f323..5d3abc63519f 100644 --- a/tools/aapt/ApkBuilder.h +++ b/tools/aapt/ApkBuilder.h @@ -32,7 +32,7 @@ class AaptFile; class ApkBuilder : public android::RefBase { public: - ApkBuilder(const sp<WeakResourceFilter>& configFilter); + explicit ApkBuilder(const sp<WeakResourceFilter>& configFilter); /** * Tells the builder to generate a separate APK for resources that diff --git a/tools/aapt/CacheUpdater.h b/tools/aapt/CacheUpdater.h index 10a1bbc2f4aa..6fa96d67e6a3 100644 --- a/tools/aapt/CacheUpdater.h +++ b/tools/aapt/CacheUpdater.h @@ -51,7 +51,7 @@ private: class SystemCacheUpdater : public CacheUpdater { public: // Constructor to set bundle to pass to preProcessImage - SystemCacheUpdater (Bundle* b) + explicit SystemCacheUpdater (Bundle* b) : bundle(b) { }; // Make sure all the directories along this path exist diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp index cbad4b9b48a9..d80aaba8f64b 100644 --- a/tools/aapt/Command.cpp +++ b/tools/aapt/Command.cpp @@ -248,7 +248,7 @@ bail: } static void printResolvedResourceAttribute(const ResTable& resTable, const ResXMLTree& tree, - uint32_t attrRes, String8 attrLabel, String8* outError) + uint32_t attrRes, const String8& attrLabel, String8* outError) { Res_value value; AaptXml::getResolvedResourceAttribute(resTable, tree, attrRes, &value, outError); @@ -399,7 +399,7 @@ static void printUsesImpliedPermission(const String8& name, const String8& reaso ResTable::normalizeForOutput(reason.string()).string()); } -Vector<String8> getNfcAidCategories(AssetManager& assets, String8 xmlPath, bool offHost, +Vector<String8> getNfcAidCategories(AssetManager& assets, const String8& xmlPath, bool offHost, String8 *outError = NULL) { Asset* aidAsset = assets.openNonAsset(xmlPath, Asset::ACCESS_BUFFER); diff --git a/tools/aapt/ConfigDescription.h b/tools/aapt/ConfigDescription.h index 4f999a2ff0c6..09430f2532fa 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) { + ConfigDescription(const android::ResTable_config&o) { // NOLINT(implicit) *static_cast<android::ResTable_config*>(this) = o; size = sizeof(android::ResTable_config); } diff --git a/tools/aapt/CrunchCache.cpp b/tools/aapt/CrunchCache.cpp index 0d574cf127dd..7b8a576b88d3 100644 --- a/tools/aapt/CrunchCache.cpp +++ b/tools/aapt/CrunchCache.cpp @@ -94,7 +94,7 @@ void CrunchCache::loadFiles() delete dw; } -bool CrunchCache::needsUpdating(String8 relativePath) const +bool CrunchCache::needsUpdating(const String8& relativePath) const { // Retrieve modification dates for this file entry under the source and // cache directory trees. The vectors will return a modification date of 0 diff --git a/tools/aapt/CrunchCache.h b/tools/aapt/CrunchCache.h index be3da5c40b25..4d6a16922f25 100644 --- a/tools/aapt/CrunchCache.h +++ b/tools/aapt/CrunchCache.h @@ -81,7 +81,7 @@ private: * // Recrunch sourceFile out to destFile. * */ - bool needsUpdating(String8 relativePath) const; + bool needsUpdating(const String8& relativePath) const; // DATA MEMBERS ==================================================== diff --git a/tools/aapt/FileFinder.cpp b/tools/aapt/FileFinder.cpp index 18775c06863f..c9d0744a4463 100644 --- a/tools/aapt/FileFinder.cpp +++ b/tools/aapt/FileFinder.cpp @@ -77,7 +77,7 @@ bool SystemFileFinder::findFiles(String8 basePath, Vector<String8>& extensions, return true; } -void SystemFileFinder::checkAndAddFile(String8 path, const struct stat* stats, +void SystemFileFinder::checkAndAddFile(const String8& path, const struct stat* stats, Vector<String8>& extensions, KeyedVector<String8,time_t>& fileStore) { diff --git a/tools/aapt/FileFinder.h b/tools/aapt/FileFinder.h index 6974aee033a8..f405381ee275 100644 --- a/tools/aapt/FileFinder.h +++ b/tools/aapt/FileFinder.h @@ -72,7 +72,7 @@ private: * time as the value. * */ - static void checkAndAddFile(String8 path, const struct stat* stats, + static void checkAndAddFile(const String8& path, const struct stat* stats, Vector<String8>& extensions, KeyedVector<String8,time_t>& fileStore); diff --git a/tools/aapt/IndentPrinter.h b/tools/aapt/IndentPrinter.h index 6fc94bc927b8..bd0edcbed8ad 100644 --- a/tools/aapt/IndentPrinter.h +++ b/tools/aapt/IndentPrinter.h @@ -3,7 +3,7 @@ class IndentPrinter { public: - IndentPrinter(FILE* stream, int indentSize=2) + explicit IndentPrinter(FILE* stream, int indentSize=2) : mStream(stream) , mIndentSize(indentSize) , mIndent(0) diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp index b278831ddf4e..b4c4d05a7397 100644 --- a/tools/aapt/Resource.cpp +++ b/tools/aapt/Resource.cpp @@ -399,7 +399,7 @@ static void collect_files(const sp<AaptDir>& dir, const DefaultKeyedVector<String8, sp<AaptGroup> >& groups = dir->getFiles(); int N = groups.size(); for (int i=0; i<N; i++) { - String8 leafName = groups.keyAt(i); + const String8& leafName = groups.keyAt(i); const sp<AaptGroup>& group = groups.valueAt(i); const DefaultKeyedVector<AaptGroupEntry, sp<AaptFile> >& files @@ -422,7 +422,7 @@ static void collect_files(const sp<AaptDir>& dir, set->add(leafName, group); resources->add(resType, set); } else { - sp<ResourceTypeSet> set = resources->valueAt(index); + const sp<ResourceTypeSet>& set = resources->valueAt(index); index = set->indexOfKey(leafName); if (index < 0) { if (kIsDebug) { @@ -457,7 +457,7 @@ static void collect_files(const sp<AaptAssets>& ass, int N = dirs.size(); for (int i=0; i<N; i++) { - sp<AaptDir> d = dirs.itemAt(i); + const sp<AaptDir>& d = dirs.itemAt(i); if (kIsDebug) { printf("Collecting dir #%d %p: %s, leaf %s\n", i, d.get(), d->getPath().string(), d->getLeaf().string()); @@ -615,7 +615,7 @@ static bool applyFileOverlay(Bundle *bundle, // get the overlay resources of the requested type ssize_t index = overlayRes->indexOfKey(resTypeString); if (index >= 0) { - sp<ResourceTypeSet> overlaySet = overlayRes->valueAt(index); + const sp<ResourceTypeSet>& overlaySet = overlayRes->valueAt(index); // for each of the resources, check for a match in the previously built // non-overlay "baseset". @@ -765,7 +765,7 @@ bool addTagAttribute(const sp<XMLNode>& node, const char* ns8, return addTagAttribute(node, ns8, attr8, value, errorOnFailedInsert, false); } -static void fullyQualifyClassName(const String8& package, sp<XMLNode> node, +static void fullyQualifyClassName(const String8& package, const sp<XMLNode>& node, const String16& attrName) { XMLNode::attribute_entry* attr = node->editAttribute( String16("http://schemas.android.com/apk/res/android"), attrName); @@ -1350,7 +1350,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil ResourceDirIterator it(resources->valueAt(index), String8("values")); ssize_t res; while ((res=it.next()) == NO_ERROR) { - sp<AaptFile> file = it.getFile(); + const sp<AaptFile>& file = it.getFile(); res = compileResourceFile(bundle, assets, file, it.getParams(), (current!=assets), &table); if (res != NO_ERROR) { @@ -2688,7 +2688,7 @@ status_t writeResourceSymbols(Bundle* bundle, const sp<AaptAssets>& assets, String8 dest(bundle->getRClassDir()); if (bundle->getMakePackageDirs()) { - String8 pkg(package); + const String8& pkg(package); const char* last = pkg.string(); const char* s = last-1; do { diff --git a/tools/aapt/ResourceFilter.h b/tools/aapt/ResourceFilter.h index d6430c0409cc..40d5b752000c 100644 --- a/tools/aapt/ResourceFilter.h +++ b/tools/aapt/ResourceFilter.h @@ -78,7 +78,7 @@ private: class StrongResourceFilter : public ResourceFilter { public: StrongResourceFilter() {} - StrongResourceFilter(const std::set<ConfigDescription>& configs) + explicit StrongResourceFilter(const std::set<ConfigDescription>& configs) : mConfigs(configs) {} android::status_t parse(const android::String8& str); @@ -106,7 +106,7 @@ private: */ class InverseResourceFilter : public ResourceFilter { public: - InverseResourceFilter(const android::sp<ResourceFilter>& filter) + explicit InverseResourceFilter(const android::sp<ResourceFilter>& filter) : mFilter(filter) {} bool match(const android::ResTable_config& config) const { diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index 4d5bb312aaf1..76c59dd57068 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -4081,7 +4081,7 @@ status_t ResourceTable::Type::applyPublicEntryOrder() j = 0; for (i=0; i<N; i++) { - sp<ConfigList> e = origOrder.itemAt(i); + const sp<ConfigList>& e = origOrder.itemAt(i); // There will always be enough room for the remaining entries. while (mOrderedConfigs.itemAt(j) != NULL) { j++; @@ -4203,7 +4203,7 @@ status_t ResourceTable::Package::applyPublicTypeOrder() size_t j=0; for (i=0; i<N; i++) { - sp<Type> t = origOrder.itemAt(i); + const sp<Type>& t = origOrder.itemAt(i); // There will always be enough room for the remaining types. while (mOrderedTypes.itemAt(j) != NULL) { j++; @@ -4636,7 +4636,7 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle) { c->getEntries(); const size_t entryCount = entries.size(); for (size_t ei = 0; ei < entryCount; ei++) { - sp<Entry> e = entries.valueAt(ei); + const sp<Entry>& e = entries.valueAt(ei); if (e == NULL || e->getType() != Entry::TYPE_BAG) { continue; } diff --git a/tools/aapt/StringPool.h b/tools/aapt/StringPool.h index 4b0d920c3274..625b0bfb3832 100644 --- a/tools/aapt/StringPool.h +++ b/tools/aapt/StringPool.h @@ -41,7 +41,7 @@ class StringPool public: struct entry { entry() : offset(0) { } - entry(const String16& _value) : value(_value), offset(0), hasStyles(false) { } + explicit entry(const String16& _value) : value(_value), offset(0), hasStyles(false) { } entry(const entry& o) : value(o.value), offset(o.offset), hasStyles(o.hasStyles), indices(o.indices), configTypeName(o.configTypeName), configs(o.configs) { } diff --git a/tools/aapt/WorkQueue.h b/tools/aapt/WorkQueue.h index d38f05d034e9..ab5f9691c21d 100644 --- a/tools/aapt/WorkQueue.h +++ b/tools/aapt/WorkQueue.h @@ -47,7 +47,7 @@ public: }; /* Creates a work queue with the specified maximum number of work threads. */ - WorkQueue(size_t maxThreads, bool canCallJava = true); + explicit WorkQueue(size_t maxThreads, bool canCallJava = true); /* Destroys the work queue. * Cancels pending work and waits for all remaining threads to complete. diff --git a/tools/aapt/XMLNode.cpp b/tools/aapt/XMLNode.cpp index 5b215daeb494..15ec4afa52dd 100644 --- a/tools/aapt/XMLNode.cpp +++ b/tools/aapt/XMLNode.cpp @@ -67,7 +67,7 @@ static const String16 RESOURCES_PREFIX_AUTO_PACKAGE(RESOURCES_AUTO_PACKAGE_NAMES static const String16 RESOURCES_PRV_PREFIX(RESOURCES_ROOT_PRV_NAMESPACE); static const String16 RESOURCES_TOOLS_NAMESPACE("http://schemas.android.com/tools"); -String16 getNamespaceResourcePackage(String16 appPackage, String16 namespaceUri, bool* outIsPublic) +String16 getNamespaceResourcePackage(const String16& appPackage, const String16& namespaceUri, bool* outIsPublic) { //printf("%s starts with %s?\n", String8(namespaceUri).string(), // String8(RESOURCES_PREFIX).string()); @@ -98,7 +98,7 @@ String16 getNamespaceResourcePackage(String16 appPackage, String16 namespaceUri, status_t hasSubstitutionErrors(const char* fileName, ResXMLTree* inXml, - String16 str16) + const String16& str16) { const char16_t* str = str16.string(); const char16_t* p = str; diff --git a/tools/aapt/XMLNode.h b/tools/aapt/XMLNode.h index 749bf9f59bf7..ac920186fe63 100644 --- a/tools/aapt/XMLNode.h +++ b/tools/aapt/XMLNode.h @@ -178,7 +178,7 @@ private: XMLNode(const String8& filename, const String16& s1, const String16& s2, bool isNamespace); // Creating a CDATA node. - XMLNode(const String8& filename); + explicit XMLNode(const String8& filename); status_t collect_strings(StringPool* dest, Vector<uint32_t>* outResIds, bool stripComments, bool stripRawValues) const; diff --git a/tools/aapt/pseudolocalize.h b/tools/aapt/pseudolocalize.h index 1faecd14172d..9bb1fd8312b0 100644 --- a/tools/aapt/pseudolocalize.h +++ b/tools/aapt/pseudolocalize.h @@ -43,7 +43,7 @@ class PseudoMethodAccent : public PseudoMethodImpl { class Pseudolocalizer { public: - Pseudolocalizer(PseudolocalizationMethod m); + explicit Pseudolocalizer(PseudolocalizationMethod m); ~Pseudolocalizer() { if (mImpl) delete mImpl; } void setMethod(PseudolocalizationMethod m); String16 start() { return mImpl->start(); } diff --git a/tools/aapt2/ConfigDescription.h b/tools/aapt2/ConfigDescription.h index ef0d147d9d98..6858c624fc80 100644 --- a/tools/aapt2/ConfigDescription.h +++ b/tools/aapt2/ConfigDescription.h @@ -51,7 +51,7 @@ struct ConfigDescription : public android::ResTable_config { static void applyVersionForCompatibility(ConfigDescription* config); ConfigDescription(); - ConfigDescription(const android::ResTable_config& o); + ConfigDescription(const android::ResTable_config& o); // NOLINT(implicit) ConfigDescription(const ConfigDescription& o); ConfigDescription(ConfigDescription&& o); diff --git a/tools/aapt2/Resource.h b/tools/aapt2/Resource.h index 0ba034520563..09a04e0f2afb 100644 --- a/tools/aapt2/Resource.h +++ b/tools/aapt2/Resource.h @@ -100,7 +100,7 @@ struct ResourceNameRef { ResourceNameRef() = default; ResourceNameRef(const ResourceNameRef&) = default; ResourceNameRef(ResourceNameRef&&) = default; - ResourceNameRef(const ResourceName& rhs); + ResourceNameRef(const ResourceName& rhs); // NOLINT(implicit) ResourceNameRef(const StringPiece& p, ResourceType t, const StringPiece& e); ResourceNameRef& operator=(const ResourceNameRef& rhs) = default; ResourceNameRef& operator=(ResourceNameRef&& rhs) = default; @@ -126,7 +126,7 @@ struct ResourceId { ResourceId(); ResourceId(const ResourceId& rhs); - ResourceId(uint32_t resId); + ResourceId(uint32_t resId); // NOLINT(implicit) ResourceId(uint8_t p, uint8_t t, uint16_t e); bool isValid() const; diff --git a/tools/aapt2/ResourceTable.cpp b/tools/aapt2/ResourceTable.cpp index 4d418d9c2e93..460de0e800d3 100644 --- a/tools/aapt2/ResourceTable.cpp +++ b/tools/aapt2/ResourceTable.cpp @@ -274,7 +274,7 @@ bool ResourceTable::addResource(const ResourceNameRef& name, } 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, } 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::addResourceAllowMangled(const ResourceNameRef& name, } 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 @@ bool ResourceTable::addResourceImpl(const ResourceNameRef& name, 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"); diff --git a/tools/aapt2/ResourceTable.h b/tools/aapt2/ResourceTable.h index a5efe355a76c..6b52a4360b7a 100644 --- a/tools/aapt2/ResourceTable.h +++ b/tools/aapt2/ResourceTable.h @@ -103,7 +103,7 @@ public: */ std::vector<std::unique_ptr<ResourceConfigValue>> values; - ResourceEntry(const StringPiece& name) : name(name.toString()) { } + explicit ResourceEntry(const StringPiece& name) : name(name.toString()) { } ResourceConfigValue* findValue(const ConfigDescription& config); ResourceConfigValue* findValue(const ConfigDescription& config, const StringPiece& product); @@ -200,7 +200,7 @@ public: IDiagnostics* diag); bool addResource(const ResourceNameRef& name, - const ResourceId resId, + const ResourceId& resId, const ConfigDescription& config, const StringPiece& product, std::unique_ptr<Value> value, @@ -231,19 +231,19 @@ public: IDiagnostics* diag); bool addResourceAllowMangled(const ResourceNameRef& name, - const ResourceId id, + const ResourceId& id, const ConfigDescription& config, const StringPiece& product, std::unique_ptr<Value> value, IDiagnostics* diag); bool setSymbolState(const ResourceNameRef& name, - const ResourceId resId, + const ResourceId& resId, const Symbol& symbol, IDiagnostics* diag); bool setSymbolStateAllowMangled(const ResourceNameRef& name, - const ResourceId resId, + const ResourceId& resId, const Symbol& symbol, IDiagnostics* diag); @@ -294,16 +294,16 @@ private: IDiagnostics* diag); bool addResourceImpl(const ResourceNameRef& name, - 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); bool setSymbolStateImpl(const ResourceNameRef& name, - ResourceId resId, + const ResourceId& resId, const Symbol& symbol, const char* validChars, IDiagnostics* diag); diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp index 7dc88dedc96e..773616d6aa71 100644 --- a/tools/aapt2/ResourceUtils.cpp +++ b/tools/aapt2/ResourceUtils.cpp @@ -545,7 +545,7 @@ uint32_t androidTypeToAttributeTypeMask(uint16_t type) { std::unique_ptr<Item> parseItemForAttribute( const StringPiece& value, uint32_t typeMask, - std::function<void(const ResourceName&)> onCreateReference) { + const std::function<void(const ResourceName&)>& onCreateReference) { std::unique_ptr<BinaryPrimitive> nullOrEmpty = tryParseNullOrEmpty(value); if (nullOrEmpty) { return std::move(nullOrEmpty); @@ -604,7 +604,7 @@ std::unique_ptr<Item> parseItemForAttribute( */ std::unique_ptr<Item> parseItemForAttribute( const StringPiece& str, const Attribute* attr, - std::function<void(const ResourceName&)> onCreateReference) { + const std::function<void(const ResourceName&)>& onCreateReference) { const uint32_t typeMask = attr->typeMask; std::unique_ptr<Item> value = parseItemForAttribute(str, typeMask, onCreateReference); if (value) { diff --git a/tools/aapt2/ResourceUtils.h b/tools/aapt2/ResourceUtils.h index 31b8e89850e5..a57d89dd0233 100644 --- a/tools/aapt2/ResourceUtils.h +++ b/tools/aapt2/ResourceUtils.h @@ -163,11 +163,11 @@ std::unique_ptr<BinaryPrimitive> tryParseFlagSymbol(const Attribute* enumAttr, */ std::unique_ptr<Item> parseItemForAttribute( const StringPiece& value, const Attribute* attr, - std::function<void(const ResourceName&)> onCreateReference = {}); + const std::function<void(const ResourceName&)>& onCreateReference = {}); std::unique_ptr<Item> parseItemForAttribute( const StringPiece& value, uint32_t typeMask, - std::function<void(const ResourceName&)> onCreateReference = {}); + const std::function<void(const ResourceName&)>& onCreateReference = {}); uint32_t androidTypeToAttributeTypeMask(uint16_t type); diff --git a/tools/aapt2/ResourceValues.h b/tools/aapt2/ResourceValues.h index 8ae71ad82a60..e6af7166c08f 100644 --- a/tools/aapt2/ResourceValues.h +++ b/tools/aapt2/ResourceValues.h @@ -198,7 +198,7 @@ struct Id : public BaseItem<Id> { struct RawString : public BaseItem<RawString> { StringPool::Ref value; - RawString(const StringPool::Ref& ref); + explicit RawString(const StringPool::Ref& ref); bool equals(const Value* value) const override; bool flatten(android::Res_value* outValue) const override; @@ -209,7 +209,7 @@ struct RawString : public BaseItem<RawString> { struct String : public BaseItem<String> { StringPool::Ref value; - String(const StringPool::Ref& ref); + explicit String(const StringPool::Ref& ref); bool equals(const Value* value) const override; bool flatten(android::Res_value* outValue) const override; @@ -220,7 +220,7 @@ struct String : public BaseItem<String> { struct StyledString : public BaseItem<StyledString> { StringPool::StyleRef value; - StyledString(const StringPool::StyleRef& ref); + explicit StyledString(const StringPool::StyleRef& ref); bool equals(const Value* value) const override; bool flatten(android::Res_value* outValue) const override; @@ -237,7 +237,7 @@ struct FileReference : public BaseItem<FileReference> { io::IFile* file = nullptr; FileReference() = default; - FileReference(const StringPool::Ref& path); + explicit FileReference(const StringPool::Ref& path); bool equals(const Value* value) const override; bool flatten(android::Res_value* outValue) const override; @@ -252,7 +252,7 @@ struct BinaryPrimitive : public BaseItem<BinaryPrimitive> { android::Res_value value; BinaryPrimitive() = default; - BinaryPrimitive(const android::Res_value& val); + explicit BinaryPrimitive(const android::Res_value& val); BinaryPrimitive(uint8_t dataType, uint32_t data); bool equals(const Value* value) const override; @@ -272,7 +272,7 @@ struct Attribute : public BaseValue<Attribute> { int32_t maxInt; std::vector<Symbol> symbols; - Attribute(bool w, uint32_t t = 0u); + explicit Attribute(bool w, uint32_t t = 0u); bool equals(const Value* value) const override; Attribute* clone(StringPool* newPool) const override; diff --git a/tools/aapt2/SdkConstants.cpp b/tools/aapt2/SdkConstants.cpp index 91e755de2514..ccf0383bd374 100644 --- a/tools/aapt2/SdkConstants.cpp +++ b/tools/aapt2/SdkConstants.cpp @@ -52,7 +52,7 @@ static bool lessEntryId(const std::pair<uint16_t, size_t>& p, uint16_t entryId) return p.first < entryId; } -size_t findAttributeSdkLevel(ResourceId id) { +size_t findAttributeSdkLevel(const ResourceId& id) { if (id.packageId() != 0x01 && id.typeId() != 0x01) { return 0; } diff --git a/tools/aapt2/SdkConstants.h b/tools/aapt2/SdkConstants.h index f28679fde0de..c9dbdca29513 100644 --- a/tools/aapt2/SdkConstants.h +++ b/tools/aapt2/SdkConstants.h @@ -47,7 +47,7 @@ enum { SDK_MARSHMALLOW = 23, }; -size_t findAttributeSdkLevel(ResourceId id); +size_t findAttributeSdkLevel(const ResourceId& id); size_t findAttributeSdkLevel(const ResourceName& name); std::pair<StringPiece, int> getDevelopmentSdkCodeNameAndVersion(); diff --git a/tools/aapt2/StringPool.h b/tools/aapt2/StringPool.h index 72ae9d184a78..13545bef53ab 100644 --- a/tools/aapt2/StringPool.h +++ b/tools/aapt2/StringPool.h @@ -65,7 +65,7 @@ public: private: friend class StringPool; - Ref(Entry* entry); + explicit Ref(Entry* entry); Entry* mEntry; }; @@ -88,7 +88,7 @@ public: private: friend class StringPool; - StyleRef(StyleEntry* entry); + explicit StyleRef(StyleEntry* entry); StyleEntry* mEntry; }; diff --git a/tools/aapt2/compile/IdAssigner.cpp b/tools/aapt2/compile/IdAssigner.cpp index 501ae9d08c08..4a3f1e10b6db 100644 --- a/tools/aapt2/compile/IdAssigner.cpp +++ b/tools/aapt2/compile/IdAssigner.cpp @@ -28,7 +28,7 @@ namespace aapt { * Assigns the intended ID to the ResourceTablePackage, ResourceTableType, and ResourceEntry, * as long as there is no existing ID or the ID is the same. */ -static bool assignId(IDiagnostics* diag, const ResourceId id, const ResourceName& name, +static bool assignId(IDiagnostics* diag, const ResourceId& id, const ResourceName& name, ResourceTablePackage* pkg, ResourceTableType* type, ResourceEntry* entry) { if (pkg->id.value() == id.packageId()) { if (!type->id || type->id.value() == id.typeId()) { diff --git a/tools/aapt2/flatten/TableFlattener_test.cpp b/tools/aapt2/flatten/TableFlattener_test.cpp index 0b92ba5b229d..b25bfa73dd39 100644 --- a/tools/aapt2/flatten/TableFlattener_test.cpp +++ b/tools/aapt2/flatten/TableFlattener_test.cpp @@ -64,7 +64,7 @@ public: ::testing::AssertionResult exists(ResTable* table, const StringPiece& expectedName, - const ResourceId expectedId, + const ResourceId& expectedId, const ConfigDescription& expectedConfig, const uint8_t expectedDataType, const uint32_t expectedData, const uint32_t expectedSpecFlags) { diff --git a/tools/aapt2/flatten/XmlFlattener_test.cpp b/tools/aapt2/flatten/XmlFlattener_test.cpp index d26f2e4ab7ea..4d1e178c4436 100644 --- a/tools/aapt2/flatten/XmlFlattener_test.cpp +++ b/tools/aapt2/flatten/XmlFlattener_test.cpp @@ -43,7 +43,7 @@ public: } ::testing::AssertionResult flatten(xml::XmlResource* doc, android::ResXMLTree* outTree, - XmlFlattenerOptions options = {}) { + const XmlFlattenerOptions& options = {}) { using namespace android; // For NO_ERROR on windows because it is a macro. BigBuffer buffer(1024); diff --git a/tools/aapt2/link/Link.cpp b/tools/aapt2/link/Link.cpp index acb0f38995cc..ff777a3b60eb 100644 --- a/tools/aapt2/link/Link.cpp +++ b/tools/aapt2/link/Link.cpp @@ -528,7 +528,7 @@ bool ResourceFileFlattener::flatten(ResourceTable* table, IArchiveWriter* archiv static bool writeStableIdMapToPath(IDiagnostics* diag, const std::unordered_map<ResourceName, ResourceId>& idMap, - const std::string idMapPath) { + const std::string& idMapPath) { std::ofstream fout(idMapPath, std::ofstream::binary); if (!fout) { diag->error(DiagMessage(idMapPath) << strerror(errno)); @@ -823,7 +823,7 @@ public: } bool writeJavaFile(ResourceTable* table, const StringPiece& packageNameToGenerate, - const StringPiece& outPackage, JavaClassGeneratorOptions javaOptions) { + const StringPiece& outPackage, const JavaClassGeneratorOptions& javaOptions) { if (!mOptions.generateJavaClassPath) { return true; } diff --git a/tools/aapt2/link/TableMerger.cpp b/tools/aapt2/link/TableMerger.cpp index 2cd2639ec228..6ec88cbe3b0f 100644 --- a/tools/aapt2/link/TableMerger.cpp +++ b/tools/aapt2/link/TableMerger.cpp @@ -135,7 +135,7 @@ bool TableMerger::doMerge(const Source& src, const bool manglePackage, const bool overlay, const bool allowNewResources, - FileMergeCallback callback) { + const FileMergeCallback& callback) { bool error = false; for (auto& srcType : srcPackage->types) { diff --git a/tools/aapt2/link/TableMerger.h b/tools/aapt2/link/TableMerger.h index 6997f936add1..3473a27f6142 100644 --- a/tools/aapt2/link/TableMerger.h +++ b/tools/aapt2/link/TableMerger.h @@ -115,7 +115,7 @@ private: const bool manglePackage, const bool overlay, const bool allowNewResources, - FileMergeCallback callback); + const FileMergeCallback& callback); std::unique_ptr<FileReference> cloneAndMangleFile(const std::string& package, const FileReference& value); diff --git a/tools/aapt2/process/SymbolTable.cpp b/tools/aapt2/process/SymbolTable.cpp index 6c506dfe1749..0c927182ecda 100644 --- a/tools/aapt2/process/SymbolTable.cpp +++ b/tools/aapt2/process/SymbolTable.cpp @@ -63,7 +63,7 @@ const SymbolTable::Symbol* SymbolTable::findByName(const ResourceName& name) { return nullptr; } -const SymbolTable::Symbol* SymbolTable::findById(ResourceId id) { +const SymbolTable::Symbol* SymbolTable::findById(const ResourceId& id) { if (const std::shared_ptr<Symbol>& s = mIdCache.get(id)) { return s.get(); } diff --git a/tools/aapt2/process/SymbolTable.h b/tools/aapt2/process/SymbolTable.h index 43f4dd7fb869..bd01b64281d5 100644 --- a/tools/aapt2/process/SymbolTable.h +++ b/tools/aapt2/process/SymbolTable.h @@ -86,7 +86,7 @@ public: * are typically stored in a cache which may evict entries. */ const Symbol* findByName(const ResourceName& name); - const Symbol* findById(ResourceId id); + const Symbol* findById(const ResourceId& id); /** * Let's the ISymbolSource decide whether looking up by name or ID is faster, if both diff --git a/tools/aapt2/proto/TableProtoDeserializer.cpp b/tools/aapt2/proto/TableProtoDeserializer.cpp index 98ff87f7af30..ca25c6a83dd9 100644 --- a/tools/aapt2/proto/TableProtoDeserializer.cpp +++ b/tools/aapt2/proto/TableProtoDeserializer.cpp @@ -228,7 +228,7 @@ private: } } else if (pbValue.has_compound_value()) { - const pb::CompoundValue pbCompoundValue = pbValue.compound_value(); + const pb::CompoundValue& pbCompoundValue = pbValue.compound_value(); if (pbCompoundValue.has_attr()) { const pb::Attribute& pbAttr = pbCompoundValue.attr(); std::unique_ptr<Attribute> attr = util::make_unique<Attribute>(isWeak); |