Add asserts to SmallVector so that calls to front() and back() only succeed

if the vector is not empty.  This will ensure that calls to these functions
will reference elements in the vector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173321 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Richard Trieu 2013-01-24 04:29:24 +00:00
parent 8453b3f66a
commit 0ac7e6f293

View File

@ -145,16 +145,20 @@ public:
}
reference front() {
assert(!empty());
return begin()[0];
}
const_reference front() const {
assert(!empty());
return begin()[0];
}
reference back() {
assert(!empty());
return end()[-1];
}
const_reference back() const {
assert(!empty());
return end()[-1];
}
};