Merge "Fix clang-tidy warnings in aapt and aapt2."

This commit is contained in:
Chih-hung Hsieh
2016-08-12 18:05:32 +00:00
committed by Gerrit Code Review
45 changed files with 92 additions and 92 deletions

View File

@ -32,7 +32,7 @@ class AaptFile;
class ApkBuilder : public android::RefBase { class ApkBuilder : public android::RefBase {
public: public:
ApkBuilder(const sp<WeakResourceFilter>& configFilter); explicit ApkBuilder(const sp<WeakResourceFilter>& configFilter);
/** /**
* Tells the builder to generate a separate APK for resources that * Tells the builder to generate a separate APK for resources that

View File

@ -51,7 +51,7 @@ private:
class SystemCacheUpdater : public CacheUpdater { class SystemCacheUpdater : public CacheUpdater {
public: public:
// Constructor to set bundle to pass to preProcessImage // Constructor to set bundle to pass to preProcessImage
SystemCacheUpdater (Bundle* b) explicit SystemCacheUpdater (Bundle* b)
: bundle(b) { }; : bundle(b) { };
// Make sure all the directories along this path exist // Make sure all the directories along this path exist

View File

@ -248,7 +248,7 @@ bail:
} }
static void printResolvedResourceAttribute(const ResTable& resTable, const ResXMLTree& tree, 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; Res_value value;
AaptXml::getResolvedResourceAttribute(resTable, tree, attrRes, &value, outError); 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()); 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) String8 *outError = NULL)
{ {
Asset* aidAsset = assets.openNonAsset(xmlPath, Asset::ACCESS_BUFFER); Asset* aidAsset = assets.openNonAsset(xmlPath, Asset::ACCESS_BUFFER);

View File

@ -29,7 +29,7 @@ struct ConfigDescription : public android::ResTable_config {
size = sizeof(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; *static_cast<android::ResTable_config*>(this) = o;
size = sizeof(android::ResTable_config); size = sizeof(android::ResTable_config);
} }

View File

@ -94,7 +94,7 @@ void CrunchCache::loadFiles()
delete dw; 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 // Retrieve modification dates for this file entry under the source and
// cache directory trees. The vectors will return a modification date of 0 // cache directory trees. The vectors will return a modification date of 0

View File

@ -81,7 +81,7 @@ private:
* // Recrunch sourceFile out to destFile. * // Recrunch sourceFile out to destFile.
* *
*/ */
bool needsUpdating(String8 relativePath) const; bool needsUpdating(const String8& relativePath) const;
// DATA MEMBERS ==================================================== // DATA MEMBERS ====================================================

View File

@ -77,7 +77,7 @@ bool SystemFileFinder::findFiles(String8 basePath, Vector<String8>& extensions,
return true; return true;
} }
void SystemFileFinder::checkAndAddFile(String8 path, const struct stat* stats, void SystemFileFinder::checkAndAddFile(const String8& path, const struct stat* stats,
Vector<String8>& extensions, Vector<String8>& extensions,
KeyedVector<String8,time_t>& fileStore) KeyedVector<String8,time_t>& fileStore)
{ {

View File

@ -72,7 +72,7 @@ private:
* time as the value. * 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, Vector<String8>& extensions,
KeyedVector<String8,time_t>& fileStore); KeyedVector<String8,time_t>& fileStore);

View File

@ -3,7 +3,7 @@
class IndentPrinter { class IndentPrinter {
public: public:
IndentPrinter(FILE* stream, int indentSize=2) explicit IndentPrinter(FILE* stream, int indentSize=2)
: mStream(stream) : mStream(stream)
, mIndentSize(indentSize) , mIndentSize(indentSize)
, mIndent(0) , mIndent(0)

View File

@ -394,7 +394,7 @@ static void collect_files(const sp<AaptDir>& dir,
const DefaultKeyedVector<String8, sp<AaptGroup> >& groups = dir->getFiles(); const DefaultKeyedVector<String8, sp<AaptGroup> >& groups = dir->getFiles();
int N = groups.size(); int N = groups.size();
for (int i=0; i<N; i++) { 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 sp<AaptGroup>& group = groups.valueAt(i);
const DefaultKeyedVector<AaptGroupEntry, sp<AaptFile> >& files const DefaultKeyedVector<AaptGroupEntry, sp<AaptFile> >& files
@ -417,7 +417,7 @@ static void collect_files(const sp<AaptDir>& dir,
set->add(leafName, group); set->add(leafName, group);
resources->add(resType, set); resources->add(resType, set);
} else { } else {
sp<ResourceTypeSet> set = resources->valueAt(index); const sp<ResourceTypeSet>& set = resources->valueAt(index);
index = set->indexOfKey(leafName); index = set->indexOfKey(leafName);
if (index < 0) { if (index < 0) {
if (kIsDebug) { if (kIsDebug) {
@ -452,7 +452,7 @@ static void collect_files(const sp<AaptAssets>& ass,
int N = dirs.size(); int N = dirs.size();
for (int i=0; i<N; i++) { for (int i=0; i<N; i++) {
sp<AaptDir> d = dirs.itemAt(i); const sp<AaptDir>& d = dirs.itemAt(i);
if (kIsDebug) { if (kIsDebug) {
printf("Collecting dir #%d %p: %s, leaf %s\n", i, d.get(), d->getPath().string(), printf("Collecting dir #%d %p: %s, leaf %s\n", i, d.get(), d->getPath().string(),
d->getLeaf().string()); d->getLeaf().string());
@ -610,7 +610,7 @@ static bool applyFileOverlay(Bundle *bundle,
// get the overlay resources of the requested type // get the overlay resources of the requested type
ssize_t index = overlayRes->indexOfKey(resTypeString); ssize_t index = overlayRes->indexOfKey(resTypeString);
if (index >= 0) { 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 // for each of the resources, check for a match in the previously built
// non-overlay "baseset". // non-overlay "baseset".
@ -760,7 +760,7 @@ bool addTagAttribute(const sp<XMLNode>& node, const char* ns8,
return addTagAttribute(node, ns8, attr8, value, errorOnFailedInsert, false); 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) { const String16& attrName) {
XMLNode::attribute_entry* attr = node->editAttribute( XMLNode::attribute_entry* attr = node->editAttribute(
String16("http://schemas.android.com/apk/res/android"), attrName); 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")); ResourceDirIterator it(resources->valueAt(index), String8("values"));
ssize_t res; ssize_t res;
while ((res=it.next()) == NO_ERROR) { while ((res=it.next()) == NO_ERROR) {
sp<AaptFile> file = it.getFile(); const sp<AaptFile>& file = it.getFile();
res = compileResourceFile(bundle, assets, file, it.getParams(), res = compileResourceFile(bundle, assets, file, it.getParams(),
(current!=assets), &table); (current!=assets), &table);
if (res != NO_ERROR) { if (res != NO_ERROR) {
@ -2674,7 +2674,7 @@ status_t writeResourceSymbols(Bundle* bundle, const sp<AaptAssets>& assets,
String8 dest(bundle->getRClassDir()); String8 dest(bundle->getRClassDir());
if (bundle->getMakePackageDirs()) { if (bundle->getMakePackageDirs()) {
String8 pkg(package); const String8& pkg(package);
const char* last = pkg.string(); const char* last = pkg.string();
const char* s = last-1; const char* s = last-1;
do { do {

View File

@ -78,7 +78,7 @@ private:
class StrongResourceFilter : public ResourceFilter { class StrongResourceFilter : public ResourceFilter {
public: public:
StrongResourceFilter() {} StrongResourceFilter() {}
StrongResourceFilter(const std::set<ConfigDescription>& configs) explicit StrongResourceFilter(const std::set<ConfigDescription>& configs)
: mConfigs(configs) {} : mConfigs(configs) {}
android::status_t parse(const android::String8& str); android::status_t parse(const android::String8& str);
@ -106,7 +106,7 @@ private:
*/ */
class InverseResourceFilter : public ResourceFilter { class InverseResourceFilter : public ResourceFilter {
public: public:
InverseResourceFilter(const android::sp<ResourceFilter>& filter) explicit InverseResourceFilter(const android::sp<ResourceFilter>& filter)
: mFilter(filter) {} : mFilter(filter) {}
bool match(const android::ResTable_config& config) const { bool match(const android::ResTable_config& config) const {

View File

@ -4023,7 +4023,7 @@ status_t ResourceTable::Type::applyPublicEntryOrder()
j = 0; j = 0;
for (i=0; i<N; i++) { 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. // There will always be enough room for the remaining entries.
while (mOrderedConfigs.itemAt(j) != NULL) { while (mOrderedConfigs.itemAt(j) != NULL) {
j++; j++;
@ -4145,7 +4145,7 @@ status_t ResourceTable::Package::applyPublicTypeOrder()
size_t j=0; size_t j=0;
for (i=0; i<N; i++) { 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. // There will always be enough room for the remaining types.
while (mOrderedTypes.itemAt(j) != NULL) { while (mOrderedTypes.itemAt(j) != NULL) {
j++; j++;
@ -4577,7 +4577,7 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle) {
c->getEntries(); c->getEntries();
const size_t entryCount = entries.size(); const size_t entryCount = entries.size();
for (size_t ei = 0; ei < entryCount; ei++) { 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) { if (e == NULL || e->getType() != Entry::TYPE_BAG) {
continue; continue;
} }

View File

@ -41,7 +41,7 @@ class StringPool
public: public:
struct entry { struct entry {
entry() : offset(0) { } 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), entry(const entry& o) : value(o.value), offset(o.offset),
hasStyles(o.hasStyles), indices(o.indices), hasStyles(o.hasStyles), indices(o.indices),
configTypeName(o.configTypeName), configs(o.configs) { } configTypeName(o.configTypeName), configs(o.configs) { }

View File

@ -47,7 +47,7 @@ public:
}; };
/* Creates a work queue with the specified maximum number of work threads. */ /* 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. /* Destroys the work queue.
* Cancels pending work and waits for all remaining threads to complete. * Cancels pending work and waits for all remaining threads to complete.

View File

@ -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_PRV_PREFIX(RESOURCES_ROOT_PRV_NAMESPACE);
static const String16 RESOURCES_TOOLS_NAMESPACE("http://schemas.android.com/tools"); 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(), //printf("%s starts with %s?\n", String8(namespaceUri).string(),
// String8(RESOURCES_PREFIX).string()); // String8(RESOURCES_PREFIX).string());
@ -98,7 +98,7 @@ String16 getNamespaceResourcePackage(String16 appPackage, String16 namespaceUri,
status_t hasSubstitutionErrors(const char* fileName, status_t hasSubstitutionErrors(const char* fileName,
ResXMLTree* inXml, ResXMLTree* inXml,
String16 str16) const String16& str16)
{ {
const char16_t* str = str16.string(); const char16_t* str = str16.string();
const char16_t* p = str; const char16_t* p = str;

View File

@ -176,7 +176,7 @@ private:
XMLNode(const String8& filename, const String16& s1, const String16& s2, bool isNamespace); XMLNode(const String8& filename, const String16& s1, const String16& s2, bool isNamespace);
// Creating a CDATA node. // Creating a CDATA node.
XMLNode(const String8& filename); explicit XMLNode(const String8& filename);
status_t collect_strings(StringPool* dest, Vector<uint32_t>* outResIds, status_t collect_strings(StringPool* dest, Vector<uint32_t>* outResIds,
bool stripComments, bool stripRawValues) const; bool stripComments, bool stripRawValues) const;

View File

@ -43,7 +43,7 @@ class PseudoMethodAccent : public PseudoMethodImpl {
class Pseudolocalizer { class Pseudolocalizer {
public: public:
Pseudolocalizer(PseudolocalizationMethod m); explicit Pseudolocalizer(PseudolocalizationMethod m);
~Pseudolocalizer() { if (mImpl) delete mImpl; } ~Pseudolocalizer() { if (mImpl) delete mImpl; }
void setMethod(PseudolocalizationMethod m); void setMethod(PseudolocalizationMethod m);
String16 start() { return mImpl->start(); } String16 start() { return mImpl->start(); }

View File

@ -62,7 +62,7 @@ public:
* Create a BigBuffer with block allocation sizes * Create a BigBuffer with block allocation sizes
* of blockSize. * of blockSize.
*/ */
BigBuffer(size_t blockSize); explicit BigBuffer(size_t blockSize);
BigBuffer(const BigBuffer&) = delete; // No copying. BigBuffer(const BigBuffer&) = delete; // No copying.

View File

@ -27,7 +27,7 @@ namespace aapt {
class BindingXmlPullParser : public XmlPullParser { class BindingXmlPullParser : public XmlPullParser {
public: public:
BindingXmlPullParser(const std::shared_ptr<XmlPullParser>& parser); explicit BindingXmlPullParser(const std::shared_ptr<XmlPullParser>& parser);
BindingXmlPullParser(const BindingXmlPullParser& rhs) = delete; BindingXmlPullParser(const BindingXmlPullParser& rhs) = delete;
Event getEvent() const override; Event getEvent() const override;

View File

@ -46,7 +46,7 @@ struct ConfigDescription : public android::ResTable_config {
static void applyVersionForCompatibility(ConfigDescription* config); static void applyVersionForCompatibility(ConfigDescription* config);
ConfigDescription(); ConfigDescription();
ConfigDescription(const android::ResTable_config& o); ConfigDescription(const android::ResTable_config& o); // NOLINT(implicit)
ConfigDescription(const ConfigDescription& o); ConfigDescription(const ConfigDescription& o);
ConfigDescription(ConfigDescription&& o); ConfigDescription(ConfigDescription&& o);

View File

@ -32,20 +32,20 @@ static std::function<bool(const StringPiece&, std::string*)> wrap(
} }
void optionalFlag(const StringPiece& name, const StringPiece& description, 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{ sFlags.push_back(Flag{
name.toString(), description.toString(), wrap(action), name.toString(), description.toString(), wrap(action),
false, nullptr, false, false }); false, nullptr, false, false });
} }
void requiredFlag(const StringPiece& name, const StringPiece& description, 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), sFlags.push_back(Flag{ name.toString(), description.toString(), wrap(action),
true, nullptr, false, false }); true, nullptr, false, false });
} }
void requiredFlag(const StringPiece& name, const StringPiece& description, 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, sFlags.push_back(Flag{ name.toString(), description.toString(), action,
true, nullptr, false, false }); true, nullptr, false, false });
} }

View File

@ -11,13 +11,13 @@ namespace aapt {
namespace flag { namespace flag {
void requiredFlag(const StringPiece& name, const StringPiece& description, 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, 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, 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, void optionalSwitch(const StringPiece& name, const StringPiece& description, bool resultWhenSet,
bool* result); bool* result);

View File

@ -35,7 +35,7 @@ struct JavaClassGeneratorTest : public ::testing::Test {
mTable->setPackageId(0x01); 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 }, return mTable->addResource(name, id, {}, SourceLine{ "test.xml", 21 },
util::make_unique<Id>()); util::make_unique<Id>());
} }

View File

@ -56,7 +56,7 @@ private:
class SourceLogger { class SourceLogger {
public: public:
SourceLogger(const Source& source); SourceLogger(const Source& source); // NOLINT(implicit)
std::ostream& error(); std::ostream& error();
std::ostream& error(size_t line); std::ostream& error(size_t line);

View File

@ -15,7 +15,7 @@ public:
struct Options { struct Options {
}; };
ManifestMerger(const Options& options); explicit ManifestMerger(const Options& options);
bool setAppManifest(const Source& source, const std::u16string& package, bool setAppManifest(const Source& source, const std::u16string& package,
std::unique_ptr<xml::Node> root); std::unique_ptr<xml::Node> root);

View File

@ -24,7 +24,7 @@
namespace aapt { 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) { AppInfo* outInfo) {
SourceLogger logger = { source }; SourceLogger logger = { source };
@ -70,7 +70,7 @@ bool ManifestParser::parse(const Source& source, std::shared_ptr<XmlPullParser>
return true; 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) { AppInfo* outInfo) {
auto attrIter = parser->findAttribute(u"", u"package"); auto attrIter = parser->findAttribute(u"", u"package");
if (attrIter == parser->endAttributes() || attrIter->value.empty()) { if (attrIter == parser->endAttributes() || attrIter->value.empty()) {

View File

@ -33,10 +33,10 @@ public:
ManifestParser() = default; ManifestParser() = default;
ManifestParser(const ManifestParser&) = delete; 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: private:
bool parseManifest(SourceLogger& logger, std::shared_ptr<XmlPullParser> parser, bool parseManifest(SourceLogger& logger, const std::shared_ptr<XmlPullParser>& parser,
AppInfo* outInfo); AppInfo* outInfo);
}; };

View File

@ -28,7 +28,7 @@ namespace aapt {
class ManifestValidator { class ManifestValidator {
public: public:
ManifestValidator(const android::ResTable& table); explicit ManifestValidator(const android::ResTable& table);
ManifestValidator(const ManifestValidator&) = delete; ManifestValidator(const ManifestValidator&) = delete;
bool validate(const Source& source, android::ResXMLParser* parser); bool validate(const Source& source, android::ResXMLParser* parser);

View File

@ -41,12 +41,12 @@ public:
Maybe(const Maybe& rhs); Maybe(const Maybe& rhs);
template <typename U> template <typename U>
Maybe(const Maybe<U>& rhs); Maybe(const Maybe<U>& rhs); // NOLINT(implicit)
Maybe(Maybe&& rhs); Maybe(Maybe&& rhs);
template <typename U> template <typename U>
Maybe(Maybe<U>&& rhs); Maybe(Maybe<U>&& rhs); // NOLINT(implicit)
Maybe& operator=(const Maybe& rhs); Maybe& operator=(const Maybe& rhs);
@ -61,12 +61,12 @@ public:
/** /**
* Construct a Maybe holding a value. * Construct a Maybe holding a value.
*/ */
Maybe(const T& value); Maybe(const T& value); // NOLINT(implicit)
/** /**
* Construct a Maybe holding a value. * Construct a Maybe holding a value.
*/ */
Maybe(T&& value); Maybe(T&& value); // NOLINT(implicit)
/** /**
* True if this holds a value, false if * True if this holds a value, false if

View File

@ -94,7 +94,7 @@ struct ResourceNameRef {
ResourceNameRef() = default; ResourceNameRef() = default;
ResourceNameRef(const ResourceNameRef&) = default; ResourceNameRef(const ResourceNameRef&) = default;
ResourceNameRef(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(const StringPiece16& p, ResourceType t, const StringPiece16& e);
ResourceNameRef& operator=(const ResourceNameRef& rhs) = default; ResourceNameRef& operator=(const ResourceNameRef& rhs) = default;
ResourceNameRef& operator=(ResourceNameRef&& rhs) = default; ResourceNameRef& operator=(ResourceNameRef&& rhs) = default;
@ -124,7 +124,7 @@ struct ResourceId {
ResourceId(); ResourceId();
ResourceId(const ResourceId& rhs); ResourceId(const ResourceId& rhs);
ResourceId(uint32_t resId); ResourceId(uint32_t resId); // NOLINT(implicit)
ResourceId(size_t p, size_t t, size_t e); ResourceId(size_t p, size_t t, size_t e);
bool isValid() const; bool isValid() const;

View File

@ -391,7 +391,7 @@ uint32_t ResourceParser::androidTypeToAttributeTypeMask(uint16_t type) {
std::unique_ptr<Item> ResourceParser::parseItemForAttribute( std::unique_ptr<Item> ResourceParser::parseItemForAttribute(
const StringPiece16& value, uint32_t typeMask, 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); std::unique_ptr<BinaryPrimitive> nullOrEmpty = tryParseNullOrEmpty(value);
if (nullOrEmpty) { if (nullOrEmpty) {
return std::move(nullOrEmpty); return std::move(nullOrEmpty);
@ -451,7 +451,7 @@ std::unique_ptr<Item> ResourceParser::parseItemForAttribute(
*/ */
std::unique_ptr<Item> ResourceParser::parseItemForAttribute( std::unique_ptr<Item> ResourceParser::parseItemForAttribute(
const StringPiece16& str, const Attribute& attr, 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; const uint32_t typeMask = attr.typeMask;
std::unique_ptr<Item> value = parseItemForAttribute(str, typeMask, onCreateReference); std::unique_ptr<Item> value = parseItemForAttribute(str, typeMask, onCreateReference);
if (value) { if (value) {

View File

@ -133,11 +133,11 @@ public:
*/ */
static std::unique_ptr<Item> parseItemForAttribute( static std::unique_ptr<Item> parseItemForAttribute(
const StringPiece16& value, const Attribute& attr, 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( static std::unique_ptr<Item> parseItemForAttribute(
const StringPiece16& value, uint32_t typeMask, 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); static uint32_t androidTypeToAttributeTypeMask(uint16_t type);

View File

@ -151,7 +151,7 @@ bool ResourceTable::addResource(const ResourceNameRef& name, const ConfigDescrip
return addResourceImpl(name, ResourceId{}, config, source, std::move(value), kValidNameChars); 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, const ConfigDescription& config, const SourceLine& source,
std::unique_ptr<Value> value) { std::unique_ptr<Value> value) {
return addResourceImpl(name, resId, config, source, std::move(value), kValidNameChars); return addResourceImpl(name, resId, config, source, std::move(value), kValidNameChars);
@ -165,7 +165,7 @@ bool ResourceTable::addResourceAllowMangled(const ResourceNameRef& name,
kValidNameMangledChars); 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, const ConfigDescription& config, const SourceLine& source,
std::unique_ptr<Value> value, const char16_t* validChars) { std::unique_ptr<Value> value, const char16_t* validChars) {
if (!name.package.empty() && name.package != mPackage) { if (!name.package.empty() && name.package != mPackage) {
@ -255,17 +255,17 @@ bool ResourceTable::addResourceImpl(const ResourceNameRef& name, const ResourceI
return true; return true;
} }
bool ResourceTable::markPublic(const ResourceNameRef& name, const ResourceId resId, bool ResourceTable::markPublic(const ResourceNameRef& name, const ResourceId& resId,
const SourceLine& source) { const SourceLine& source) {
return markPublicImpl(name, resId, source, kValidNameChars); 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) { const SourceLine& source) {
return markPublicImpl(name, resId, source, kValidNameMangledChars); 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) { const SourceLine& source, const char16_t* validChars) {
if (!name.package.empty() && name.package != mPackage) { if (!name.package.empty() && name.package != mPackage) {
Logger::error(source) Logger::error(source)

View File

@ -81,8 +81,8 @@ struct ResourceEntry {
*/ */
std::vector<ResourceConfigValue> values; std::vector<ResourceConfigValue> values;
inline ResourceEntry(const StringPiece16& _name); inline explicit ResourceEntry(const StringPiece16& _name);
inline ResourceEntry(const ResourceEntry* rhs); inline explicit ResourceEntry(const ResourceEntry* rhs);
}; };
/** /**
@ -115,8 +115,8 @@ struct ResourceTableType {
*/ */
std::vector<std::unique_ptr<ResourceEntry>> entries; std::vector<std::unique_ptr<ResourceEntry>> entries;
ResourceTableType(const ResourceType _type); explicit ResourceTableType(const ResourceType _type);
ResourceTableType(const ResourceTableType* rhs); explicit ResourceTableType(const ResourceTableType* rhs);
}; };
/** /**
@ -151,12 +151,12 @@ public:
bool addResourceAllowMangled(const ResourceNameRef& name, const ConfigDescription& config, bool addResourceAllowMangled(const ResourceNameRef& name, const ConfigDescription& config,
const SourceLine& source, std::unique_ptr<Value> value); 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, const ConfigDescription& config, const SourceLine& source,
std::unique_ptr<Value> value); std::unique_ptr<Value> value);
bool markPublic(const ResourceNameRef& name, const ResourceId resId, const SourceLine& source); bool markPublic(const ResourceNameRef& name, const ResourceId& resId, const SourceLine& source);
bool markPublicAllowMangled(const ResourceNameRef& name, const ResourceId resId, bool markPublicAllowMangled(const ResourceNameRef& name, const ResourceId& resId,
const SourceLine& source); const SourceLine& source);
/* /*
@ -186,10 +186,10 @@ private:
std::unique_ptr<ResourceEntry>& findOrCreateEntry(std::unique_ptr<ResourceTableType>& type, std::unique_ptr<ResourceEntry>& findOrCreateEntry(std::unique_ptr<ResourceTableType>& type,
const StringPiece16& name); 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, const ConfigDescription& config, const SourceLine& source,
std::unique_ptr<Value> value, const char16_t* validChars); 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); const SourceLine& source, const char16_t* validChars);
std::u16string mPackage; std::u16string mPackage;

View File

@ -128,8 +128,8 @@ struct Reference : public BaseItem<Reference> {
bool privateReference = false; bool privateReference = false;
Reference(); Reference();
Reference(const ResourceNameRef& n, Type type = Type::kResource); Reference(const ResourceNameRef& n, Type type = Type::kResource); // NOLINT(implicit)
Reference(const ResourceId& i, Type type = Type::kResource); explicit Reference(const ResourceId& i, Type type = Type::kResource);
bool flatten(android::Res_value& outValue) const override; bool flatten(android::Res_value& outValue) const override;
Reference* clone(StringPool* newPool) const override; Reference* clone(StringPool* newPool) const override;
@ -154,7 +154,7 @@ struct Id : public BaseItem<Id> {
struct RawString : public BaseItem<RawString> { struct RawString : public BaseItem<RawString> {
StringPool::Ref value; StringPool::Ref value;
RawString(const StringPool::Ref& ref); explicit RawString(const StringPool::Ref& ref);
bool flatten(android::Res_value& outValue) const override; bool flatten(android::Res_value& outValue) const override;
RawString* clone(StringPool* newPool) const override; RawString* clone(StringPool* newPool) const override;
@ -164,7 +164,7 @@ struct RawString : public BaseItem<RawString> {
struct String : public BaseItem<String> { struct String : public BaseItem<String> {
StringPool::Ref value; StringPool::Ref value;
String(const StringPool::Ref& ref); explicit String(const StringPool::Ref& ref);
bool flatten(android::Res_value& outValue) const override; bool flatten(android::Res_value& outValue) const override;
String* clone(StringPool* newPool) const override; String* clone(StringPool* newPool) const override;
@ -174,7 +174,7 @@ struct String : public BaseItem<String> {
struct StyledString : public BaseItem<StyledString> { struct StyledString : public BaseItem<StyledString> {
StringPool::StyleRef value; StringPool::StyleRef value;
StyledString(const StringPool::StyleRef& ref); explicit StyledString(const StringPool::StyleRef& ref);
bool flatten(android::Res_value& outValue) const override; bool flatten(android::Res_value& outValue) const override;
StyledString* clone(StringPool* newPool) const override; StyledString* clone(StringPool* newPool) const override;
@ -185,7 +185,7 @@ struct FileReference : public BaseItem<FileReference> {
StringPool::Ref path; StringPool::Ref path;
FileReference() = default; FileReference() = default;
FileReference(const StringPool::Ref& path); explicit FileReference(const StringPool::Ref& path);
bool flatten(android::Res_value& outValue) const override; bool flatten(android::Res_value& outValue) const override;
FileReference* clone(StringPool* newPool) const override; FileReference* clone(StringPool* newPool) const override;
@ -199,7 +199,7 @@ struct BinaryPrimitive : public BaseItem<BinaryPrimitive> {
android::Res_value value; android::Res_value value;
BinaryPrimitive() = default; BinaryPrimitive() = default;
BinaryPrimitive(const android::Res_value& val); explicit BinaryPrimitive(const android::Res_value& val);
bool flatten(android::Res_value& outValue) const override; bool flatten(android::Res_value& outValue) const override;
BinaryPrimitive* clone(StringPool* newPool) const override; BinaryPrimitive* clone(StringPool* newPool) const override;
@ -218,7 +218,7 @@ struct Attribute : public BaseValue<Attribute> {
uint32_t maxInt; uint32_t maxInt;
std::vector<Symbol> symbols; std::vector<Symbol> symbols;
Attribute(bool w, uint32_t t = 0u); explicit Attribute(bool w, uint32_t t = 0u);
bool isWeak() const override; bool isWeak() const override;
virtual Attribute* clone(StringPool* newPool) const override; virtual Attribute* clone(StringPool* newPool) const override;
@ -388,7 +388,7 @@ template <typename T, typename TFunc>
struct ValueVisitorFunc : ValueVisitor { struct ValueVisitorFunc : ValueVisitor {
TFunc func; TFunc func;
ValueVisitorFunc(TFunc f) : func(f) { explicit ValueVisitorFunc(TFunc f) : func(f) {
} }
void visit(T& value, ValueVisitorArgs&) override { void visit(T& value, ValueVisitorArgs&) override {
@ -403,7 +403,7 @@ template <typename T, typename TFunc>
struct ConstValueVisitorFunc : ConstValueVisitor { struct ConstValueVisitorFunc : ConstValueVisitor {
TFunc func; TFunc func;
ConstValueVisitorFunc(TFunc f) : func(f) { explicit ConstValueVisitorFunc(TFunc f) : func(f) {
} }
void visit(const T& value, ValueVisitorArgs&) override { void visit(const T& value, ValueVisitorArgs&) override {

View File

@ -47,7 +47,7 @@ namespace aapt {
*/ */
class ScopedXmlPullParser : public XmlPullParser { class ScopedXmlPullParser : public XmlPullParser {
public: public:
ScopedXmlPullParser(XmlPullParser* parser); explicit ScopedXmlPullParser(XmlPullParser* parser);
ScopedXmlPullParser(const ScopedXmlPullParser&) = delete; ScopedXmlPullParser(const ScopedXmlPullParser&) = delete;
ScopedXmlPullParser& operator=(const ScopedXmlPullParser&) = delete; ScopedXmlPullParser& operator=(const ScopedXmlPullParser&) = delete;
~ScopedXmlPullParser(); ~ScopedXmlPullParser();

View File

@ -48,7 +48,7 @@ static bool lessEntryId(const std::pair<uint16_t, size_t>& p, uint16_t entryId)
return p.first < entryId; return p.first < entryId;
} }
size_t findAttributeSdkLevel(ResourceId id) { size_t findAttributeSdkLevel(const ResourceId& id) {
if (id.packageId() != 0x01 && id.typeId() != 0x01) { if (id.packageId() != 0x01 && id.typeId() != 0x01) {
return 0; return 0;
} }

View File

@ -44,7 +44,7 @@ enum {
SDK_LOLLIPOP_MR1 = 22, SDK_LOLLIPOP_MR1 = 22,
}; };
size_t findAttributeSdkLevel(ResourceId id); size_t findAttributeSdkLevel(const ResourceId& id);
size_t findAttributeSdkLevel(const ResourceName& name); size_t findAttributeSdkLevel(const ResourceName& name);
} // namespace aapt } // namespace aapt

View File

@ -30,7 +30,7 @@ namespace aapt {
class SourceXmlPullParser : public XmlPullParser { class SourceXmlPullParser : public XmlPullParser {
public: public:
SourceXmlPullParser(std::istream& in); explicit SourceXmlPullParser(std::istream& in);
SourceXmlPullParser(const SourceXmlPullParser& rhs) = delete; SourceXmlPullParser(const SourceXmlPullParser& rhs) = delete;
~SourceXmlPullParser(); ~SourceXmlPullParser();

View File

@ -39,8 +39,8 @@ public:
BasicStringPiece(); BasicStringPiece();
BasicStringPiece(const BasicStringPiece<TChar>& str); BasicStringPiece(const BasicStringPiece<TChar>& str);
BasicStringPiece(const std::basic_string<TChar>& str); BasicStringPiece(const std::basic_string<TChar>& str); // NOLINT(implicit)
BasicStringPiece(const TChar* str); BasicStringPiece(const TChar* str); // NOLINT(implicit)
BasicStringPiece(const TChar* str, size_t len); BasicStringPiece(const TChar* str, size_t len);
BasicStringPiece<TChar>& operator=(const BasicStringPiece<TChar>& rhs); BasicStringPiece<TChar>& operator=(const BasicStringPiece<TChar>& rhs);

View File

@ -65,7 +65,7 @@ public:
private: private:
friend class StringPool; friend class StringPool;
Ref(Entry* entry); explicit Ref(Entry* entry);
Entry* mEntry; Entry* mEntry;
}; };
@ -88,7 +88,7 @@ public:
private: private:
friend class StringPool; friend class StringPool;
StyleRef(StyleEntry* entry); explicit StyleRef(StyleEntry* entry);
StyleEntry* mEntry; StyleEntry* mEntry;
}; };

View File

@ -46,7 +46,7 @@ struct TableFlattener {
bool useExtendedChunks = true; bool useExtendedChunks = true;
}; };
TableFlattener(Options options); explicit TableFlattener(Options options);
bool flatten(BigBuffer* out, const ResourceTable& table); bool flatten(BigBuffer* out, const ResourceTable& table);

View File

@ -311,7 +311,7 @@ Maybe<std::u16string> extractPackageFromNamespace(const std::u16string& namespac
* In the aapt namespace for lookup. * In the aapt namespace for lookup.
*/ */
inline ::std::ostream& operator<<(::std::ostream& out, 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); return f(out);
} }

View File

@ -30,7 +30,7 @@ namespace aapt {
*/ */
class XliffXmlPullParser : public XmlPullParser { class XliffXmlPullParser : public XmlPullParser {
public: public:
XliffXmlPullParser(const std::shared_ptr<XmlPullParser>& parser); explicit XliffXmlPullParser(const std::shared_ptr<XmlPullParser>& parser);
XliffXmlPullParser(const XliffXmlPullParser& rhs) = delete; XliffXmlPullParser(const XliffXmlPullParser& rhs) = delete;
Event getEvent() const override; Event getEvent() const override;

View File

@ -52,7 +52,7 @@ struct Node {
std::u16string comment; std::u16string comment;
std::vector<std::unique_ptr<Node>> children; std::vector<std::unique_ptr<Node>> children;
Node(NodeType type); explicit Node(NodeType type);
void addChild(std::unique_ptr<Node> child); void addChild(std::unique_ptr<Node> child);
virtual std::unique_ptr<Node> clone() const = 0; virtual std::unique_ptr<Node> clone() const = 0;
virtual void accept(Visitor* visitor) = 0; virtual void accept(Visitor* visitor) = 0;
@ -65,7 +65,7 @@ struct Node {
*/ */
template <typename Derived> template <typename Derived>
struct BaseNode : public Node { struct BaseNode : public Node {
BaseNode(NodeType t); explicit BaseNode(NodeType t);
virtual void accept(Visitor* visitor) override; virtual void accept(Visitor* visitor) override;
}; };