diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -29,21 +29,6 @@ class Builder; class OpBuilder; -/// This class represents success/failure for operation parsing. It is -/// essentially a simple wrapper class around LogicalResult that allows for -/// explicit conversion to bool. This allows for the parser to chain together -/// parse rules without the clutter of "failed/succeeded". -class ParseResult : public LogicalResult { -public: - ParseResult(LogicalResult result = success()) : LogicalResult(result) {} - - // Allow diagnostics emitted during parsing to be converted to failure. - ParseResult(const InFlightDiagnostic &) : LogicalResult(failure()) {} - ParseResult(const Diagnostic &) : LogicalResult(failure()) {} - - /// Failure is true in a boolean context. - explicit operator bool() const { return failed(); } -}; /// This class implements `Optional` functionality for ParseResult. We don't /// directly use Optional here, because it provides an implicit conversion /// to 'bool' which we want to avoid. This class is used to implement tri-state diff --git a/mlir/include/mlir/Support/LogicalResult.h b/mlir/include/mlir/Support/LogicalResult.h --- a/mlir/include/mlir/Support/LogicalResult.h +++ b/mlir/include/mlir/Support/LogicalResult.h @@ -13,6 +13,8 @@ #include "llvm/ADT/Optional.h" namespace mlir { +class InFlightDiagnostic; +class Diagnostic; /// This class represents an efficient way to signal success or failure. It /// should be preferred over the use of `bool` when appropriate, as it avoids @@ -71,6 +73,22 @@ /// to a failure value. inline bool failed(LogicalResult result) { return result.failed(); } +/// This class represents success/failure for operation parsing. It is +/// essentially a simple wrapper class around LogicalResult that allows for +/// explicit conversion to bool. This allows for the parser to chain together +/// parse rules without the clutter of "failed/succeeded". +class ParseResult : public LogicalResult { +public: + ParseResult(LogicalResult result = success()) : LogicalResult(result) {} + + // Allow diagnostics emitted during parsing to be converted to failure. + ParseResult(const InFlightDiagnostic &) : LogicalResult(failure()) {} + ParseResult(const Diagnostic &) : LogicalResult(failure()) {} + + /// Failure is true in a boolean context. + explicit operator bool() const { return failed(); } +}; + /// This class provides support for representing a failure result, or a valid /// value of type `T`. This allows for integrating with LogicalResult, while /// also providing a value on the success path. diff --git a/mlir/lib/Tools/PDLL/AST/Diagnostic.cpp b/mlir/lib/Tools/PDLL/AST/Diagnostic.cpp --- a/mlir/lib/Tools/PDLL/AST/Diagnostic.cpp +++ b/mlir/lib/Tools/PDLL/AST/Diagnostic.cpp @@ -15,7 +15,7 @@ // InFlightDiagnostic //===----------------------------------------------------------------------===// -void InFlightDiagnostic::report() { +void mlir::pdll::ast::InFlightDiagnostic::report() { // If this diagnostic is still inflight and it hasn't been abandoned, then // report it. if (isInFlight()) {