LLVM 19.0.0git
Public Member Functions | Static Public Member Functions | List of all members
llvm::LogicalResult Struct Reference

This class represents an efficient way to signal success or failure. More...

#include "llvm/Support/LogicalResult.h"

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

Public Member Functions

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.
 

Static Public Member Functions

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 an efficient way to signal success or failure.

It should be preferred over the use of bool when appropriate, as it avoids all of the ambiguity that arises in interpreting a boolean result. This class is marked as NODISCARD to ensure that the result is processed. Users may explicitly discard a result by using (void), e.g. (void)functionThatReturnsALogicalResult();. Given the intended nature of this class, it generally shouldn't be used as the result of functions that very frequently have the result ignored. This class is intended to be used in conjunction with the utility functions below.

Definition at line 25 of file LogicalResult.h.

Member Function Documentation

◆ failed()

constexpr bool llvm::LogicalResult::failed ( ) const
inlineconstexpr

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

Definition at line 43 of file LogicalResult.h.

◆ failure()

static LogicalResult llvm::LogicalResult::failure ( bool  IsFailure = true)
inlinestatic

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

Definition at line 35 of file LogicalResult.h.

Referenced by llvm::failure().

◆ succeeded()

constexpr bool llvm::LogicalResult::succeeded ( ) const
inlineconstexpr

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

Definition at line 40 of file LogicalResult.h.

◆ success()

static LogicalResult llvm::LogicalResult::success ( bool  IsSuccess = true)
inlinestatic

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

Definition at line 29 of file LogicalResult.h.

Referenced by llvm::success().


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