[clang][NFC] Use llvm::count_if instead of manual loop
authorTimm Bäder <tbaeder@redhat.com>
Sun, 14 May 2023 07:45:51 +0000 (09:45 +0200)
committerTimm Bäder <tbaeder@redhat.com>
Tue, 16 May 2023 13:35:05 +0000 (15:35 +0200)
clang/lib/Frontend/DiagnosticRenderer.cpp

index 4cd7d98..18c8be7 100644 (file)
@@ -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;