[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 08:56:37 PST 2025


================
@@ -2547,8 +2547,8 @@ static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl,
                  diag::ext_constexpr_function_never_constant_expr)
         << isa<CXXConstructorDecl>(Dcl) << Dcl->isConsteval()
         << Dcl->getNameInfo().getSourceRange();
-    for (size_t I = 0, N = Diags.size(); I != N; ++I)
-      SemaRef.Diag(Diags[I].first, Diags[I].second);
+    for (const auto &Diag : Diags)
+      SemaRef.Diag(Diag.first, Diag.second);
----------------
davidstone wrote:

I'm not opposed to that, but I think the better fix would be to fix the underlying value_type to be a struct with proper names instead of a `std::pair`. I don't really have the context here to know what the right name is for all these variables.

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


More information about the cfe-commits mailing list