-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[Clang][NFC] Avoid copies by using std::move #146960
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
Conversation
Static analysis flagged this code as using copies when we could use move instead.
|
@llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: Shafik Yaghmour (shafik) ChangesStatic analysis flagged this code as using copies when we could use move instead. I used a temporary in some cases instead of an explicit move. Full diff: https://github.com/llvm/llvm-project/pull/146960.diff 2 Files Affected:
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1a87608e5be34..21b97102db95a 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -6404,7 +6404,7 @@ class SpirvOperand {
SpirvOperand() : Kind(Invalid), ResultType(), Value() {}
SpirvOperand(SpirvOperandKind Kind, QualType ResultType, llvm::APInt Value)
- : Kind(Kind), ResultType(ResultType), Value(Value) {}
+ : Kind(Kind), ResultType(ResultType), Value(std::move(Value)) {}
SpirvOperand(const SpirvOperand &Other) { *this = Other; }
~SpirvOperand() {}
@@ -6438,11 +6438,11 @@ class SpirvOperand {
}
static SpirvOperand createConstant(QualType ResultType, llvm::APInt Val) {
- return SpirvOperand(ConstantId, ResultType, Val);
+ return SpirvOperand(ConstantId, ResultType, std::move(Val));
}
static SpirvOperand createLiteral(llvm::APInt Val) {
- return SpirvOperand(Literal, QualType(), Val);
+ return SpirvOperand(Literal, QualType(), std::move(Val));
}
static SpirvOperand createType(QualType T) {
diff --git a/clang/lib/CodeGen/Targets/SPIR.cpp b/clang/lib/CodeGen/Targets/SPIR.cpp
index 845b0f4b58461..a66de79ed7cd1 100644
--- a/clang/lib/CodeGen/Targets/SPIR.cpp
+++ b/clang/lib/CodeGen/Targets/SPIR.cpp
@@ -421,14 +421,12 @@ static llvm::Type *getInlineSpirvType(CodeGenModule &CGM,
case SpirvOperandKind::ConstantId: {
llvm::Type *IntegralType =
CGM.getTypes().ConvertType(Operand.getResultType());
- llvm::APInt Value = Operand.getValue();
- Result = getInlineSpirvConstant(CGM, IntegralType, Value);
+ Result = getInlineSpirvConstant(CGM, IntegralType, Operand.getValue());
break;
}
case SpirvOperandKind::Literal: {
- llvm::APInt Value = Operand.getValue();
- Result = getInlineSpirvConstant(CGM, nullptr, Value);
+ Result = getInlineSpirvConstant(CGM, nullptr, Operand.getValue());
break;
}
case SpirvOperandKind::TypeId: {
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/88/builds/13648 Here is the relevant piece of the build log for the reference |
Static analysis flagged this code as using copies when we could use move instead. I used a temporary in some cases instead of an explicit move.