LLVM 20.0.0git
Public Member Functions | List of all members
llvm::ParseResult Class Reference

This class represents success/failure for parsing-like operations that find it important to chain together failable operations with ||. More...

#include "llvm/Support/LogicalResult.h"

Inheritance diagram for llvm::ParseResult:
Inheritance graph
[legend]

Public Member Functions

 ParseResult (LogicalResult Result=success())
 
constexpr operator bool () const
 Failure is true in a boolean context.
 
- Public Member Functions inherited from llvm::LogicalResult
constexpr bool succeeded () const
 Returns true if the provided LogicalResult corresponds to a success value.
 
constexpr bool failed () const
 Returns true if the provided LogicalResult corresponds to a failure value.
 

Additional Inherited Members

- Static Public Member Functions inherited from llvm::LogicalResult
static LogicalResult success (bool IsSuccess=true)
 If isSuccess is true a success result is generated, otherwise a 'failure' result is generated.
 
static LogicalResult failure (bool IsFailure=true)
 If isFailure is true a failure result is generated, otherwise a 'success' result is generated.
 

Detailed 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.

Definition at line 119 of file LogicalResult.h.

Constructor & Destructor Documentation

◆ ParseResult()

llvm::ParseResult::ParseResult ( LogicalResult  Result = success())
inline

Definition at line 121 of file LogicalResult.h.

References llvm::success().

Member Function Documentation

◆ operator bool()

constexpr llvm::ParseResult::operator bool ( ) const
inlineexplicitconstexpr

Failure is true in a boolean context.

Definition at line 124 of file LogicalResult.h.

References llvm::failed().


The documentation for this class was generated from the following file: