[clang] dff6aee - [clang][NFC] Call Stmt::getBeginLoc() once in DiagnoseForRangeVariable (#141472)

via cfe-commits cfe-commits at lists.llvm.org
Mon May 26 04:46:15 PDT 2025


Author: Timm Baeder
Date: 2025-05-26T13:46:12+02:00
New Revision: dff6aee94597fda742c41390b1890a5434215dec

URL: https://github.com/llvm/llvm-project/commit/dff6aee94597fda742c41390b1890a5434215dec
DIFF: https://github.com/llvm/llvm-project/commit/dff6aee94597fda742c41390b1890a5434215dec.diff

LOG: [clang][NFC] Call Stmt::getBeginLoc() once in DiagnoseForRangeVariable (#141472)

...Copies. Instead of three times.

Added: 
    

Modified: 
    clang/lib/Sema/SemaStmt.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index ed070649dc1f9..c943645c3ab9d 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3172,13 +3172,11 @@ static void DiagnoseForRangeVariableCopies(Sema &SemaRef,
   if (SemaRef.inTemplateInstantiation())
     return;
 
+  SourceLocation Loc = ForStmt->getBeginLoc();
   if (SemaRef.Diags.isIgnored(
-          diag::warn_for_range_const_ref_binds_temp_built_from_ref,
-          ForStmt->getBeginLoc()) &&
-      SemaRef.Diags.isIgnored(diag::warn_for_range_ref_binds_ret_temp,
-                              ForStmt->getBeginLoc()) &&
-      SemaRef.Diags.isIgnored(diag::warn_for_range_copy,
-                              ForStmt->getBeginLoc())) {
+          diag::warn_for_range_const_ref_binds_temp_built_from_ref, Loc) &&
+      SemaRef.Diags.isIgnored(diag::warn_for_range_ref_binds_ret_temp, Loc) &&
+      SemaRef.Diags.isIgnored(diag::warn_for_range_copy, Loc)) {
     return;
   }
 


        


More information about the cfe-commits mailing list