Add an assertion for a likely ilist::splice() contract violation.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 18 Dec 2012 19:28:37 +0000 (19:28 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 18 Dec 2012 19:28:37 +0000 (19:28 +0000)
commitb8d29bf2e41daa0800c9922b1eb59f8ac2efe192
treee1ff905ff47a8003f880953e84b0396d89b0b15c
parent0126132e2f309a03104e8384586f407160446452
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.

llvm-svn: 170443
llvm/include/llvm/ADT/ilist.h
llvm/unittests/ADT/ilistTest.cpp