Skip to content

Commit b7e1c76

Browse files
committed
[CIR][Rebase] Stub out error handling for Pass option initialization
1 parent d0eed34 commit b7e1c76

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

clang/lib/CIR/CodeGen/CIRPasses.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "mlir/Pass/Pass.h"
1818
#include "mlir/Pass/PassManager.h"
19+
#include "mlir/Support/LogicalResult.h"
1920

2021
namespace cir {
2122
mlir::LogicalResult
@@ -29,9 +30,15 @@ runCIRToCIRPasses(mlir::ModuleOp theModule, mlir::MLIRContext *mlirCtx,
2930
mlir::PassManager pm(mlirCtx);
3031
pm.addPass(mlir::createMergeCleanupsPass());
3132

33+
// TODO(CIR): Make this actually propagate errors correctly. This is stubbed
34+
// in to get rebases going.
35+
auto errorHandler = [](const llvm::Twine &) -> mlir::LogicalResult {
36+
return mlir::LogicalResult::failure();
37+
};
38+
3239
if (enableLifetime) {
3340
auto lifetimePass = mlir::createLifetimeCheckPass(&astCtx);
34-
if (lifetimePass->initializeOptions(lifetimeOpts).failed()) {
41+
if (lifetimePass->initializeOptions(lifetimeOpts, errorHandler).failed()) {
3542
passOptParsingFailure = lifetimeOpts;
3643
return mlir::failure();
3744
}
@@ -40,7 +47,8 @@ runCIRToCIRPasses(mlir::ModuleOp theModule, mlir::MLIRContext *mlirCtx,
4047

4148
if (enableIdiomRecognizer) {
4249
auto idiomPass = mlir::createIdiomRecognizerPass(&astCtx);
43-
if (idiomPass->initializeOptions(idiomRecognizerOpts).failed()) {
50+
if (idiomPass->initializeOptions(idiomRecognizerOpts, errorHandler)
51+
.failed()) {
4452
passOptParsingFailure = idiomRecognizerOpts;
4553
return mlir::failure();
4654
}
@@ -49,7 +57,7 @@ runCIRToCIRPasses(mlir::ModuleOp theModule, mlir::MLIRContext *mlirCtx,
4957

5058
if (enableLibOpt) {
5159
auto libOpPass = mlir::createLibOptPass(&astCtx);
52-
if (libOpPass->initializeOptions(libOptOpts).failed()) {
60+
if (libOpPass->initializeOptions(libOptOpts, errorHandler).failed()) {
5361
passOptParsingFailure = libOptOpts;
5462
return mlir::failure();
5563
}
@@ -77,4 +85,4 @@ void populateCIRPreLoweringPasses(OpPassManager &pm) {
7785
// add other passes here
7886
}
7987

80-
} // namespace mlir
88+
} // namespace mlir

0 commit comments

Comments
 (0)