diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -1983,14 +1983,11 @@ continue; // Consider only the first mapping of the file for any given PID - bool PIDExists = false; auto Range = GlobalMMapInfo.equal_range(FileMMapInfo.first); - for (auto MI = Range.first; MI != Range.second; ++MI) { - if (MI->second.PID == FileMMapInfo.second.PID) { - PIDExists = true; - break; - } - } + bool PIDExists = llvm::any_of(make_range(Range), [&](const auto &MI) { + return MI.second.PID == FileMMapInfo.second.PID; + }); + if (PIDExists) continue; @@ -2014,8 +2011,7 @@ } auto Range = GlobalMMapInfo.equal_range(NameToUse); - for (auto I = Range.first; I != Range.second; ++I) { - MMapInfo &MMapInfo = I->second; + for (MMapInfo &MMapInfo : llvm::make_second_range(make_range(Range))) { if (BC->HasFixedLoadAddress && MMapInfo.MMapAddress) { // Check that the binary mapping matches one of the segments. bool MatchFound = llvm::any_of( diff --git a/bolt/lib/Profile/DataReader.cpp b/bolt/lib/Profile/DataReader.cpp --- a/bolt/lib/Profile/DataReader.cpp +++ b/bolt/lib/Profile/DataReader.cpp @@ -215,9 +215,9 @@ } }; auto Range = std::equal_range(Data.begin(), Data.end(), From, Compare()); - for (auto I = Range.first; I != Range.second; ++I) - if (I->From.Name != I->To.Name) - return *I; + for (const auto &RI : llvm::make_range(Range)) + if (RI.From.Name != RI.To.Name) + return RI; return make_error_code(llvm::errc::invalid_argument); }