[llvm] 571d5f9 - [Orc][examples] Factor out make_error from parseExampleModule (NFC)
Stefan Gränitz via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 26 10:49:51 PDT 2021
Author: Stefan Gränitz
Date: 2021-03-26T18:49:07+01:00
New Revision: 571d5f92130bc03aec794875cb9775d599a710e3
URL: https://github.com/llvm/llvm-project/commit/571d5f92130bc03aec794875cb9775d599a710e3
DIFF: https://github.com/llvm/llvm-project/commit/571d5f92130bc03aec794875cb9775d599a710e3.diff
LOG: [Orc][examples] Factor out make_error from parseExampleModule (NFC)
Added:
Modified:
llvm/examples/OrcV2Examples/ExampleModules.h
Removed:
################################################################################
diff --git a/llvm/examples/OrcV2Examples/ExampleModules.h b/llvm/examples/OrcV2Examples/ExampleModules.h
index 7f0332f7688c..c88609fae769 100644
--- a/llvm/examples/OrcV2Examples/ExampleModules.h
+++ b/llvm/examples/OrcV2Examples/ExampleModules.h
@@ -31,25 +31,25 @@ const llvm::StringRef Add1Example =
}
)";
+inline llvm::Error createSMDiagnosticError(llvm::SMDiagnostic &Diag) {
+ using namespace llvm;
+ std::string Msg;
+ {
+ raw_string_ostream OS(Msg);
+ Diag.print("", OS);
+ }
+ return make_error<StringError>(std::move(Msg), inconvertibleErrorCode());
+}
+
inline llvm::Expected<llvm::orc::ThreadSafeModule>
parseExampleModule(llvm::StringRef Source, llvm::StringRef Name) {
using namespace llvm;
- using namespace llvm::orc;
-
auto Ctx = std::make_unique<LLVMContext>();
SMDiagnostic Err;
- auto M = parseIR(MemoryBufferRef(Source, Name), Err, *Ctx);
-
- if (!M) {
- std::string ErrMsg;
- {
- raw_string_ostream ErrStream(ErrMsg);
- Err.print("", ErrStream);
- }
- return make_error<StringError>(std::move(ErrMsg), inconvertibleErrorCode());
- }
+ if (auto M = parseIR(MemoryBufferRef(Source, Name), Err, *Ctx))
+ return orc::ThreadSafeModule(std::move(M), std::move(Ctx));
- return ThreadSafeModule(std::move(M), std::move(Ctx));
+ return createSMDiagnosticError(Err);
}
#endif // LLVM_EXAMPLES_ORCV2EXAMPLES_EXAMPLEMODULES_H
More information about the llvm-commits
mailing list