https://github.com/shafik created 
https://github.com/llvm/llvm-project/pull/137029

Static analysis flagged this code b/c we should have been using std::move when 
passing by value since the value is not used anymore. In this case the simpler 
fix is just to use a temporary value as many of the other cases where we simply 
use MakeIntValue to then create an APValue result from it.

>From 6a7551c057843be12f6e26935b57c08666fa960f Mon Sep 17 00:00:00 2001
From: Shafik Yaghmour <shafik.yaghm...@intel.com>
Date: Wed, 23 Apr 2025 10:55:33 -0700
Subject: [PATCH] [Clang][NFC] Use temporary instead of one use local variable
 when creating APValue

Static analysis flagged this code b/c we should have been using std::move when
passing by value since the value is not used anymore. In this case the simpler
fix is just to use a temporary value as many of the other cases where we simply
use MakeIntValue to then create an APValue result from it.
---
 clang/lib/Sema/SemaExprCXX.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index f5a10e0db85ad..72edb72ceb600 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -6147,9 +6147,8 @@ static APValue EvaluateSizeTTypeTrait(Sema &S, TypeTrait 
Kind,
       S.Diag(KWLoc, diag::err_arg_is_not_destructurable) << T << ArgRange;
       return APValue();
     }
-    llvm::APSInt V =
-        S.getASTContext().MakeIntValue(*Size, S.getASTContext().getSizeType());
-    return APValue{V};
+    return APValue(
+        S.getASTContext().MakeIntValue(*Size, 
S.getASTContext().getSizeType()));
     break;
   }
   default:

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to