本文整理汇总了C++中OptTable::ParseArgs方法的典型用法代码示例。如果您正苦于以下问题:C++ OptTable::ParseArgs方法的具体用法?C++ OptTable::ParseArgs怎么用?C++ OptTable::ParseArgs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptTable
的用法示例。
在下文中一共展示了OptTable::ParseArgs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// FIXME: Define the need for this testing away.
static int cc1_test(Diagnostic &Diags,
const char **ArgBegin, const char **ArgEnd) {
using namespace clang::driver;
llvm::errs() << "cc1 argv:";
for (const char **i = ArgBegin; i != ArgEnd; ++i)
llvm::errs() << " \"" << *i << '"';
llvm::errs() << "\n";
// Parse the arguments.
OptTable *Opts = createCC1OptTable();
unsigned MissingArgIndex, MissingArgCount;
InputArgList *Args = Opts->ParseArgs(ArgBegin, ArgEnd,
MissingArgIndex, MissingArgCount);
// Check for missing argument error.
if (MissingArgCount)
Diags.Report(clang::diag::err_drv_missing_argument)
<< Args->getArgString(MissingArgIndex) << MissingArgCount;
// Dump the parsed arguments.
llvm::errs() << "cc1 parsed options:\n";
for (ArgList::const_iterator it = Args->begin(), ie = Args->end();
it != ie; ++it)
(*it)->dump();
// Create a compiler invocation.
llvm::errs() << "cc1 creating invocation.\n";
CompilerInvocation Invocation;
CompilerInvocation::CreateFromArgs(Invocation, ArgBegin, ArgEnd, Diags);
// Convert the invocation back to argument strings.
std::vector<std::string> InvocationArgs;
Invocation.toArgs(InvocationArgs);
// Dump the converted arguments.
SmallVector<const char*, 32> Invocation2Args;
llvm::errs() << "invocation argv :";
for (unsigned i = 0, e = InvocationArgs.size(); i != e; ++i) {
Invocation2Args.push_back(InvocationArgs[i].c_str());
llvm::errs() << " \"" << InvocationArgs[i] << '"';
}
llvm::errs() << "\n";
// Convert those arguments to another invocation, and check that we got the
// same thing.
CompilerInvocation Invocation2;
CompilerInvocation::CreateFromArgs(Invocation2, Invocation2Args.begin(),
Invocation2Args.end(), Diags);
// FIXME: Implement CompilerInvocation comparison.
if (true) {
//llvm::errs() << "warning: Invocations differ!\n";
std::vector<std::string> Invocation2Args;
Invocation2.toArgs(Invocation2Args);
llvm::errs() << "invocation2 argv:";
for (unsigned i = 0, e = Invocation2Args.size(); i != e; ++i)
llvm::errs() << " \"" << Invocation2Args[i] << '"';
llvm::errs() << "\n";
}
return 0;
}