diff --git a/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp b/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp index 05cae4b67d7e5..9be0eec7b73f3 100644 --- a/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp +++ b/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp @@ -189,11 +189,11 @@ class FunctionDifferenceEngine { // The returned reference is not permanently valid and should not be stored. BlockDiffCandidate &getOrCreateBlockDiffCandidate(const BasicBlock *LBB, const BasicBlock *RBB) { - auto It = BlockDiffCandidateIndices.find(LBB); + auto [It, Inserted] = + BlockDiffCandidateIndices.try_emplace(LBB, BlockDiffCandidates.size()); // Check if LBB already has a diff candidate - if (It == BlockDiffCandidateIndices.end()) { + if (Inserted) { // Add new one - BlockDiffCandidateIndices[LBB] = BlockDiffCandidates.size(); BlockDiffCandidates.push_back( {LBB, RBB, SmallDenseMap(), false}); return BlockDiffCandidates.back();