[clang] [Clang][NFC] Use temporary instead of one use local variable when creating APValue (PR #137029)

via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 23 11:00:49 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Shafik Yaghmour (shafik)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/137029.diff


1 Files Affected:

- (modified) clang/lib/Sema/SemaExprCXX.cpp (+2-3) 


``````````diff
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:

``````````

</details>


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


More information about the cfe-commits mailing list