[all-commits] [llvm/llvm-project] 58369f: Add a helper function to convert LogicalResult to ...

Thomas Köppe via All-commits all-commits at lists.llvm.org
Tue May 18 17:13:06 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 58369fce30af484889356f225d89cb0b32009206
      https://github.com/llvm/llvm-project/commit/58369fce30af484889356f225d89cb0b32009206
  Author: Thomas Köppe <tkoeppe at google.com>
  Date:   2021-05-19 (Wed, 19 May 2021)

  Changed paths:
    M mlir/examples/standalone/standalone-opt/standalone-opt.cpp
    M mlir/include/mlir/Support/MlirOptMain.h
    M mlir/tools/mlir-opt/mlir-opt.cpp

  Log Message:
  -----------
  Add a helper function to convert LogicalResult to int for return from main

At present, a lot of code contains main function bodies like "return failed(mlir::MlirOptMain(...);". This is unfortunate for two reasons: a) it uses ADL, which is maybe not what the free "failed" function was designed for; and b) it is a bit awkward to read, requring the reader to both understand the boolean nature of the value and the semantics of main's return value. (And it's also not portable, since 1 is not a portable success value.)

The replacement code, `return mlir::AsMainReturnCode(mlir::MlirOptMain(...))` is a bit more self-explanatory.

The change applies the new function to a few internal uses of MlirOptMain, too.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D102641




More information about the All-commits mailing list