[llvm] r278346 - IR: Don't cast the end iterator to Instruction*
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 11 08:45:05 PDT 2016
Author: dexonsmith
Date: Thu Aug 11 10:45:04 2016
New Revision: 278346
URL: http://llvm.org/viewvc/llvm-project?rev=278346&view=rev
Log:
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.
Modified:
llvm/trunk/lib/IR/Core.cpp
Modified: llvm/trunk/lib/IR/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=278346&r1=278345&r2=278346&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Core.cpp (original)
+++ llvm/trunk/lib/IR/Core.cpp Thu Aug 11 10:45:04 2016
@@ -2410,8 +2410,8 @@ LLVMBuilderRef LLVMCreateBuilder(void) {
void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
LLVMValueRef Instr) {
BasicBlock *BB = unwrap(Block);
- Instruction *I = Instr? unwrap<Instruction>(Instr) : (Instruction*) BB->end();
- unwrap(Builder)->SetInsertPoint(BB, I->getIterator());
+ auto I = Instr ? unwrap<Instruction>(Instr)->getIterator() : BB->end();
+ unwrap(Builder)->SetInsertPoint(BB, I);
}
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr) {
More information about the llvm-commits
mailing list