[clang] [clang][NFC] Use range-based for loop and algorithms in `SemaDeclCXX.cpp` (PR #169938)

David Stone via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 2 09:50:43 PST 2025


================
@@ -17969,13 +17949,9 @@ DeclResult Sema::ActOnTemplatedFriendTag(
 
   if (Invalid) return true;
 
-  bool isAllExplicitSpecializations = true;
-  for (unsigned I = TempParamLists.size(); I-- > 0; ) {
-    if (TempParamLists[I]->size()) {
-      isAllExplicitSpecializations = false;
-      break;
-    }
-  }
+  const bool isAllExplicitSpecializations = std::all_of(
----------------
davidstone wrote:

I can't find this in the coding standard and I can't find a Discourse topic about this. Is there documentation somewhere that I can read to get the justification for this? There are counter-examples in this same file (for instance, in `Sema::CheckShadowInheritedFields`) and it definitely helps my understanding to know a variable isn't mutated.

https://github.com/llvm/llvm-project/pull/169938


More information about the cfe-commits mailing list