本文整理汇总了C++中cl::opt::data方法的典型用法代码示例。如果您正苦于以下问题:C++ opt::data方法的具体用法?C++ opt::data怎么用?C++ opt::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cl::opt
的用法示例。
在下文中一共展示了opt::data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//===----------------------------------------------------------------------===//
int main(int argc, char **argv) {
// Print a stack trace if we signal out.
sys::PrintStackTraceOnErrorSignal();
PrettyStackTraceProgram X(argc, argv);
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
cl::ParseCommandLineOptions(argc, argv, "LLVM profile data merger\n");
std::unique_ptr<MemoryBuffer> File1;
std::unique_ptr<MemoryBuffer> File2;
if (error_code ec = MemoryBuffer::getFile(Filename1, File1))
exitWithError(ec.message(), Filename1);
if (error_code ec = MemoryBuffer::getFile(Filename2, File2))
exitWithError(ec.message(), Filename2);
if (OutputFilename.empty())
OutputFilename = "-";
std::string ErrorInfo;
raw_fd_ostream Output(OutputFilename.data(), ErrorInfo, sys::fs::F_Text);
if (!ErrorInfo.empty())
exitWithError(ErrorInfo, OutputFilename);
const char *Start1 = File1->getBufferStart();
const char *Start2 = File2->getBufferStart();
const char *End1 = File1->getBufferEnd();
const char *End2 = File2->getBufferEnd();
const char *P1 = Start1;
const char *P2 = Start2;
StringRef Line1, Line2;
int64_t Num = 0;
while (readLine(P1, End1, Line1)) {
++Num;
if (!readLine(P2, End2, Line2))
exitWithError("truncated file", Filename2, Num);
std::vector<StringRef> Words1, Words2;
if (splitWords(Line1, Words1) != splitWords(Line2, Words2))
exitWithError("data mismatch", Filename2, Num);
if (Words1.size() > 2)
exitWithError("invalid data", Filename1, Num);
if (Words1.empty()) {
Output << "\n";
continue;
}
if (Words1.size() == 2) {
if (Words1[0] != Words2[0])
exitWithError("function name mismatch", Filename2, Num);
uint64_t N1, N2;
if (!getNumber(Words1[1], N1))
exitWithError("bad function count", Filename1, Num);
if (!getNumber(Words2[1], N2))
exitWithError("bad function count", Filename2, Num);
if (N1 != N2)
exitWithError("function count mismatch", Filename2, Num);
Output << Line1 << "\n";
continue;
}
uint64_t N1, N2;
if (!getNumber(Words1[0], N1))
exitWithError("invalid counter", Filename1, Num);
if (!getNumber(Words2[0], N2))
exitWithError("invalid counter", Filename2, Num);
uint64_t Sum = N1 + N2;
if (Sum < N1)
exitWithError("counter overflow", Filename2, Num);
Output << N1 + N2 << "\n";
}
if (readLine(P2, End2, Line2))
exitWithError("truncated file", Filename1, Num + 1);
return 0;
}