aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2013-01-24 04:29:24 +0000
committerRichard Trieu <rtrieu@google.com>2013-01-24 04:29:24 +0000
commit0ac7e6f293bc502b39005496d2160b0089d3fa46 (patch)
treec428db8b20cb732667d7d1c9e51599cee6c52f2f
parent8453b3f66a3c3200ea828491ef5cf162db9ccfb2 (diff)
downloadexternal_llvm-0ac7e6f293bc502b39005496d2160b0089d3fa46.zip
external_llvm-0ac7e6f293bc502b39005496d2160b0089d3fa46.tar.gz
external_llvm-0ac7e6f293bc502b39005496d2160b0089d3fa46.tar.bz2
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
-rw-r--r--include/llvm/ADT/SmallVector.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h
index 951e574..9167f87 100644
--- a/include/llvm/ADT/SmallVector.h
+++ b/include/llvm/ADT/SmallVector.h
@@ -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];
}
};