Skip to content

Commit 6efa366

Browse files
authored
[Clang][NFC] Avoid copies by using std::move (#146960)
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.
1 parent 659c810 commit 6efa366

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

clang/include/clang/AST/Type.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6404,7 +6404,7 @@ class SpirvOperand {
64046404
SpirvOperand() : Kind(Invalid), ResultType(), Value() {}
64056405

64066406
SpirvOperand(SpirvOperandKind Kind, QualType ResultType, llvm::APInt Value)
6407-
: Kind(Kind), ResultType(ResultType), Value(Value) {}
6407+
: Kind(Kind), ResultType(ResultType), Value(std::move(Value)) {}
64086408

64096409
SpirvOperand(const SpirvOperand &Other) { *this = Other; }
64106410
~SpirvOperand() {}
@@ -6438,11 +6438,11 @@ class SpirvOperand {
64386438
}
64396439

64406440
static SpirvOperand createConstant(QualType ResultType, llvm::APInt Val) {
6441-
return SpirvOperand(ConstantId, ResultType, Val);
6441+
return SpirvOperand(ConstantId, ResultType, std::move(Val));
64426442
}
64436443

64446444
static SpirvOperand createLiteral(llvm::APInt Val) {
6445-
return SpirvOperand(Literal, QualType(), Val);
6445+
return SpirvOperand(Literal, QualType(), std::move(Val));
64466446
}
64476447

64486448
static SpirvOperand createType(QualType T) {

clang/lib/CodeGen/Targets/SPIR.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,12 @@ static llvm::Type *getInlineSpirvType(CodeGenModule &CGM,
421421
case SpirvOperandKind::ConstantId: {
422422
llvm::Type *IntegralType =
423423
CGM.getTypes().ConvertType(Operand.getResultType());
424-
llvm::APInt Value = Operand.getValue();
425424

426-
Result = getInlineSpirvConstant(CGM, IntegralType, Value);
425+
Result = getInlineSpirvConstant(CGM, IntegralType, Operand.getValue());
427426
break;
428427
}
429428
case SpirvOperandKind::Literal: {
430-
llvm::APInt Value = Operand.getValue();
431-
Result = getInlineSpirvConstant(CGM, nullptr, Value);
429+
Result = getInlineSpirvConstant(CGM, nullptr, Operand.getValue());
432430
break;
433431
}
434432
case SpirvOperandKind::TypeId: {

0 commit comments

Comments
 (0)