Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 1 | /*===------- llvm-c/Error.h - llvm::Error class C Interface -------*- C -*-===*\ |
| 2 | |* *| |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 3 | |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| |
| 4 | |* Exceptions. *| |
| 5 | |* See https://llvm.org/LICENSE.txt for license information. *| |
| 6 | |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 7 | |* *| |
| 8 | |*===----------------------------------------------------------------------===*| |
| 9 | |* *| |
| 10 | |* This file defines the C interface to LLVM's Error class. *| |
| 11 | |* *| |
| 12 | \*===----------------------------------------------------------------------===*/ |
| 13 | |
| 14 | #ifndef LLVM_C_ERROR_H |
| 15 | #define LLVM_C_ERROR_H |
| 16 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 17 | #include "llvm-c/ExternC.h" |
| 18 | |
| 19 | LLVM_C_EXTERN_C_BEGIN |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 20 | |
| 21 | #define LLVMErrorSuccess 0 |
| 22 | |
| 23 | /** |
| 24 | * Opaque reference to an error instance. Null serves as the 'success' value. |
| 25 | */ |
| 26 | typedef struct LLVMOpaqueError *LLVMErrorRef; |
| 27 | |
| 28 | /** |
| 29 | * Error type identifier. |
| 30 | */ |
| 31 | typedef const void *LLVMErrorTypeId; |
| 32 | |
| 33 | /** |
| 34 | * Returns the type id for the given error instance, which must be a failure |
| 35 | * value (i.e. non-null). |
| 36 | */ |
| 37 | LLVMErrorTypeId LLVMGetErrorTypeId(LLVMErrorRef Err); |
| 38 | |
| 39 | /** |
| 40 | * Dispose of the given error without handling it. This operation consumes the |
| 41 | * error, and the given LLVMErrorRef value is not usable once this call returns. |
| 42 | * Note: This method *only* needs to be called if the error is not being passed |
| 43 | * to some other consuming operation, e.g. LLVMGetErrorMessage. |
| 44 | */ |
| 45 | void LLVMConsumeError(LLVMErrorRef Err); |
| 46 | |
| 47 | /** |
| 48 | * Returns the given string's error message. This operation consumes the error, |
| 49 | * and the given LLVMErrorRef value is not usable once this call returns. |
| 50 | * The caller is responsible for disposing of the string by calling |
| 51 | * LLVMDisposeErrorMessage. |
| 52 | */ |
| 53 | char *LLVMGetErrorMessage(LLVMErrorRef Err); |
| 54 | |
| 55 | /** |
| 56 | * Dispose of the given error message. |
| 57 | */ |
| 58 | void LLVMDisposeErrorMessage(char *ErrMsg); |
| 59 | |
| 60 | /** |
| 61 | * Returns the type id for llvm StringError. |
| 62 | */ |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 63 | LLVMErrorTypeId LLVMGetStringErrorTypeId(void); |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 64 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 65 | /** |
| 66 | * Create a StringError. |
| 67 | */ |
| 68 | LLVMErrorRef LLVMCreateStringError(const char *ErrMsg); |
| 69 | |
| 70 | LLVM_C_EXTERN_C_END |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 71 | |
| 72 | #endif |