- static LTOModule *makeLTOModule(const char* path,
- std::string &errMsg);
- static LTOModule *makeLTOModule(int fd, const char *path,
- size_t size, std::string &errMsg);
- static LTOModule *makeLTOModule(int fd, const char *path,
- size_t map_size,
- off_t offset,
- std::string& errMsg);
- static LTOModule *makeLTOModule(const void *mem, size_t length,
- std::string &errMsg);
-
- /// getTargetTriple - Return the Module's target triple.
- const char *getTargetTriple() {
- return _module->getTargetTriple().c_str();
+ static ErrorOr<std::unique_ptr<LTOModule>>
+ createFromFile(LLVMContext &Context, const char *path, TargetOptions options);
+ static ErrorOr<std::unique_ptr<LTOModule>>
+ createFromOpenFile(LLVMContext &Context, int fd, const char *path,
+ size_t size, TargetOptions options);
+ static ErrorOr<std::unique_ptr<LTOModule>>
+ createFromOpenFileSlice(LLVMContext &Context, int fd, const char *path,
+ size_t map_size, off_t offset, TargetOptions options);
+ static ErrorOr<std::unique_ptr<LTOModule>>
+ createFromBuffer(LLVMContext &Context, const void *mem, size_t length,
+ TargetOptions options, StringRef path = "");
+
+ static ErrorOr<std::unique_ptr<LTOModule>>
+ createInLocalContext(const void *mem, size_t length, TargetOptions options,
+ StringRef path);
+ static ErrorOr<std::unique_ptr<LTOModule>>
+ createInContext(const void *mem, size_t length, TargetOptions options,
+ StringRef path, LLVMContext *Context);
+
+ const Module &getModule() const {
+ return const_cast<LTOModule*>(this)->getModule();
+ }
+ Module &getModule() {
+ return IRFile->getModule();
+ }
+
+ std::unique_ptr<Module> takeModule() { return IRFile->takeModule(); }
+
+ /// Return the Module's target triple.
+ const std::string &getTargetTriple() {
+ return getModule().getTargetTriple();