================
@@ -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(
----------------
AaronBallman 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.

We're consistently inconsistent because folks will slip them in from time to 
time, but I concur with the review feedback; drop top-level `const` on anything 
that's not a data member. The reason is: very little of the code base is 
`const` correct (we're slowly trying to improve that) and we have plenty of 
`const_cast` use in the code base. So declaring the object as actually `const` 
is in danger of accidentally turning that into UB (whereas leaving it 
non-`const` means we still have a maintenance task to attend to, but at least 
it's not turned into a bug).

https://github.com/llvm/llvm-project/pull/169938
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to