Fix up TODO: c++0x, update cpplint.
Needed to update cpplint to handle const auto.
Fixed a few cpplint errors that were being missed before.
Replaced most of the TODO c++0x with ranged based loops. Loops which
do not have a descriptive container name have a concrete type instead
of auto.
Change-Id: Id7cc0f27030f56057c544e94277300b3f298c9c5
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index b8727fe..0ef0428 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -664,8 +664,7 @@
Thread* self = Thread::Current();
ScopedObjectAccess soa(self);
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
- typedef DescriptorSet::iterator It; // TODO: C++0x auto
- for (It it = image_classes_->begin(), end = image_classes_->end(); it != end;) {
+ for (auto it = image_classes_->begin(), end = image_classes_->end(); it != end;) {
std::string descriptor(*it);
SirtRef<mirror::Class> klass(self, class_linker->FindSystemClass(descriptor.c_str()));
if (klass.get() == NULL) {
@@ -687,12 +686,9 @@
unresolved_exception_types.clear();
class_linker->VisitClasses(ResolveCatchBlockExceptionsClassVisitor,
&unresolved_exception_types);
- typedef std::set<std::pair<uint16_t, const DexFile*> >::const_iterator It; // TODO: C++0x auto
- for (It it = unresolved_exception_types.begin(),
- end = unresolved_exception_types.end();
- it != end; ++it) {
- uint16_t exception_type_idx = it->first;
- const DexFile* dex_file = it->second;
+ for (const std::pair<uint16_t, const DexFile*>& exception_type : unresolved_exception_types) {
+ uint16_t exception_type_idx = exception_type.first;
+ const DexFile* dex_file = exception_type.second;
mirror::DexCache* dex_cache = class_linker->FindDexCache(*dex_file);
mirror:: ClassLoader* class_loader = NULL;
SirtRef<mirror::Class> klass(self, class_linker->ResolveType(*dex_file, exception_type_idx,
diff --git a/compiler/elf_fixup.cc b/compiler/elf_fixup.cc
index 6c090fd..359c493 100644
--- a/compiler/elf_fixup.cc
+++ b/compiler/elf_fixup.cc
@@ -80,7 +80,6 @@
#define DT_MIPS_RLD_MAP 0x70000016 // d_ptr
bool ElfFixup::FixupDynamic(ElfFile& elf_file, uintptr_t base_address) {
- // TODO: C++0x auto.
for (::llvm::ELF::Elf32_Word i = 0; i < elf_file.GetDynamicNum(); i++) {
::llvm::ELF::Elf32_Dyn& elf_dyn = elf_file.GetDynamic(i);
::llvm::ELF::Elf32_Word d_tag = elf_dyn.d_tag;
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc
index 4e9ae54..548ea9e 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -74,10 +74,7 @@
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
const std::vector<DexCache*>& all_dex_caches = class_linker->GetDexCaches();
- for (size_t i = 0; i < all_dex_caches.size(); i++) {
- DexCache* dex_cache = all_dex_caches[i];
- dex_caches_.insert(dex_cache);
- }
+ dex_caches_.insert(all_dex_caches.begin(), all_dex_caches.end());
UniquePtr<File> oat_file(OS::OpenFileReadWrite(oat_filename.c_str()));
if (oat_file.get() == NULL) {
@@ -117,11 +114,7 @@
gc::Heap* heap = Runtime::Current()->GetHeap();
heap->CollectGarbage(false); // Remove garbage.
// Trim size of alloc spaces.
- const std::vector<gc::space::ContinuousSpace*>& spaces = heap->GetContinuousSpaces();
- // TODO: C++0x auto
- typedef std::vector<gc::space::ContinuousSpace*>::const_iterator It;
- for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) {
- gc::space::ContinuousSpace* space = *it;
+ for (const auto& space : heap->GetContinuousSpaces()) {
if (space->IsDlMallocSpace()) {
space->AsDlMallocSpace()->Trim();
}
@@ -163,13 +156,8 @@
}
bool ImageWriter::AllocMemory() {
- gc::Heap* heap = Runtime::Current()->GetHeap();
- const std::vector<gc::space::ContinuousSpace*>& spaces = heap->GetContinuousSpaces();
size_t size = 0;
- // TODO: C++0x auto
- typedef std::vector<gc::space::ContinuousSpace*>::const_iterator It;
- for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) {
- gc::space::ContinuousSpace* space = *it;
+ for (const auto& space : Runtime::Current()->GetHeap()->GetContinuousSpaces()) {
if (space->IsDlMallocSpace()) {
size += space->Size();
}
@@ -203,9 +191,7 @@
String* string = obj->AsString();
const uint16_t* utf16_string = string->GetCharArray()->GetData() + string->GetOffset();
ImageWriter* writer = reinterpret_cast<ImageWriter*>(arg);
- typedef Set::const_iterator CacheIt; // TODO: C++0x auto
- for (CacheIt it = writer->dex_caches_.begin(), end = writer->dex_caches_.end(); it != end; ++it) {
- DexCache* dex_cache = *it;
+ for (DexCache* dex_cache : writer->dex_caches_) {
const DexFile& dex_file = *dex_cache->GetDexFile();
const DexFile::StringId* string_id = dex_file.FindStringId(utf16_string);
if (string_id != NULL) {
@@ -251,16 +237,13 @@
class_linker->VisitClasses(NonImageClassesVisitor, &context);
// Remove the undesired classes from the class roots.
- typedef std::set<std::string>::const_iterator ClassIt; // TODO: C++0x auto
- for (ClassIt it = non_image_classes.begin(), end = non_image_classes.end(); it != end; ++it) {
- class_linker->RemoveClass((*it).c_str(), NULL);
+ for (const std::string& it : non_image_classes) {
+ class_linker->RemoveClass(it.c_str(), NULL);
}
// Clear references to removed classes from the DexCaches.
ArtMethod* resolution_method = runtime->GetResolutionMethod();
- typedef Set::const_iterator CacheIt; // TODO: C++0x auto
- for (CacheIt it = dex_caches_.begin(), end = dex_caches_.end(); it != end; ++it) {
- DexCache* dex_cache = *it;
+ for (DexCache* dex_cache : dex_caches_) {
for (size_t i = 0; i < dex_cache->NumResolvedTypes(); i++) {
Class* klass = dex_cache->GetResolvedType(i);
if (klass != NULL && !IsImageClass(klass)) {
@@ -324,9 +307,8 @@
void ImageWriter::DumpImageClasses() {
CompilerDriver::DescriptorSet* image_classes = compiler_driver_.GetImageClasses();
CHECK(image_classes != NULL);
- typedef std::set<std::string>::const_iterator It; // TODO: C++0x auto
- for (It it = image_classes->begin(), end = image_classes->end(); it != end; ++it) {
- LOG(INFO) << " " << *it;
+ for (const std::string& image_class : *image_classes) {
+ LOG(INFO) << " " << image_class;
}
}
@@ -368,9 +350,8 @@
ObjectArray<Object>* dex_caches = ObjectArray<Object>::Alloc(self, object_array_class,
dex_caches_.size());
int i = 0;
- typedef Set::const_iterator It; // TODO: C++0x auto
- for (It it = dex_caches_.begin(), end = dex_caches_.end(); it != end; ++it, ++i) {
- dex_caches->Set(i, *it);
+ for (DexCache* dex_cache : dex_caches_) {
+ dex_caches->Set(i++, dex_cache);
}
// build an Object[] of the roots needed to restore the runtime
@@ -403,7 +384,7 @@
SirtRef<ObjectArray<Object> > image_roots(self, CreateImageRoots());
gc::Heap* heap = Runtime::Current()->GetHeap();
- const std::vector<gc::space::ContinuousSpace*>& spaces = heap->GetContinuousSpaces();
+ const auto& spaces = heap->GetContinuousSpaces();
DCHECK(!spaces.empty());
DCHECK_EQ(0U, image_end_);
@@ -418,10 +399,7 @@
// TODO: Add InOrderWalk to heap bitmap.
const char* old = self->StartAssertNoThreadSuspension("ImageWriter");
DCHECK(heap->GetLargeObjectsSpace()->GetLiveObjects()->IsEmpty());
- // TODO: C++0x auto
- typedef std::vector<gc::space::ContinuousSpace*>::const_iterator It;
- for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) {
- gc::space::ContinuousSpace* space = *it;
+ for (const auto& space : spaces) {
space->GetLiveBitmap()->InOrderWalk(CalculateNewObjectOffsetsCallback, this);
DCHECK_LT(image_end_, image_->Size());
}
diff --git a/compiler/image_writer.h b/compiler/image_writer.h
index 750109d..6a126b8 100644
--- a/compiler/image_writer.h
+++ b/compiler/image_writer.h
@@ -204,8 +204,7 @@
uint32_t quick_to_interpreter_bridge_offset_;
// DexCaches seen while scanning for fixing up CodeAndDirectMethods
- typedef std::set<mirror::DexCache*> Set;
- Set dex_caches_;
+ std::set<mirror::DexCache*> dex_caches_;
};
} // namespace art
diff --git a/compiler/sea_ir/ir/regions_test.cc b/compiler/sea_ir/ir/regions_test.cc
index 9813465..8ca51e4 100644
--- a/compiler/sea_ir/ir/regions_test.cc
+++ b/compiler/sea_ir/ir/regions_test.cc
@@ -56,4 +56,4 @@
EXPECT_EQ(root, preds->at(0));
}
-} // namespace art
+} // namespace sea_ir
diff --git a/compiler/sea_ir/types/type_data_test.cc b/compiler/sea_ir/types/type_data_test.cc
index a66ebce..f7a5362 100644
--- a/compiler/sea_ir/types/type_data_test.cc
+++ b/compiler/sea_ir/types/type_data_test.cc
@@ -38,4 +38,4 @@
EXPECT_TRUE(byte_type == td.FindTypeOf(second_instruction_id));
}
-} // namespace art
+} // namespace sea_ir
diff --git a/compiler/sea_ir/types/type_inference_visitor.cc b/compiler/sea_ir/types/type_inference_visitor.cc
index 3da2fc1..81a8f4d 100644
--- a/compiler/sea_ir/types/type_inference_visitor.cc
+++ b/compiler/sea_ir/types/type_inference_visitor.cc
@@ -78,9 +78,9 @@
const Type* TypeInferenceVisitor::MergeTypes(std::vector<const Type*>& types) const {
const Type* type = NULL;
- if (types.size()>0) {
+ if (types.size() > 0) {
type = *(types.begin());
- if (types.size()>1) {
+ if (types.size() > 1) {
for (std::vector<const Type*>::const_iterator cit = types.begin();
cit != types.end(); cit++) {
if (!type->Equals(**cit)) {
diff --git a/compiler/sea_ir/types/type_inference_visitor.h b/compiler/sea_ir/types/type_inference_visitor.h
index 200b9f0..4bdac38 100644
--- a/compiler/sea_ir/types/type_inference_visitor.h
+++ b/compiler/sea_ir/types/type_inference_visitor.h
@@ -61,7 +61,7 @@
std::vector<const Type*> GetOperandTypes(InstructionNode* instruction) const;
const Type* GetType() {
// TODO: Currently multiple defined types are not supported.
- if (crt_type_.size()>0) {
+ if (!crt_type_.empty()) {
const Type* single_type = crt_type_.at(0);
crt_type_.clear();
return single_type;
diff --git a/compiler/sea_ir/types/type_inference_visitor_test.cc b/compiler/sea_ir/types/type_inference_visitor_test.cc
index 8a249eb..77acb3d 100644
--- a/compiler/sea_ir/types/type_inference_visitor_test.cc
+++ b/compiler/sea_ir/types/type_inference_visitor_test.cc
@@ -130,4 +130,4 @@
}
-} // namespace art
+} // namespace sea_ir
diff --git a/compiler/utils/assembler.h b/compiler/utils/assembler.h
index 9d79002..c9be4ed 100644
--- a/compiler/utils/assembler.h
+++ b/compiler/utils/assembler.h
@@ -137,6 +137,7 @@
// Next in linked list of slow paths
SlowPath *next_;
+ private:
friend class AssemblerBuffer;
DISALLOW_COPY_AND_ASSIGN(SlowPath);
};