Fix clang errors in ArenaAllocator.
Change-Id: Ib0fa290fd46ff9288f86cda9be2d1c1faf99b964
diff --git a/compiler/utils/arena_allocator.cc b/compiler/utils/arena_allocator.cc
index 365b094..ca4635d 100644
--- a/compiler/utils/arena_allocator.cc
+++ b/compiler/utils/arena_allocator.cc
@@ -31,7 +31,8 @@
static constexpr size_t kValgrindRedZoneBytes = 8;
constexpr size_t Arena::kDefaultSize;
-static const char* alloc_names[kNumArenaAllocKinds] = {
+template <bool kCount>
+const char* ArenaAllocatorStatsImpl<kCount>::kAllocNames[kNumArenaAllocKinds] = {
"Misc ",
"BasicBlock ",
"LIR ",
@@ -94,14 +95,14 @@
const size_t bytes_allocated = BytesAllocated();
os << " MEM: used: " << bytes_allocated << ", allocated: " << malloc_bytes
<< ", lost: " << lost_bytes << "\n";
- size_t num_allocations = ArenaAllocatorStats::NumAllocations();
+ size_t num_allocations = NumAllocations();
if (num_allocations != 0) {
os << "Number of arenas allocated: " << num_arenas << ", Number of allocations: "
<< num_allocations << ", avg size: " << bytes_allocated / num_allocations << "\n";
}
os << "===== Allocation by kind\n";
for (int i = 0; i < kNumArenaAllocKinds; i++) {
- os << alloc_names[i] << std::setw(10) << alloc_stats_[i] << "\n";
+ os << kAllocNames[i] << std::setw(10) << alloc_stats_[i] << "\n";
}
}
diff --git a/compiler/utils/arena_allocator.h b/compiler/utils/arena_allocator.h
index a6b74f7..18a5bce 100644
--- a/compiler/utils/arena_allocator.h
+++ b/compiler/utils/arena_allocator.h
@@ -90,6 +90,8 @@
size_t num_allocations_;
// TODO: Use std::array<size_t, kNumArenaAllocKinds> from C++11 when we upgrade the STL.
size_t alloc_stats_[kNumArenaAllocKinds]; // Bytes used by various allocation kinds.
+
+ static const char* kAllocNames[kNumArenaAllocKinds];
};
typedef ArenaAllocatorStatsImpl<kArenaAllocatorCountAllocations> ArenaAllocatorStats;