LLVM
8.0.1
|
Helper for Errors used as out-parameters. More...
#include "llvm/Support/Error.h"
Public Member Functions | |
ErrorAsOutParameter (Error *Err) | |
~ErrorAsOutParameter () | |
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.
|
inline |