Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clang/include/clang/CIR/Dialect/IR/CIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,8 @@ def CIR_SwitchOp : CIR_Op<"switch", [

let arguments = (ins
CIR_IntType:$condition,
UnitAttr:$allEnumCasesCovered
UnitAttr:$allEnumCasesCovered,
UnitAttr:$handling_enum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
UnitAttr:$handling_enum
UnitAttr:$is_enum

);

let regions = (region AnyRegion:$body);
Expand All @@ -1230,6 +1231,7 @@ def CIR_SwitchOp : CIR_Op<"switch", [
let assemblyFormat = [{
`(` $condition `:` qualified(type($condition)) `)`
(`allEnumCasesCovered` $allEnumCasesCovered^)?
(`handling_enum` $handling_enum^)?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(`handling_enum` $handling_enum^)?
(`enum` $is_enum^)?

$body
attr-dict
}];
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CIR/CodeGen/CIRGenStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,7 @@ mlir::LogicalResult CIRGenFunction::emitSwitchStmt(const clang::SwitchStmt &s) {
terminateBody(builder, caseOp.getCaseRegion(), caseOp.getLoc());
terminateBody(builder, swop.getBody(), swop.getLoc());

swop.setHandlingEnum(s.getCond()->IgnoreParenImpCasts()->getType()->isEnumeralType());
swop.setAllEnumCasesCovered(s.isAllEnumCasesCovered());

return res;
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/CodeGen/switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ void testSwitchCoverAllCase(M m) {
break;
}
}
// CIR: cir.switch(%[[ARG:.*]] : !s32i) allEnumCasesCovered {
// CIR: cir.switch(%[[ARG:.*]] : !s32i) allEnumCasesCovered handling_enum {

void testSwitchNotCoverAllCase(M m) {
switch (m) {
Expand All @@ -1291,4 +1291,4 @@ void testSwitchNotCoverAllCase(M m) {
break;
}
}
// CIR: cir.switch(%[[ARG:.*]] : !s32i) {
// CIR: cir.switch(%[[ARG:.*]] : !s32i) handling_enum {
Loading