From: Duncan P. N. Exon Smith Date: Thu, 11 Aug 2016 15:45:04 +0000 (+0000) Subject: IR: Don't cast the end iterator to Instruction* X-Git-Tag: llvmorg-4.0.0-rc1~12749 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=43724649c3460ce5e748e8cf4af743fb9eda2195;p=platform%2Fupstream%2Fllvm.git IR: Don't cast the end iterator to Instruction* End iterators are usually sentinels, not actually Instruction* at all. Stop casting to it just to get an iterator back. There is likely no observable functionality change here right now (although this is relying on UB, I doubt it was triggering anything), but I'll be removing the cast soon. llvm-svn: 278346 --- diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 3c4b0cf..4c946a6 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -2410,8 +2410,8 @@ LLVMBuilderRef LLVMCreateBuilder(void) { void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, LLVMValueRef Instr) { BasicBlock *BB = unwrap(Block); - Instruction *I = Instr? unwrap(Instr) : (Instruction*) BB->end(); - unwrap(Builder)->SetInsertPoint(BB, I->getIterator()); + auto I = Instr ? unwrap(Instr)->getIterator() : BB->end(); + unwrap(Builder)->SetInsertPoint(BB, I); } void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr) {