projects
/
platform
/
upstream
/
llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a2d76bc
)
Add asserts to SmallVector so that calls to front() and back() only succeed
author
Richard Trieu
<rtrieu@google.com>
Thu, 24 Jan 2013 04:29:24 +0000
(
04:29
+0000)
committer
Richard Trieu
<rtrieu@google.com>
Thu, 24 Jan 2013 04:29:24 +0000
(
04:29
+0000)
if the vector is not empty. This will ensure that calls to these functions
will reference elements in the vector.
llvm-svn: 173321
llvm/include/llvm/ADT/SmallVector.h
patch
|
blob
|
history
diff --git
a/llvm/include/llvm/ADT/SmallVector.h
b/llvm/include/llvm/ADT/SmallVector.h
index
951e574
..
9167f87
100644
(file)
--- a/
llvm/include/llvm/ADT/SmallVector.h
+++ b/
llvm/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];
}
};