summaryrefslogtreecommitdiff
path: root/compiler/dwarf/writer.h
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2015-10-01 20:57:57 +0100
committer Vladimir Marko <vmarko@google.com> 2015-10-08 11:10:18 +0100
commitec7802a102d49ab5c17495118d4fe0bcc7287beb (patch)
tree08649609604b9c96bc48ca071c48b0af5abb1a3f /compiler/dwarf/writer.h
parentb2e436ffcda1d7a87e7bf9133d8ed878388c73c2 (diff)
Add DCHECKs to ArenaVector and ScopedArenaVector.
Implement dchecked_vector<> template that DCHECK()s element access and insert()/emplace()/erase() positions. Change the ArenaVector<> and ScopedArenaVector<> aliases to use the new template instead of std::vector<>. Remove DCHECK()s that have now become unnecessary from the Optimizing compiler. Change-Id: Ib8506bd30d223f68f52bd4476c76d9991acacadc
Diffstat (limited to 'compiler/dwarf/writer.h')
-rw-r--r--compiler/dwarf/writer.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/dwarf/writer.h b/compiler/dwarf/writer.h
index e703aeea2d..42c32c4303 100644
--- a/compiler/dwarf/writer.h
+++ b/compiler/dwarf/writer.h
@@ -26,8 +26,10 @@ namespace art {
namespace dwarf {
// The base class for all DWARF writers.
-template<typename Allocator = std::allocator<uint8_t>>
+template <typename Vector = std::vector<uint8_t>>
class Writer {
+ static_assert(std::is_same<typename Vector::value_type, uint8_t>::value, "Invalid value type");
+
public:
void PushUint8(int value) {
DCHECK_GE(value, 0);
@@ -116,8 +118,9 @@ class Writer {
data_->insert(data_->end(), p, p + size);
}
- template<typename Allocator2>
- void PushData(const std::vector<uint8_t, Allocator2>* buffer) {
+ template<typename Vector2>
+ void PushData(const Vector2* buffer) {
+ static_assert(std::is_same<typename Vector2::value_type, uint8_t>::value, "Invalid value type");
data_->insert(data_->end(), buffer->begin(), buffer->end());
}
@@ -155,14 +158,14 @@ class Writer {
data_->resize(RoundUp(data_->size(), alignment), 0);
}
- const std::vector<uint8_t, Allocator>* data() const {
+ const Vector* data() const {
return data_;
}
- explicit Writer(std::vector<uint8_t, Allocator>* buffer) : data_(buffer) { }
+ explicit Writer(Vector* buffer) : data_(buffer) { }
private:
- std::vector<uint8_t, Allocator>* data_;
+ Vector* const data_;
DISALLOW_COPY_AND_ASSIGN(Writer);
};