ObjCARC: do not increment past the end of the BB
authorSaleem Abdulrasool <compnerd@compnerd.org>
Tue, 24 Oct 2017 00:09:10 +0000 (00:09 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Tue, 24 Oct 2017 00:09:10 +0000 (00:09 +0000)
commit619b3269fdaffbcb298c4d7b33cda7109a2082d6
treec5f75291d6ed989795f57eabeb6c9a7acb5ac999
parent3d64d6ee54041e110c94a3bacc8ae1dc8114c9df
ObjCARC: do not increment past the end of the BB

The `BasicBlock::getFirstInsertionPt` call may return `std::end` for the
BB.  Dereferencing the end iterator results in an assertion failure
"(!NodePtr->isKnownSentinel()), function operator*".  Ensure that the
returned iterator is valid before dereferencing it.  If the end is
returned, move one position backward to get a valid insertion point.

llvm-svn: 316401
llvm/lib/Transforms/ObjCARC/PtrState.cpp
llvm/test/Transforms/ObjCARC/invoke-2.ll [new file with mode: 0644]