[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / llvm / include / llvm-c / Error.h
blobc3baaf65186aac65ec84d97cde1aa41b165d2df9
1 /*===------- llvm-c/Error.h - llvm::Error class C Interface -------*- C -*-===*\
2 |* *|
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 *|
7 |* *|
8 |*===----------------------------------------------------------------------===*|
9 |* *|
10 |* This file defines the C interface to LLVM's Error class. *|
11 |* *|
12 \*===----------------------------------------------------------------------===*/
14 #ifndef LLVM_C_ERROR_H
15 #define LLVM_C_ERROR_H
17 #include "llvm-c/ExternC.h"
19 LLVM_C_EXTERN_C_BEGIN
21 /**
22 * @defgroup LLVMCError Error Handling
23 * @ingroup LLVMC
25 * @{
28 #define LLVMErrorSuccess 0
30 /**
31 * Opaque reference to an error instance. Null serves as the 'success' value.
33 typedef struct LLVMOpaqueError *LLVMErrorRef;
35 /**
36 * Error type identifier.
38 typedef const void *LLVMErrorTypeId;
40 /**
41 * Returns the type id for the given error instance, which must be a failure
42 * value (i.e. non-null).
44 LLVMErrorTypeId LLVMGetErrorTypeId(LLVMErrorRef Err);
46 /**
47 * Dispose of the given error without handling it. This operation consumes the
48 * error, and the given LLVMErrorRef value is not usable once this call returns.
49 * Note: This method *only* needs to be called if the error is not being passed
50 * to some other consuming operation, e.g. LLVMGetErrorMessage.
52 void LLVMConsumeError(LLVMErrorRef Err);
54 /**
55 * Returns the given string's error message. This operation consumes the error,
56 * and the given LLVMErrorRef value is not usable once this call returns.
57 * The caller is responsible for disposing of the string by calling
58 * LLVMDisposeErrorMessage.
60 char *LLVMGetErrorMessage(LLVMErrorRef Err);
62 /**
63 * Dispose of the given error message.
65 void LLVMDisposeErrorMessage(char *ErrMsg);
67 /**
68 * Returns the type id for llvm StringError.
70 LLVMErrorTypeId LLVMGetStringErrorTypeId(void);
72 /**
73 * Create a StringError.
75 LLVMErrorRef LLVMCreateStringError(const char *ErrMsg);
77 /**
78 * @}
81 LLVM_C_EXTERN_C_END
83 #endif