diff --git a/clang/lib/Frontend/DiagnosticRenderer.cpp b/clang/lib/Frontend/DiagnosticRenderer.cpp index 4cd7d982ed0ec..18c8be7a72936 100644 --- a/clang/lib/Frontend/DiagnosticRenderer.cpp +++ b/clang/lib/Frontend/DiagnosticRenderer.cpp @@ -494,10 +494,8 @@ static bool checkRangesForMacroArgExpansion(FullSourceLoc Loc, mapDiagnosticRanges(Loc, Ranges, SpellingRanges); // Count all valid ranges. - unsigned ValidCount = 0; - for (const auto &Range : Ranges) - if (Range.isValid()) - ValidCount++; + unsigned ValidCount = + llvm::count_if(Ranges, [](const auto &R) { return R.isValid(); }); if (ValidCount > SpellingRanges.size()) return false;