diff options
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 6d95adc..53bf69f 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -452,13 +452,13 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { if (CGM.getCodeGenOpts().EmitDeclMetadata) EmitDeclMetadata(); - for (SmallVectorImpl<std::pair<llvm::Instruction *, llvm::Value *> >::iterator - I = DeferredReplacements.begin(), - E = DeferredReplacements.end(); - I != E; ++I) { - I->first->replaceAllUsesWith(I->second); - I->first->eraseFromParent(); + for (const auto &R : DeferredReplacements) { + if (llvm::Value *Old = R.first) { + Old->replaceAllUsesWith(R.second); + cast<llvm::Instruction>(Old)->eraseFromParent(); + } } + DeferredReplacements.clear(); // Eliminate CleanupDestSlot alloca by replacing it with SSA values and // PHIs if the current function is a coroutine. We don't do it for all |