Handle switch without cases

This commit is contained in:
William S. Moses 2021-12-24 13:08:40 -05:00 committed by William Moses
parent dce464e271
commit f5b6c2b9cf
2 changed files with 19 additions and 0 deletions

View File

@ -650,6 +650,13 @@ ValueCategory MLIRScanner::VisitSwitchStmt(clang::SwitchStmt *stmt) {
}
}
if (caseVals.size() == 0) {
delete &exitB;
er.erase();
builder.setInsertionPoint(oldblock2, oldpoint2);
return nullptr;
}
if (inCase)
loops.pop_back();
builder.create<mlir::BranchOp>(loc, &exitB);

View File

@ -0,0 +1,12 @@
// RUN: mlir-clang %s --function=foo -S | FileCheck %s
int foo(int t) {
switch (t) {
}
return t;
}
// TODO the select should be canonicalized better
// CHECK: func @foo(%arg0: i32) -> i32 attributes {llvm.linkage = #llvm.linkage<external>} {
// CHECK-NEXT: return %arg0 : i32
// CHECK-NEXT: }