diff options
author | David Blaikie <dblaikie@gmail.com> | 2024-07-31 16:38:14 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2024-07-31 16:40:26 +0000 |
commit | 45ef0d492f7b61613d0833fbf7eafdd41e137139 (patch) | |
tree | 2f69edccd161312f1cf56f2fc642fb5bbb5e8b9a /llvm/lib/Support/Error.cpp | |
parent | 3715035797a8b07ddaf2e2eff08fedc535891e15 (diff) | |
download | llvm-45ef0d492f7b61613d0833fbf7eafdd41e137139.zip llvm-45ef0d492f7b61613d0833fbf7eafdd41e137139.tar.gz llvm-45ef0d492f7b61613d0833fbf7eafdd41e137139.tar.bz2 |
Add llvm::Error C API, LLVMCantFail
It's barely testable - the test does exercise the code, but wouldn't
fail on an empty implementation. It would cause a memory leak though
(because the error handle wouldn't be unwrapped/reowned) which could be
detected by asan and other leak detectors.
Diffstat (limited to 'llvm/lib/Support/Error.cpp')
-rw-r--r-- | llvm/lib/Support/Error.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Support/Error.cpp b/llvm/lib/Support/Error.cpp index 93481ca..baa3c32 100644 --- a/llvm/lib/Support/Error.cpp +++ b/llvm/lib/Support/Error.cpp @@ -182,6 +182,12 @@ LLVMErrorTypeId LLVMGetErrorTypeId(LLVMErrorRef Err) { void LLVMConsumeError(LLVMErrorRef Err) { consumeError(unwrap(Err)); } + + +void LLVMCantFail(LLVMErrorRef Err) { + cantFail(unwrap(Err)); +} + char *LLVMGetErrorMessage(LLVMErrorRef Err) { std::string Tmp = toString(unwrap(Err)); char *ErrMsg = new char[Tmp.size() + 1]; |