[clang] [Clang][NFC] Use temporary instead of one use local variable when creating APValue (PR #137029)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 23 11:00:18 PDT 2025
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.yaghmour at 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:
More information about the cfe-commits
mailing list