idmap2: fix clang-tidy warnings [misc-*]
Bug: 120024673
Test: mmm frameworks/base/cmds/idmap2; check output
Change-Id: I48c1cf25d2f1cf243dca67ec9d7e8fd50e6f9f32
diff --git a/cmds/idmap2/libidmap2/Idmap.cpp b/cmds/idmap2/libidmap2/Idmap.cpp
index 1ef3267..49bb7d8 100644
--- a/cmds/idmap2/libidmap2/Idmap.cpp
+++ b/cmds/idmap2/libidmap2/Idmap.cpp
@@ -43,17 +43,23 @@
#define EXTRACT_ENTRY(resid) (0x0000ffff & (resid))
-struct MatchingResources {
+class MatchingResources {
+ public:
void Add(ResourceId target_resid, ResourceId overlay_resid) {
TypeId target_typeid = EXTRACT_TYPE(target_resid);
- if (map.find(target_typeid) == map.end()) {
- map.emplace(target_typeid, std::set<std::pair<ResourceId, ResourceId>>());
+ if (map_.find(target_typeid) == map_.end()) {
+ map_.emplace(target_typeid, std::set<std::pair<ResourceId, ResourceId>>());
}
- map[target_typeid].insert(std::make_pair(target_resid, overlay_resid));
+ map_[target_typeid].insert(std::make_pair(target_resid, overlay_resid));
}
+ inline const std::map<TypeId, std::set<std::pair<ResourceId, ResourceId>>>& Map() const {
+ return map_;
+ }
+
+ private:
// target type id -> set { pair { overlay entry id, overlay entry id } }
- std::map<TypeId, std::set<std::pair<ResourceId, ResourceId>>> map;
+ std::map<TypeId, std::set<std::pair<ResourceId, ResourceId>>> map_;
};
static bool WARN_UNUSED Read16(std::istream& stream, uint16_t* out) {
@@ -375,8 +381,8 @@
// encode idmap data
std::unique_ptr<IdmapData> data(new IdmapData());
- const auto types_end = matching_resources.map.cend();
- for (auto ti = matching_resources.map.cbegin(); ti != types_end; ++ti) {
+ const auto types_end = matching_resources.Map().cend();
+ for (auto ti = matching_resources.Map().cbegin(); ti != types_end; ++ti) {
auto ei = ti->second.cbegin();
std::unique_ptr<IdmapData::TypeEntry> type(new IdmapData::TypeEntry());
type->target_type_id_ = EXTRACT_TYPE(ei->first);
diff --git a/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp b/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
index 8b552dc..7d2e8ee 100644
--- a/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
+++ b/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
@@ -29,7 +29,6 @@
#include "TestHelpers.h"
-using ::testing::IsNull;
using ::testing::NotNull;
namespace android {
diff --git a/cmds/idmap2/tests/CommandLineOptionsTests.cpp b/cmds/idmap2/tests/CommandLineOptionsTests.cpp
index b04b256..7d1f56b 100644
--- a/cmds/idmap2/tests/CommandLineOptionsTests.cpp
+++ b/cmds/idmap2/tests/CommandLineOptionsTests.cpp
@@ -38,8 +38,6 @@
#include "TestHelpers.h"
-using ::testing::NotNull;
-
namespace android {
namespace idmap2 {
diff --git a/cmds/idmap2/tests/PrettyPrintVisitorTests.cpp b/cmds/idmap2/tests/PrettyPrintVisitorTests.cpp
index da97792..0c4f493 100644
--- a/cmds/idmap2/tests/PrettyPrintVisitorTests.cpp
+++ b/cmds/idmap2/tests/PrettyPrintVisitorTests.cpp
@@ -29,7 +29,6 @@
#include "TestHelpers.h"
-using ::testing::IsNull;
using ::testing::NotNull;
using android::ApkAssets;
diff --git a/cmds/idmap2/tests/RawPrintVisitorTests.cpp b/cmds/idmap2/tests/RawPrintVisitorTests.cpp
index c28ce2e..6285f21 100644
--- a/cmds/idmap2/tests/RawPrintVisitorTests.cpp
+++ b/cmds/idmap2/tests/RawPrintVisitorTests.cpp
@@ -27,7 +27,6 @@
#include "TestHelpers.h"
-using ::testing::IsNull;
using ::testing::NotNull;
namespace android {