[Support] Add a C-API function to create a StringError instance.
This will allow C API clients to return errors from callbacks. This
functionality will be used in upcoming Orc C-bindings functions.
diff --git a/llvm/include/llvm-c/Error.h b/llvm/include/llvm-c/Error.h
index 92f81bf..bc702ac 100644
--- a/llvm/include/llvm-c/Error.h
+++ b/llvm/include/llvm-c/Error.h
@@ -62,6 +62,11 @@
*/
LLVMErrorTypeId LLVMGetStringErrorTypeId(void);
+/**
+ * Create a StringError.
+ */
+LLVMErrorRef LLVMCreateStringError(const char *ErrMsg);
+
LLVM_C_EXTERN_C_END
#endif
diff --git a/llvm/lib/Support/Error.cpp b/llvm/lib/Support/Error.cpp
index 315a11e..e7ab438 100644
--- a/llvm/lib/Support/Error.cpp
+++ b/llvm/lib/Support/Error.cpp
@@ -168,3 +168,7 @@
LLVMErrorTypeId LLVMGetStringErrorTypeId() {
return reinterpret_cast<void *>(&StringError::ID);
}
+
+LLVMErrorRef LLVMCreateStringError(const char *ErrMsg) {
+ return wrap(make_error<StringError>(ErrMsg, inconvertibleErrorCode()));
+}