summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/ilist.h
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-12-18 19:28:37 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-12-18 19:28:37 +0000
commit7f1d6d688f6ae288a16a4151e8a27b518d97f6f7 (patch)
treeb977f1037a24e59cbdac295171732a9325fc366e /include/llvm/ADT/ilist.h
parent0ef0e2e6d0a45cdbc792eee9d76f0a4b7cda5c8f (diff)
downloadllvm-7f1d6d688f6ae288a16a4151e8a27b518d97f6f7.tar.gz
llvm-7f1d6d688f6ae288a16a4151e8a27b518d97f6f7.tar.bz2
llvm-7f1d6d688f6ae288a16a4151e8a27b518d97f6f7.tar.xz
Add an assertion for a likely ilist::splice() contract violation.
The single-element ilist::splice() function supports a noop move: List.splice(I, List, I); The corresponding std::list function doesn't allow that, so add a unit test to document that behavior. This also means that List.splice(I, List, F); is somewhat surprisingly not equivalent to List.splice(I, List, F, next(F)); This patch adds an assertion to catch the illegal case I == F above. Alternatively, we could make I == F a legal noop, but that would make ilist differ even more from std::list. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170443 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/ilist.h')
-rw-r--r--include/llvm/ADT/ilist.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/llvm/ADT/ilist.h b/include/llvm/ADT/ilist.h
index 7f5cd17181..36650d4375 100644
--- a/include/llvm/ADT/ilist.h
+++ b/include/llvm/ADT/ilist.h
@@ -472,6 +472,10 @@ private:
//
void transfer(iterator position, iplist &L2, iterator first, iterator last) {
assert(first != last && "Should be checked by callers");
+ // Position cannot be contained in the range to be transferred.
+ // Check for the most common mistake.
+ assert(position != first &&
+ "Insertion point can't be one of the transferred nodes");
if (position != last) {
// Note: we have to be careful about the case when we move the first node