Success/failure status for parsing‐style chains using ||.

Synopsis

Declared in <llvm/Support/LogicalResult.h>

class [[nodiscard]] ParseResult
    : public LogicalResult

Description

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.

Base Classes

Name

Description

LogicalResult

Efficient success‐or‐failure status, preferred over ambiguous bool results.

Member Functions

Name

Description

ParseResult [constructor]

Construct from a LogicalResult, defaulting to success.

failed

Returns true if the provided LogicalResult corresponds to a failure value.

succeeded

Returns true if the provided LogicalResult corresponds to a success value.

operator bool

Failure is true in a boolean context.

Static Member Functions

Name

Description

failure

If isFailure is true a failure result is generated, otherwise a 'success' result is generated.

success

If isSuccess is true a success result is generated, otherwise a 'failure' result is generated.

Return Value

Note

The return value should not be discarded.

Created with MrDocs