class ErrorAsOutParameter

Declaration

class ErrorAsOutParameter { /* full declaration omitted */ };

Description

Helper for Errors used as out-parameters. This helper is for use with the Error-as-out-parameter idiom, where an error is passed to a function or method by reference, rather than being returned. In such cases it is helpful to set the checked bit on entry to the function so that the error can be written to (unchecked Errors abort on assignment) and clear the checked bit on exit so that clients cannot accidentally forget to check the result. This helper performs these actions automatically using RAII: ErrorAsOutParameter takes an Error* rather than Error & so that it can be used with optional Errors (Error pointers that are allowed to be null). If ErrorAsOutParameter took an Error reference, an instance would have to be created inside every condition that verified that Error was non-null. By taking an Error pointer we can just create one instance at the top of the function.

Declared at: llvm/include/llvm/Support/Error.h:1097

Member Variables

private llvm::Error* Err

Method Overview

Methods

ErrorAsOutParameter(llvm::Error* Err)

Declared at: llvm/include/llvm/Support/Error.h:1099

Parameters

llvm::Error* Err

~ErrorAsOutParameter()

Declared at: llvm/include/llvm/Support/Error.h:1105