Skip to content

Commit 25dff99

Browse files
Apply new code review suggestions
1 parent eba4924 commit 25dff99

File tree

6 files changed

+17
-18
lines changed

6 files changed

+17
-18
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def StoreOp : CIR_Op<"store", [
473473
//===----------------------------------------------------------------------===//
474474

475475
def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp", "ScopeOp", "IfOp",
476-
"DoWhileOp", "WhileOp", "ForOp"]>,
476+
"DoWhileOp", "WhileOp", "ForOp"]>,
477477
Terminator]> {
478478
let summary = "Return from function";
479479
let description = [{
@@ -527,17 +527,17 @@ def IfOp : CIR_Op<"if",
527527
Examples:
528528

529529
```mlir
530-
cir.if %b {
530+
cir.if %cond {
531531
...
532532
} else {
533533
...
534534
}
535535

536-
cir.if %c {
536+
cir.if %cond {
537537
...
538538
}
539539

540-
cir.if %c {
540+
cir.if %cond {
541541
...
542542
cir.br ^a
543543
^a:
@@ -613,7 +613,7 @@ def ConditionOp : CIR_Op<"condition", [
613613

614614
def YieldOp : CIR_Op<"yield", [ReturnLike, Terminator,
615615
ParentOneOf<["IfOp", "ScopeOp", "WhileOp",
616-
"ForOp", "DoWhileOp"]>]> {
616+
"ForOp", "DoWhileOp"]>]> {
617617
let summary = "Represents the default branching behaviour of a region";
618618
let description = [{
619619
The `cir.yield` operation terminates regions on different CIR operations,

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,14 +540,14 @@ mlir::Value CIRGenFunction::emitOpOnBoolExpr(mlir::Location loc,
540540
assert(!cir::MissingFeatures::shouldReverseUnaryCondOnBoolExpr());
541541

542542
if (isa<ConditionalOperator>(cond)) {
543-
544543
cgm.errorNYI(cond->getExprLoc(), "Ternary NYI");
545544
assert(!cir::MissingFeatures::ternaryOp());
546545
return createDummyValue(loc, cond->getType());
547546
}
548547

549548
if (isa<CXXThrowExpr>(cond)) {
550549
cgm.errorNYI("NYI");
550+
return createDummyValue(loc, cond->getType());
551551
}
552552

553553
// If the branch has a condition wrapped by __builtin_unpredictable,

clang/lib/CIR/CodeGen/CIRGenFunction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ bool CIRGenFunction::containsLabel(const Stmt *s, bool ignoreCaseStmts) {
164164
});
165165
}
166166

167-
/// If the specified expression does not fold
168-
/// to a constant, or if it does but contains a label, return false. If it
169-
/// constant folds return true and set the folded value.
167+
/// If the specified expression does not fold to a constant, or if it does
168+
/// fold but contains a label, return false. If it constant folds, return
169+
/// true and set the folded value.
170170
bool CIRGenFunction::constantFoldsToSimpleInteger(const Expr *cond,
171171
llvm::APSInt &resultInt,
172172
bool allowLabels) {

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,8 @@ void cir::IfOp::build(OpBuilder &builder, OperationState &result, Value cond,
583583
thenBuilder(builder, result.location);
584584

585585
Region *elseRegion = result.addRegion();
586-
if (!withElseRegion) {
586+
if (!withElseRegion)
587587
return;
588-
}
589588

590589
builder.createBlock(elseRegion);
591590
elseBuilder(builder, result.location);

clang/test/CIR/CodeGen/if-consteval.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ void f() {
1111
if consteval {
1212
result = 10;
1313
// CIR-NOT: cir.const #cir.int<10> : !s32i
14-
// LLVM-NOT: store i32 10, ptr %1, align 4
15-
// OGCG-NOT: store i32 10, ptr %result, align 4
14+
// LLVM-NOT: store i32 10
15+
// OGCG-NOT: store i32 10
1616
} else {
1717
result = 20;
1818
// CHECK: cir.const #cir.int<20> : !s32i
@@ -29,15 +29,15 @@ void f() {
2929
} else {
3030
result = 40;
3131
// CIR-NOT: cir.const #cir.int<40> : !s32i
32-
// LLVM-NOT: store i32 40, ptr %1, align 4
33-
// OGCG-NOT: store i32 40, ptr %result, align 4
32+
// LLVM-NOT: store i32 40
33+
// OGCG-NOT: store i32 40
3434
}
3535

3636
if consteval {
3737
result = 50;
3838
// CIR-NOT: cir.const #cir.int<50> : !s32i
39-
// LLVM-NOT: store i32 50, ptr %1, align 4
40-
// OGCG-NOT: store i32 50, ptr %result, align 4
39+
// LLVM-NOT: store i32 50
40+
// OGCG-NOT: store i32 50
4141
}
4242

4343
if !consteval {

clang/test/CIR/CodeGen/if.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void if2(int a, bool b, bool c) {
253253
// OGCG: ret void
254254

255255
int if_init() {
256-
if (int x = 42) {
256+
if (int x = 42 ; x) {
257257
return x + 1; // x should be visible here
258258
} else {
259259
return x - 1; // x should also be visible here

0 commit comments

Comments
 (0)