-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang][NFC] Use temporary instead of one use local variable when creating APValue #137029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clang][NFC] Use temporary instead of one use local variable when creating APValue #137029
Conversation
…ating 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.
@llvm/pr-subscribers-clang Author: Shafik Yaghmour (shafik) ChangesStatic 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:
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:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…ating APValue (llvm#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.
…ating APValue (llvm#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.
…ating APValue (llvm#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.
…ating APValue (llvm#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.
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.