From ec7802a102d49ab5c17495118d4fe0bcc7287beb Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 1 Oct 2015 20:57:57 +0100 Subject: 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 --- compiler/dwarf/writer.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'compiler/dwarf/writer.h') 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> +template > class Writer { + static_assert(std::is_same::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 - void PushData(const std::vector* buffer) { + template + void PushData(const Vector2* buffer) { + static_assert(std::is_same::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* data() const { + const Vector* data() const { return data_; } - explicit Writer(std::vector* buffer) : data_(buffer) { } + explicit Writer(Vector* buffer) : data_(buffer) { } private: - std::vector* data_; + Vector* const data_; DISALLOW_COPY_AND_ASSIGN(Writer); }; -- cgit v1.2.3-59-g8ed1b