[Mlir-commits] [mlir] cac19f4 - [LogicalResult.h] Move ParseResult to the bottom of file and fix comment, NFC.

Chris Lattner llvmlistbot at llvm.org
Sun Apr 17 15:35:07 PDT 2022


Author: Chris Lattner
Date: 2022-04-17T15:34:26-07:00
New Revision: cac19f414124bf6f2ba78cbe51ed52764e8df237

URL: https://github.com/llvm/llvm-project/commit/cac19f414124bf6f2ba78cbe51ed52764e8df237
DIFF: https://github.com/llvm/llvm-project/commit/cac19f414124bf6f2ba78cbe51ed52764e8df237.diff

LOG: [LogicalResult.h] Move ParseResult to the bottom of file and fix comment, NFC.

This was review feedback that I missed in the phab review:
https://reviews.llvm.org/D123760

Added: 
    

Modified: 
    mlir/include/mlir/Support/LogicalResult.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Support/LogicalResult.h b/mlir/include/mlir/Support/LogicalResult.h
index 3391485433f4d..a30fe42d1f5f1 100644
--- a/mlir/include/mlir/Support/LogicalResult.h
+++ b/mlir/include/mlir/Support/LogicalResult.h
@@ -71,25 +71,6 @@ inline bool succeeded(LogicalResult result) { return result.succeeded(); }
 /// to a failure value.
 inline bool failed(LogicalResult result) { return result.failed(); }
 
-/// This class represents success/failure for parsing-like operations that find
-/// it important to chain together failable operations with `||`.  This is an
-/// extended version of `LogicalResult` that allows for explicit conversion to
-/// bool.
-///
-/// This class should not be used for general error handling cases - we prefer
-/// to keep the logic explicit with the `succeeded`/`failed` predicates.
-/// However, traditional monadic-style parsering logic can sometimes get
-/// swallowed up in boilerplate without this, so we provide this for narrow
-/// cases where it is important.
-///
-class ParseResult : public LogicalResult {
-public:
-  ParseResult(LogicalResult result = success()) : LogicalResult(result) {}
-
-  /// 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.
@@ -117,6 +98,25 @@ template <typename T> class LLVM_NODISCARD FailureOr : public Optional<T> {
   using Optional<T>::hasValue;
 };
 
+/// This class represents success/failure for parsing-like operations that find
+/// it important to chain together failable operations with `||`.  This is an
+/// extended version of `LogicalResult` that allows for explicit conversion to
+/// bool.
+///
+/// This class should not be used for general error handling cases - we prefer
+/// to keep the logic explicit with the `succeeded`/`failed` predicates.
+/// However, traditional monadic-style parsing logic can sometimes get
+/// swallowed up in boilerplate without this, so we provide this for narrow
+/// cases where it is important.
+///
+class ParseResult : public LogicalResult {
+public:
+  ParseResult(LogicalResult result = success()) : LogicalResult(result) {}
+
+  /// Failure is true in a boolean context.
+  explicit operator bool() const { return failed(); }
+};
+
 } // namespace mlir
 
 #endif // MLIR_SUPPORT_LOGICALRESULT_H


        


More information about the Mlir-commits mailing list