summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-06-08 16:00:02 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-06-08 16:00:02 +0000
commit789df06f876b5cc5ccd940ed76cb0b25f2fdb585 (patch)
tree81639a40807c8f2a134d6243b573257de6612818 /llvm/include
parent8804e5cb499ab48ede014515f59cb557810ec29a (diff)
downloadbcm5719-llvm-789df06f876b5cc5ccd940ed76cb0b25f2fdb585.tar.gz
bcm5719-llvm-789df06f876b5cc5ccd940ed76cb0b25f2fdb585.zip
Ensure SmallVector::insert doesn't overwrite the last element in the range with the already-moved-from value
This would cause the last element in a range to be in a moved-from state after an insert at a non-end position, losing that value entirely in the process. Side note: move_backward is subtle. It copies [A, B) to C-1 and down. (the fact that it decrements both the second and third iterators before the first movement is the subtle part... kind of surprising, anyway) llvm-svn: 210426
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/ADT/SmallVector.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index dcf0354860f..29ad250010e 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -488,9 +488,9 @@ public:
}
::new ((void*) this->end()) T(::std::move(this->back()));
- this->setEnd(this->end()+1);
// Push everything else over.
this->move_backward(I, this->end()-1, this->end());
+ this->setEnd(this->end()+1);
// If we just moved the element we're inserting, be sure to update
// the reference.
OpenPOWER on IntegriCloud