[llvm-branch-commits] [clang] 1d8568c - [CIR][NFC] Fix copy constructed AP real and imag values (#159935)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Sep 23 08:57:56 PDT 2025
Author: Amr Hesham
Date: 2025-09-23T16:52:04+02:00
New Revision: 1d8568c96ce86be57aba88d5f23b06ba547ba224
URL: https://github.com/llvm/llvm-project/commit/1d8568c96ce86be57aba88d5f23b06ba547ba224
DIFF: https://github.com/llvm/llvm-project/commit/1d8568c96ce86be57aba88d5f23b06ba547ba224.diff
LOG: [CIR][NFC] Fix copy constructed AP real and imag values (#159935)
Fix warning about copy-constructed APInt & APFloat values
Added:
Modified:
clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
Removed:
################################################################################
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
index f660544d13cfa..178b276f19d41 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
@@ -1464,25 +1464,24 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &value,
case APValue::ComplexInt:
case APValue::ComplexFloat: {
mlir::Type desiredType = cgm.convertType(destType);
- cir::ComplexType complexType =
- mlir::dyn_cast<cir::ComplexType>(desiredType);
+ auto complexType = mlir::dyn_cast<cir::ComplexType>(desiredType);
mlir::Type complexElemTy = complexType.getElementType();
if (isa<cir::IntType>(complexElemTy)) {
- llvm::APSInt real = value.getComplexIntReal();
- llvm::APSInt imag = value.getComplexIntImag();
- return builder.getAttr<cir::ConstComplexAttr>(
- complexType, cir::IntAttr::get(complexElemTy, real),
- cir::IntAttr::get(complexElemTy, imag));
+ const llvm::APSInt &real = value.getComplexIntReal();
+ const llvm::APSInt &imag = value.getComplexIntImag();
+ return cir::ConstComplexAttr::get(builder.getContext(), complexType,
+ cir::IntAttr::get(complexElemTy, real),
+ cir::IntAttr::get(complexElemTy, imag));
}
assert(isa<cir::FPTypeInterface>(complexElemTy) &&
"expected floating-point type");
- llvm::APFloat real = value.getComplexFloatReal();
- llvm::APFloat imag = value.getComplexFloatImag();
- return builder.getAttr<cir::ConstComplexAttr>(
- complexType, cir::FPAttr::get(complexElemTy, real),
- cir::FPAttr::get(complexElemTy, imag));
+ const llvm::APFloat &real = value.getComplexFloatReal();
+ const llvm::APFloat &imag = value.getComplexFloatImag();
+ return cir::ConstComplexAttr::get(builder.getContext(), complexType,
+ cir::FPAttr::get(complexElemTy, real),
+ cir::FPAttr::get(complexElemTy, imag));
}
case APValue::FixedPoint:
case APValue::AddrLabelDiff:
More information about the llvm-branch-commits
mailing list