本文整理汇总了C++中Expected::parseModule方法的典型用法代码示例。如果您正苦于以下问题:C++ Expected::parseModule方法的具体用法?C++ Expected::parseModule怎么用?C++ Expected::parseModule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Expected
的用法示例。
在下文中一共展示了Expected::parseModule方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DiagErrors
std::unique_ptr<llvm::Module> CodeGenAction::loadModule(MemoryBufferRef MBRef) {
CompilerInstance &CI = getCompilerInstance();
SourceManager &SM = CI.getSourceManager();
// For ThinLTO backend invocations, ensure that the context
// merges types based on ODR identifiers. We also need to read
// the correct module out of a multi-module bitcode file.
if (!CI.getCodeGenOpts().ThinLTOIndexFile.empty()) {
VMContext->enableDebugTypeODRUniquing();
auto DiagErrors = [&](Error E) -> std::unique_ptr<llvm::Module> {
unsigned DiagID =
CI.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error, "%0");
handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) {
CI.getDiagnostics().Report(DiagID) << EIB.message();
});
return {};
};
Expected<llvm::BitcodeModule> BMOrErr = FindThinLTOModule(MBRef);
if (!BMOrErr)
return DiagErrors(BMOrErr.takeError());
Expected<std::unique_ptr<llvm::Module>> MOrErr =
BMOrErr->parseModule(*VMContext);
if (!MOrErr)
return DiagErrors(MOrErr.takeError());
return std::move(*MOrErr);
}
llvm::SMDiagnostic Err;
if (std::unique_ptr<llvm::Module> M = parseIR(MBRef, Err, *VMContext))
return M;
// Translate from the diagnostic info to the SourceManager location if
// available.
// TODO: Unify this with ConvertBackendLocation()
SourceLocation Loc;
if (Err.getLineNo() > 0) {
assert(Err.getColumnNo() >= 0);
Loc = SM.translateFileLineCol(SM.getFileEntryForID(SM.getMainFileID()),
Err.getLineNo(), Err.getColumnNo() + 1);
}
// Strip off a leading diagnostic code if there is one.
StringRef Msg = Err.getMessage();
if (Msg.startswith("error: "))
Msg = Msg.substr(7);
unsigned DiagID =
CI.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error, "%0");
CI.getDiagnostics().Report(Loc, DiagID) << Msg;
return {};
}