summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chih-hung Hsieh <chh@google.com> 2016-08-12 18:05:32 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-08-12 18:05:32 +0000
commit17bd236b4b6b78c32a187649aa4abcf94e5951c3 (patch)
tree3776aabd2d84938c13edf1644cbdb7044d5bbd65
parent76ce8e52422bc6121fb974ef6aab040bb5d9da51 (diff)
parent8bd37ba458633ee7b2aeec0a7593817000aa84b2 (diff)
Merge "Fix clang-tidy warnings in aapt and aapt2."
-rw-r--r--tools/aapt/ApkBuilder.h2
-rw-r--r--tools/aapt/CacheUpdater.h2
-rw-r--r--tools/aapt/Command.cpp4
-rw-r--r--tools/aapt/ConfigDescription.h2
-rw-r--r--tools/aapt/CrunchCache.cpp2
-rw-r--r--tools/aapt/CrunchCache.h2
-rw-r--r--tools/aapt/FileFinder.cpp2
-rw-r--r--tools/aapt/FileFinder.h2
-rw-r--r--tools/aapt/IndentPrinter.h2
-rw-r--r--tools/aapt/Resource.cpp14
-rw-r--r--tools/aapt/ResourceFilter.h4
-rw-r--r--tools/aapt/ResourceTable.cpp6
-rw-r--r--tools/aapt/StringPool.h2
-rw-r--r--tools/aapt/WorkQueue.h2
-rw-r--r--tools/aapt/XMLNode.cpp4
-rw-r--r--tools/aapt/XMLNode.h2
-rw-r--r--tools/aapt/pseudolocalize.h2
-rw-r--r--tools/aapt2/BigBuffer.h2
-rw-r--r--tools/aapt2/BindingXmlPullParser.h2
-rw-r--r--tools/aapt2/ConfigDescription.h2
-rw-r--r--tools/aapt2/Flag.cpp6
-rw-r--r--tools/aapt2/Flag.h6
-rw-r--r--tools/aapt2/JavaClassGenerator_test.cpp2
-rw-r--r--tools/aapt2/Logger.h2
-rw-r--r--tools/aapt2/ManifestMerger.h2
-rw-r--r--tools/aapt2/ManifestParser.cpp4
-rw-r--r--tools/aapt2/ManifestParser.h4
-rw-r--r--tools/aapt2/ManifestValidator.h2
-rw-r--r--tools/aapt2/Maybe.h8
-rw-r--r--tools/aapt2/Resource.h4
-rw-r--r--tools/aapt2/ResourceParser.cpp4
-rw-r--r--tools/aapt2/ResourceParser.h4
-rw-r--r--tools/aapt2/ResourceTable.cpp10
-rw-r--r--tools/aapt2/ResourceTable.h18
-rw-r--r--tools/aapt2/ResourceValues.h20
-rw-r--r--tools/aapt2/ScopedXmlPullParser.h2
-rw-r--r--tools/aapt2/SdkConstants.cpp2
-rw-r--r--tools/aapt2/SdkConstants.h2
-rw-r--r--tools/aapt2/SourceXmlPullParser.h2
-rw-r--r--tools/aapt2/StringPiece.h4
-rw-r--r--tools/aapt2/StringPool.h4
-rw-r--r--tools/aapt2/TableFlattener.h2
-rw-r--r--tools/aapt2/Util.h2
-rw-r--r--tools/aapt2/XliffXmlPullParser.h2
-rw-r--r--tools/aapt2/XmlDom.h4
45 files changed, 92 insertions, 92 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 ba4aac6f32a8..8eeb84bbdd36 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 d05ae3cec028..b6f9aaf5d4f0 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -394,7 +394,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
@@ -417,7 +417,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) {
@@ -452,7 +452,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());
@@ -610,7 +610,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".
@@ -760,7 +760,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);
@@ -1339,7 +1339,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) {
@@ -2674,7 +2674,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 d5a09d817b1e..66018724ee2e 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -4023,7 +4023,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++;
@@ -4145,7 +4145,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++;
@@ -4577,7 +4577,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 dc08eb806356..e87a05ff8347 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 b9e5cd574cdc..d9d86ec19811 100644
--- a/tools/aapt/XMLNode.h
+++ b/tools/aapt/XMLNode.h
@@ -176,7 +176,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/BigBuffer.h b/tools/aapt2/BigBuffer.h
index 8b6569c6a8d6..b4b42b48d1cf 100644
--- a/tools/aapt2/BigBuffer.h
+++ b/tools/aapt2/BigBuffer.h
@@ -62,7 +62,7 @@ public:
* Create a BigBuffer with block allocation sizes
* of blockSize.
*/
- BigBuffer(size_t blockSize);
+ explicit BigBuffer(size_t blockSize);
BigBuffer(const BigBuffer&) = delete; // No copying.
diff --git a/tools/aapt2/BindingXmlPullParser.h b/tools/aapt2/BindingXmlPullParser.h
index cfb16ef477c9..b34c00b2c137 100644
--- a/tools/aapt2/BindingXmlPullParser.h
+++ b/tools/aapt2/BindingXmlPullParser.h
@@ -27,7 +27,7 @@ namespace aapt {
class BindingXmlPullParser : public XmlPullParser {
public:
- BindingXmlPullParser(const std::shared_ptr<XmlPullParser>& parser);
+ explicit BindingXmlPullParser(const std::shared_ptr<XmlPullParser>& parser);
BindingXmlPullParser(const BindingXmlPullParser& rhs) = delete;
Event getEvent() const override;
diff --git a/tools/aapt2/ConfigDescription.h b/tools/aapt2/ConfigDescription.h
index 67b4b75cce0b..1250ad2094ba 100644
--- a/tools/aapt2/ConfigDescription.h
+++ b/tools/aapt2/ConfigDescription.h
@@ -46,7 +46,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/Flag.cpp b/tools/aapt2/Flag.cpp
index 76985da99912..774c1bae0ce8 100644
--- a/tools/aapt2/Flag.cpp
+++ b/tools/aapt2/Flag.cpp
@@ -32,20 +32,20 @@ static std::function<bool(const StringPiece&, std::string*)> wrap(
}
void optionalFlag(const StringPiece& name, const StringPiece& description,
- std::function<void(const StringPiece&)> action) {
+ const std::function<void(const StringPiece&)>& action) {
sFlags.push_back(Flag{
name.toString(), description.toString(), wrap(action),
false, nullptr, false, false });
}
void requiredFlag(const StringPiece& name, const StringPiece& description,
- std::function<void(const StringPiece&)> action) {
+ const std::function<void(const StringPiece&)>& action) {
sFlags.push_back(Flag{ name.toString(), description.toString(), wrap(action),
true, nullptr, false, false });
}
void requiredFlag(const StringPiece& name, const StringPiece& description,
- std::function<bool(const StringPiece&, std::string*)> action) {
+ const std::function<bool(const StringPiece&, std::string*)>& action) {
sFlags.push_back(Flag{ name.toString(), description.toString(), action,
true, nullptr, false, false });
}
diff --git a/tools/aapt2/Flag.h b/tools/aapt2/Flag.h
index e86374283986..57aceb403023 100644
--- a/tools/aapt2/Flag.h
+++ b/tools/aapt2/Flag.h
@@ -11,13 +11,13 @@ namespace aapt {
namespace flag {
void requiredFlag(const StringPiece& name, const StringPiece& description,
- std::function<void(const StringPiece&)> action);
+ const std::function<void(const StringPiece&)>& action);
void requiredFlag(const StringPiece& name, const StringPiece& description,
- std::function<bool(const StringPiece&, std::string*)> action);
+ const std::function<bool(const StringPiece&, std::string*)>& action);
void optionalFlag(const StringPiece& name, const StringPiece& description,
- std::function<void(const StringPiece&)> action);
+ const std::function<void(const StringPiece&)>& action);
void optionalSwitch(const StringPiece& name, const StringPiece& description, bool resultWhenSet,
bool* result);
diff --git a/tools/aapt2/JavaClassGenerator_test.cpp b/tools/aapt2/JavaClassGenerator_test.cpp
index b385ff4828e1..3d1bf8961937 100644
--- a/tools/aapt2/JavaClassGenerator_test.cpp
+++ b/tools/aapt2/JavaClassGenerator_test.cpp
@@ -35,7 +35,7 @@ struct JavaClassGeneratorTest : public ::testing::Test {
mTable->setPackageId(0x01);
}
- bool addResource(const ResourceNameRef& name, ResourceId id) {
+ bool addResource(const ResourceNameRef& name, const ResourceId& id) {
return mTable->addResource(name, id, {}, SourceLine{ "test.xml", 21 },
util::make_unique<Id>());
}
diff --git a/tools/aapt2/Logger.h b/tools/aapt2/Logger.h
index 1d437ebe6492..27a79eb8553f 100644
--- a/tools/aapt2/Logger.h
+++ b/tools/aapt2/Logger.h
@@ -56,7 +56,7 @@ private:
class SourceLogger {
public:
- SourceLogger(const Source& source);
+ SourceLogger(const Source& source); // NOLINT(implicit)
std::ostream& error();
std::ostream& error(size_t line);
diff --git a/tools/aapt2/ManifestMerger.h b/tools/aapt2/ManifestMerger.h
index c6219dbba65e..9d34479e4d6b 100644
--- a/tools/aapt2/ManifestMerger.h
+++ b/tools/aapt2/ManifestMerger.h
@@ -15,7 +15,7 @@ public:
struct Options {
};
- ManifestMerger(const Options& options);
+ explicit ManifestMerger(const Options& options);
bool setAppManifest(const Source& source, const std::u16string& package,
std::unique_ptr<xml::Node> root);
diff --git a/tools/aapt2/ManifestParser.cpp b/tools/aapt2/ManifestParser.cpp
index b8f0a430bcee..5b539c6a5d67 100644
--- a/tools/aapt2/ManifestParser.cpp
+++ b/tools/aapt2/ManifestParser.cpp
@@ -24,7 +24,7 @@
namespace aapt {
-bool ManifestParser::parse(const Source& source, std::shared_ptr<XmlPullParser> parser,
+bool ManifestParser::parse(const Source& source, const std::shared_ptr<XmlPullParser>& parser,
AppInfo* outInfo) {
SourceLogger logger = { source };
@@ -70,7 +70,7 @@ bool ManifestParser::parse(const Source& source, std::shared_ptr<XmlPullParser>
return true;
}
-bool ManifestParser::parseManifest(SourceLogger& logger, std::shared_ptr<XmlPullParser> parser,
+bool ManifestParser::parseManifest(SourceLogger& logger, const std::shared_ptr<XmlPullParser>& parser,
AppInfo* outInfo) {
auto attrIter = parser->findAttribute(u"", u"package");
if (attrIter == parser->endAttributes() || attrIter->value.empty()) {
diff --git a/tools/aapt2/ManifestParser.h b/tools/aapt2/ManifestParser.h
index f2e43d4bb695..76201abd6a93 100644
--- a/tools/aapt2/ManifestParser.h
+++ b/tools/aapt2/ManifestParser.h
@@ -33,10 +33,10 @@ public:
ManifestParser() = default;
ManifestParser(const ManifestParser&) = delete;
- bool parse(const Source& source, std::shared_ptr<XmlPullParser> parser, AppInfo* outInfo);
+ bool parse(const Source& source, const std::shared_ptr<XmlPullParser>& parser, AppInfo* outInfo);
private:
- bool parseManifest(SourceLogger& logger, std::shared_ptr<XmlPullParser> parser,
+ bool parseManifest(SourceLogger& logger, const std::shared_ptr<XmlPullParser>& parser,
AppInfo* outInfo);
};
diff --git a/tools/aapt2/ManifestValidator.h b/tools/aapt2/ManifestValidator.h
index 318878499cfa..ecbecde5d86c 100644
--- a/tools/aapt2/ManifestValidator.h
+++ b/tools/aapt2/ManifestValidator.h
@@ -28,7 +28,7 @@ namespace aapt {
class ManifestValidator {
public:
- ManifestValidator(const android::ResTable& table);
+ explicit ManifestValidator(const android::ResTable& table);
ManifestValidator(const ManifestValidator&) = delete;
bool validate(const Source& source, android::ResXMLParser* parser);
diff --git a/tools/aapt2/Maybe.h b/tools/aapt2/Maybe.h
index ff6625f4bb5e..fe8e9a71b0d6 100644
--- a/tools/aapt2/Maybe.h
+++ b/tools/aapt2/Maybe.h
@@ -41,12 +41,12 @@ public:
Maybe(const Maybe& rhs);
template <typename U>
- Maybe(const Maybe<U>& rhs);
+ Maybe(const Maybe<U>& rhs); // NOLINT(implicit)
Maybe(Maybe&& rhs);
template <typename U>
- Maybe(Maybe<U>&& rhs);
+ Maybe(Maybe<U>&& rhs); // NOLINT(implicit)
Maybe& operator=(const Maybe& rhs);
@@ -61,12 +61,12 @@ public:
/**
* Construct a Maybe holding a value.
*/
- Maybe(const T& value);
+ Maybe(const T& value); // NOLINT(implicit)
/**
* Construct a Maybe holding a value.
*/
- Maybe(T&& value);
+ Maybe(T&& value); // NOLINT(implicit)
/**
* True if this holds a value, false if
diff --git a/tools/aapt2/Resource.h b/tools/aapt2/Resource.h
index fa9ac07b1779..b948ea5eb81a 100644
--- a/tools/aapt2/Resource.h
+++ b/tools/aapt2/Resource.h
@@ -94,7 +94,7 @@ struct ResourceNameRef {
ResourceNameRef() = default;
ResourceNameRef(const ResourceNameRef&) = default;
ResourceNameRef(ResourceNameRef&&) = default;
- ResourceNameRef(const ResourceName& rhs);
+ ResourceNameRef(const ResourceName& rhs); // NOLINT(implicit)
ResourceNameRef(const StringPiece16& p, ResourceType t, const StringPiece16& e);
ResourceNameRef& operator=(const ResourceNameRef& rhs) = default;
ResourceNameRef& operator=(ResourceNameRef&& rhs) = default;
@@ -124,7 +124,7 @@ struct ResourceId {
ResourceId();
ResourceId(const ResourceId& rhs);
- ResourceId(uint32_t resId);
+ ResourceId(uint32_t resId); // NOLINT(implicit)
ResourceId(size_t p, size_t t, size_t e);
bool isValid() const;
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index 13f916bfc8f3..ec7bfa5994f6 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -391,7 +391,7 @@ uint32_t ResourceParser::androidTypeToAttributeTypeMask(uint16_t type) {
std::unique_ptr<Item> ResourceParser::parseItemForAttribute(
const StringPiece16& 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);
@@ -451,7 +451,7 @@ std::unique_ptr<Item> ResourceParser::parseItemForAttribute(
*/
std::unique_ptr<Item> ResourceParser::parseItemForAttribute(
const StringPiece16& 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/ResourceParser.h b/tools/aapt2/ResourceParser.h
index 7618999f0023..6fd58fae9259 100644
--- a/tools/aapt2/ResourceParser.h
+++ b/tools/aapt2/ResourceParser.h
@@ -133,11 +133,11 @@ public:
*/
static std::unique_ptr<Item> parseItemForAttribute(
const StringPiece16& value, const Attribute& attr,
- std::function<void(const ResourceName&)> onCreateReference = {});
+ const std::function<void(const ResourceName&)>& onCreateReference = {});
static std::unique_ptr<Item> parseItemForAttribute(
const StringPiece16& value, uint32_t typeMask,
- std::function<void(const ResourceName&)> onCreateReference = {});
+ const std::function<void(const ResourceName&)>& onCreateReference = {});
static uint32_t androidTypeToAttributeTypeMask(uint16_t type);
diff --git a/tools/aapt2/ResourceTable.cpp b/tools/aapt2/ResourceTable.cpp
index c93ecc768022..eeec8da3a1eb 100644
--- a/tools/aapt2/ResourceTable.cpp
+++ b/tools/aapt2/ResourceTable.cpp
@@ -151,7 +151,7 @@ bool ResourceTable::addResource(const ResourceNameRef& name, const ConfigDescrip
return addResourceImpl(name, ResourceId{}, config, source, std::move(value), kValidNameChars);
}
-bool ResourceTable::addResource(const ResourceNameRef& name, const ResourceId resId,
+bool ResourceTable::addResource(const ResourceNameRef& name, const ResourceId& resId,
const ConfigDescription& config, const SourceLine& source,
std::unique_ptr<Value> value) {
return addResourceImpl(name, resId, config, source, std::move(value), kValidNameChars);
@@ -165,7 +165,7 @@ bool ResourceTable::addResourceAllowMangled(const ResourceNameRef& name,
kValidNameMangledChars);
}
-bool ResourceTable::addResourceImpl(const ResourceNameRef& name, const ResourceId resId,
+bool ResourceTable::addResourceImpl(const ResourceNameRef& name, const ResourceId& resId,
const ConfigDescription& config, const SourceLine& source,
std::unique_ptr<Value> value, const char16_t* validChars) {
if (!name.package.empty() && name.package != mPackage) {
@@ -255,17 +255,17 @@ bool ResourceTable::addResourceImpl(const ResourceNameRef& name, const ResourceI
return true;
}
-bool ResourceTable::markPublic(const ResourceNameRef& name, const ResourceId resId,
+bool ResourceTable::markPublic(const ResourceNameRef& name, const ResourceId& resId,
const SourceLine& source) {
return markPublicImpl(name, resId, source, kValidNameChars);
}
-bool ResourceTable::markPublicAllowMangled(const ResourceNameRef& name, const ResourceId resId,
+bool ResourceTable::markPublicAllowMangled(const ResourceNameRef& name, const ResourceId& resId,
const SourceLine& source) {
return markPublicImpl(name, resId, source, kValidNameMangledChars);
}
-bool ResourceTable::markPublicImpl(const ResourceNameRef& name, const ResourceId resId,
+bool ResourceTable::markPublicImpl(const ResourceNameRef& name, const ResourceId& resId,
const SourceLine& source, const char16_t* validChars) {
if (!name.package.empty() && name.package != mPackage) {
Logger::error(source)
diff --git a/tools/aapt2/ResourceTable.h b/tools/aapt2/ResourceTable.h
index 706f56a2776f..e00fb3e4406b 100644
--- a/tools/aapt2/ResourceTable.h
+++ b/tools/aapt2/ResourceTable.h
@@ -81,8 +81,8 @@ struct ResourceEntry {
*/
std::vector<ResourceConfigValue> values;
- inline ResourceEntry(const StringPiece16& _name);
- inline ResourceEntry(const ResourceEntry* rhs);
+ inline explicit ResourceEntry(const StringPiece16& _name);
+ inline explicit ResourceEntry(const ResourceEntry* rhs);
};
/**
@@ -115,8 +115,8 @@ struct ResourceTableType {
*/
std::vector<std::unique_ptr<ResourceEntry>> entries;
- ResourceTableType(const ResourceType _type);
- ResourceTableType(const ResourceTableType* rhs);
+ explicit ResourceTableType(const ResourceType _type);
+ explicit ResourceTableType(const ResourceTableType* rhs);
};
/**
@@ -151,12 +151,12 @@ public:
bool addResourceAllowMangled(const ResourceNameRef& name, const ConfigDescription& config,
const SourceLine& source, std::unique_ptr<Value> value);
- bool addResource(const ResourceNameRef& name, const ResourceId resId,
+ bool addResource(const ResourceNameRef& name, const ResourceId& resId,
const ConfigDescription& config, const SourceLine& source,
std::unique_ptr<Value> value);
- bool markPublic(const ResourceNameRef& name, const ResourceId resId, const SourceLine& source);
- bool markPublicAllowMangled(const ResourceNameRef& name, const ResourceId resId,
+ bool markPublic(const ResourceNameRef& name, const ResourceId& resId, const SourceLine& source);
+ bool markPublicAllowMangled(const ResourceNameRef& name, const ResourceId& resId,
const SourceLine& source);
/*
@@ -186,10 +186,10 @@ private:
std::unique_ptr<ResourceEntry>& findOrCreateEntry(std::unique_ptr<ResourceTableType>& type,
const StringPiece16& name);
- bool addResourceImpl(const ResourceNameRef& name, const ResourceId resId,
+ bool addResourceImpl(const ResourceNameRef& name, const ResourceId& resId,
const ConfigDescription& config, const SourceLine& source,
std::unique_ptr<Value> value, const char16_t* validChars);
- bool markPublicImpl(const ResourceNameRef& name, const ResourceId resId,
+ bool markPublicImpl(const ResourceNameRef& name, const ResourceId& resId,
const SourceLine& source, const char16_t* validChars);
std::u16string mPackage;
diff --git a/tools/aapt2/ResourceValues.h b/tools/aapt2/ResourceValues.h
index ef6594e6f231..2635e34ccd20 100644
--- a/tools/aapt2/ResourceValues.h
+++ b/tools/aapt2/ResourceValues.h
@@ -128,8 +128,8 @@ struct Reference : public BaseItem<Reference> {
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 Id : public BaseItem<Id> {
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 RawString : public BaseItem<RawString> {
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 String : public BaseItem<String> {
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 @@ struct FileReference : public BaseItem<FileReference> {
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 @@ struct BinaryPrimitive : public BaseItem<BinaryPrimitive> {
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 @@ struct Attribute : public BaseValue<Attribute> {
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 @@ template <typename T, typename TFunc>
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 @@ template <typename T, typename TFunc>
struct ConstValueVisitorFunc : ConstValueVisitor {
TFunc func;
- ConstValueVisitorFunc(TFunc f) : func(f) {
+ explicit ConstValueVisitorFunc(TFunc f) : func(f) {
}
void visit(const T& value, ValueVisitorArgs&) override {
diff --git a/tools/aapt2/ScopedXmlPullParser.h b/tools/aapt2/ScopedXmlPullParser.h
index a040f6097fc3..5b6b32113aa1 100644
--- a/tools/aapt2/ScopedXmlPullParser.h
+++ b/tools/aapt2/ScopedXmlPullParser.h
@@ -47,7 +47,7 @@ namespace aapt {
*/
class ScopedXmlPullParser : public XmlPullParser {
public:
- ScopedXmlPullParser(XmlPullParser* parser);
+ explicit ScopedXmlPullParser(XmlPullParser* parser);
ScopedXmlPullParser(const ScopedXmlPullParser&) = delete;
ScopedXmlPullParser& operator=(const ScopedXmlPullParser&) = delete;
~ScopedXmlPullParser();
diff --git a/tools/aapt2/SdkConstants.cpp b/tools/aapt2/SdkConstants.cpp
index 9bdae490412f..cd75e98041c3 100644
--- a/tools/aapt2/SdkConstants.cpp
+++ b/tools/aapt2/SdkConstants.cpp
@@ -48,7 +48,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 803da03743c5..4a57828fd2ee 100644
--- a/tools/aapt2/SdkConstants.h
+++ b/tools/aapt2/SdkConstants.h
@@ -44,7 +44,7 @@ enum {
SDK_LOLLIPOP_MR1 = 22,
};
-size_t findAttributeSdkLevel(ResourceId id);
+size_t findAttributeSdkLevel(const ResourceId& id);
size_t findAttributeSdkLevel(const ResourceName& name);
} // namespace aapt
diff --git a/tools/aapt2/SourceXmlPullParser.h b/tools/aapt2/SourceXmlPullParser.h
index d8ed45952b31..66d54a817241 100644
--- a/tools/aapt2/SourceXmlPullParser.h
+++ b/tools/aapt2/SourceXmlPullParser.h
@@ -30,7 +30,7 @@ namespace aapt {
class SourceXmlPullParser : public XmlPullParser {
public:
- SourceXmlPullParser(std::istream& in);
+ explicit SourceXmlPullParser(std::istream& in);
SourceXmlPullParser(const SourceXmlPullParser& rhs) = delete;
~SourceXmlPullParser();
diff --git a/tools/aapt2/StringPiece.h b/tools/aapt2/StringPiece.h
index e2a1597caeda..2221e2344f25 100644
--- a/tools/aapt2/StringPiece.h
+++ b/tools/aapt2/StringPiece.h
@@ -39,8 +39,8 @@ public:
BasicStringPiece();
BasicStringPiece(const BasicStringPiece<TChar>& str);
- BasicStringPiece(const std::basic_string<TChar>& str);
- BasicStringPiece(const TChar* str);
+ BasicStringPiece(const std::basic_string<TChar>& str); // NOLINT(implicit)
+ BasicStringPiece(const TChar* str); // NOLINT(implicit)
BasicStringPiece(const TChar* str, size_t len);
BasicStringPiece<TChar>& operator=(const BasicStringPiece<TChar>& rhs);
diff --git a/tools/aapt2/StringPool.h b/tools/aapt2/StringPool.h
index 14304a6e6b1a..610a5539b331 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/TableFlattener.h b/tools/aapt2/TableFlattener.h
index ccbb737059f9..55914dbf5e4b 100644
--- a/tools/aapt2/TableFlattener.h
+++ b/tools/aapt2/TableFlattener.h
@@ -46,7 +46,7 @@ struct TableFlattener {
bool useExtendedChunks = true;
};
- TableFlattener(Options options);
+ explicit TableFlattener(Options options);
bool flatten(BigBuffer* out, const ResourceTable& table);
diff --git a/tools/aapt2/Util.h b/tools/aapt2/Util.h
index 9cdb152bf41f..b2b6d8e66f9c 100644
--- a/tools/aapt2/Util.h
+++ b/tools/aapt2/Util.h
@@ -311,7 +311,7 @@ Maybe<std::u16string> extractPackageFromNamespace(const std::u16string& namespac
* In the aapt namespace for lookup.
*/
inline ::std::ostream& operator<<(::std::ostream& out,
- ::std::function<::std::ostream&(::std::ostream&)> f) {
+ const ::std::function<::std::ostream&(::std::ostream&)>& f) {
return f(out);
}
diff --git a/tools/aapt2/XliffXmlPullParser.h b/tools/aapt2/XliffXmlPullParser.h
index 77912277b31e..e89d8bbfc25c 100644
--- a/tools/aapt2/XliffXmlPullParser.h
+++ b/tools/aapt2/XliffXmlPullParser.h
@@ -30,7 +30,7 @@ namespace aapt {
*/
class XliffXmlPullParser : public XmlPullParser {
public:
- XliffXmlPullParser(const std::shared_ptr<XmlPullParser>& parser);
+ explicit XliffXmlPullParser(const std::shared_ptr<XmlPullParser>& parser);
XliffXmlPullParser(const XliffXmlPullParser& rhs) = delete;
Event getEvent() const override;
diff --git a/tools/aapt2/XmlDom.h b/tools/aapt2/XmlDom.h
index 035e7c46d1b5..105a07478164 100644
--- a/tools/aapt2/XmlDom.h
+++ b/tools/aapt2/XmlDom.h
@@ -52,7 +52,7 @@ struct Node {
std::u16string comment;
std::vector<std::unique_ptr<Node>> children;
- Node(NodeType type);
+ explicit Node(NodeType type);
void addChild(std::unique_ptr<Node> child);
virtual std::unique_ptr<Node> clone() const = 0;
virtual void accept(Visitor* visitor) = 0;
@@ -65,7 +65,7 @@ struct Node {
*/
template <typename Derived>
struct BaseNode : public Node {
- BaseNode(NodeType t);
+ explicit BaseNode(NodeType t);
virtual void accept(Visitor* visitor) override;
};