[CIR][NFC] Replace bool by cir::UnaryOpKind in emitComplexPrePostIncDec#149566
Conversation
|
Ref: #149162 |
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clangir Author: Amr Hesham (AmrDeveloper) ChangesReplace bool by cir::UnaryOpKind in emitComplexPrePostIncDec Full diff: https://github.com/llvm/llvm-project/pull/149566.diff 2 Files Affected:
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp b/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp
index 0a22771378ff1..213a795b186b6 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp
@@ -57,23 +57,23 @@ class ComplexExprEmitter : public StmtVisitor<ComplexExprEmitter, mlir::Value> {
mlir::Value
VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *e);
- mlir::Value VisitPrePostIncDec(const UnaryOperator *e, bool isInc,
+ mlir::Value VisitPrePostIncDec(const UnaryOperator *e, cir::UnaryOpKind op,
bool isPre);
mlir::Value VisitUnaryPostDec(const UnaryOperator *e) {
- return VisitPrePostIncDec(e, false, false);
+ return VisitPrePostIncDec(e, cir::UnaryOpKind::Dec, false);
}
mlir::Value VisitUnaryPostInc(const UnaryOperator *e) {
- return VisitPrePostIncDec(e, true, false);
+ return VisitPrePostIncDec(e, cir::UnaryOpKind::Inc, false);
}
mlir::Value VisitUnaryPreDec(const UnaryOperator *e) {
- return VisitPrePostIncDec(e, false, true);
+ return VisitPrePostIncDec(e, cir::UnaryOpKind::Dec, true);
}
mlir::Value VisitUnaryPreInc(const UnaryOperator *e) {
- return VisitPrePostIncDec(e, true, true);
+ return VisitPrePostIncDec(e, cir::UnaryOpKind::Inc, true);
}
mlir::Value VisitUnaryDeref(const Expr *e);
@@ -355,9 +355,10 @@ mlir::Value ComplexExprEmitter::VisitSubstNonTypeTemplateParmExpr(
}
mlir::Value ComplexExprEmitter::VisitPrePostIncDec(const UnaryOperator *e,
- bool isInc, bool isPre) {
+ cir::UnaryOpKind op,
+ bool isPre) {
LValue lv = cgf.emitLValue(e->getSubExpr());
- return cgf.emitComplexPrePostIncDec(e, lv, isInc, isPre);
+ return cgf.emitComplexPrePostIncDec(e, lv, op, isPre);
}
mlir::Value ComplexExprEmitter::VisitUnaryDeref(const Expr *e) {
@@ -449,12 +450,15 @@ mlir::Value CIRGenFunction::emitComplexExpr(const Expr *e) {
}
mlir::Value CIRGenFunction::emitComplexPrePostIncDec(const UnaryOperator *e,
- LValue lv, bool isInc,
+ LValue lv,
+ cir::UnaryOpKind op,
bool isPre) {
+ assert(op == cir::UnaryOpKind::Inc ||
+ op == cir::UnaryOpKind::Dec && "Invalid UnaryOp kind for ComplexType");
+
mlir::Value inVal = emitLoadOfComplex(lv, e->getExprLoc());
mlir::Location loc = getLoc(e->getExprLoc());
- auto opKind = isInc ? cir::UnaryOpKind::Inc : cir::UnaryOpKind::Dec;
- mlir::Value incVal = builder.createUnaryOp(loc, opKind, inVal);
+ mlir::Value incVal = builder.createUnaryOp(loc, op, inVal);
// Store the updated result through the lvalue.
emitStoreOfComplex(loc, incVal, lv, /*isInit=*/false);
diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.h b/clang/lib/CIR/CodeGen/CIRGenFunction.h
index 9541f4f0725eb..552a3921f2d9b 100644
--- a/clang/lib/CIR/CodeGen/CIRGenFunction.h
+++ b/clang/lib/CIR/CodeGen/CIRGenFunction.h
@@ -931,7 +931,7 @@ class CIRGenFunction : public CIRGenTypeCache {
mlir::Value emitComplexExpr(const Expr *e);
mlir::Value emitComplexPrePostIncDec(const UnaryOperator *e, LValue lv,
- bool isInc, bool isPre);
+ cir::UnaryOpKind op, bool isPre);
LValue emitComplexAssignmentLValue(const BinaryOperator *e);
|
andykaylor
left a comment
There was a problem hiding this comment.
LGTM
We should make this same change in ScalarExprEmitter::EmitScalarPrePostIncDec
I will update it too |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/20125 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/19241 Here is the relevant piece of the build log for the reference |
…ec (llvm#149566) Replace bool by cir::UnaryOpKind in emitComplexPrePostIncDec
Replace bool by cir::UnaryOpKind in emitComplexPrePostIncDec