本文整理汇总了C++中OwningPtr::MaterializeAllPermanently方法的典型用法代码示例。如果您正苦于以下问题:C++ OwningPtr::MaterializeAllPermanently方法的具体用法?C++ OwningPtr::MaterializeAllPermanently怎么用?C++ OwningPtr::MaterializeAllPermanently使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OwningPtr
的用法示例。
在下文中一共展示了OwningPtr::MaterializeAllPermanently方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
// Print a stack trace if we signal out.
sys::PrintStackTraceOnErrorSignal();
PrettyStackTraceProgram X(argc, argv);
LLVMContext &Context = getGlobalContext();
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .ll disassembler\n");
std::string ErrorMessage;
OwningPtr<Module> M;
// Use the bitcode streaming interface
DataStreamer *streamer = getDataFileStreamer(InputFilename, &ErrorMessage);
if (streamer) {
std::string DisplayFilename;
if (InputFilename == "-")
DisplayFilename = "<stdin>";
else
DisplayFilename = InputFilename;
M.reset(getStreamedBitcodeModule(DisplayFilename, streamer, Context,
&ErrorMessage));
if(M.get() != 0 && M->MaterializeAllPermanently(&ErrorMessage)) {
M.reset();
}
}
if (M.get() == 0) {
errs() << argv[0] << ": ";
if (ErrorMessage.size())
errs() << ErrorMessage << "\n";
else
errs() << "bitcode didn't read correctly.\n";
return 1;
}
// Just use stdout. We won't actually print anything on it.
if (DontPrint)
OutputFilename = "-";
if (OutputFilename.empty()) { // Unspecified output, infer it.
if (InputFilename == "-") {
OutputFilename = "-";
} else {
const std::string &IFN = InputFilename;
int Len = IFN.length();
// If the source ends in .bc, strip it off.
if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c')
OutputFilename = std::string(IFN.begin(), IFN.end()-3)+".ll";
else
OutputFilename = IFN+".ll";
}
}
std::string ErrorInfo;
OwningPtr<tool_output_file> Out(new tool_output_file(
OutputFilename.c_str(), ErrorInfo, sys::fs::F_Binary));
if (!ErrorInfo.empty()) {
errs() << ErrorInfo << '\n';
return 1;
}
OwningPtr<AssemblyAnnotationWriter> Annotator;
if (ShowAnnotations)
Annotator.reset(new CommentWriter());
// All that llvm-dis does is write the assembly to a file.
if (!DontPrint)
M->print(Out->os(), Annotator.get());
// Declare success.
Out->keep();
return 0;
}