本文整理汇总了C++中ArgStringList::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ ArgStringList::begin方法的具体用法?C++ ArgStringList::begin怎么用?C++ ArgStringList::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArgStringList
的用法示例。
在下文中一共展示了ArgStringList::begin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getAsString
std::string Arg::getAsString(const ArgList &Args) const {
llvm::SmallString<256> Res;
llvm::raw_svector_ostream OS(Res);
ArgStringList ASL;
render(Args, ASL);
for (ArgStringList::iterator
it = ASL.begin(), ie = ASL.end(); it != ie; ++it) {
if (it != ASL.begin())
OS << ' ';
OS << *it;
}
return OS.str();
}
示例2: CleanupFileList
bool Compilation::CleanupFileList(const ArgStringList &Files,
bool IssueErrors) const {
bool Success = true;
for (ArgStringList::const_iterator
it = Files.begin(), ie = Files.end(); it != ie; ++it) {
llvm::sys::Path P(*it);
std::string Error;
// Don't try to remove files which we don't have write access to (but may be
// able to remove). Underlying tools may have intentionally not overwritten
// them.
if (!P.canWrite())
continue;
if (P.eraseFromDisk(false, &Error)) {
// Failure is only failure if the file exists and is "regular". There is
// a race condition here due to the limited interface of
// llvm::sys::Path, we want to know if the removal gave ENOENT.
// FIXME: Grumble, P.exists() is broken. PR3837.
struct stat buf;
if (::stat(P.c_str(), &buf) == 0 ? (buf.st_mode & S_IFMT) == S_IFREG :
(errno != ENOENT)) {
if (IssueErrors)
getDriver().Diag(lfort::diag::err_drv_unable_to_remove_file)
<< Error;
Success = false;
}
}
}
return Success;
}
示例3: os
ToolChain::InvocationInfo
ToolChain::constructInvocation(const REPLJobAction &job,
const JobContext &context) const {
assert(context.Inputs.empty());
assert(context.InputActions.empty());
bool useLLDB;
switch (job.getRequestedMode()) {
case REPLJobAction::Mode::Integrated:
useLLDB = false;
break;
case REPLJobAction::Mode::RequireLLDB:
useLLDB = true;
break;
case REPLJobAction::Mode::PreferLLDB:
useLLDB = !findProgramRelativeToSwift("lldb").empty();
break;
}
ArgStringList FrontendArgs;
addCommonFrontendArgs(*this, context.OI, context.Output, context.Args,
FrontendArgs);
context.Args.AddAllArgs(FrontendArgs, options::OPT_l, options::OPT_framework,
options::OPT_L);
if (!useLLDB) {
FrontendArgs.insert(FrontendArgs.begin(), {"-frontend", "-repl"});
FrontendArgs.push_back("-module-name");
FrontendArgs.push_back(context.Args.MakeArgString(context.OI.ModuleName));
return {SWIFT_EXECUTABLE_NAME, FrontendArgs};
}
// Squash important frontend options into a single argument for LLDB.
std::string SingleArg = "--repl=";
{
llvm::raw_string_ostream os(SingleArg);
Job::printArguments(os, FrontendArgs);
}
ArgStringList Arguments;
Arguments.push_back(context.Args.MakeArgString(std::move(SingleArg)));
return {"lldb", Arguments};
}
示例4: ParseIRGenArgs
static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
DiagnosticEngine &Diags,
const FrontendOptions &FrontendOpts,
StringRef SDKPath,
StringRef ResourceDir) {
using namespace options;
if (const Arg *A = Args.getLastArg(OPT_g_Group)) {
if (A->getOption().matches(OPT_g))
Opts.DebugInfoKind = IRGenDebugInfoKind::Normal;
else if (A->getOption().matches(options::OPT_gline_tables_only))
Opts.DebugInfoKind = IRGenDebugInfoKind::LineTables;
else
assert(A->getOption().matches(options::OPT_gnone) &&
"unknown -g<kind> option");
if (Opts.DebugInfoKind == IRGenDebugInfoKind::Normal) {
ArgStringList RenderedArgs;
for (auto A : Args)
A->render(Args, RenderedArgs);
CompilerInvocation::buildDWARFDebugFlags(Opts.DWARFDebugFlags,
RenderedArgs, SDKPath,
ResourceDir);
// TODO: Should we support -fdebug-compilation-dir?
llvm::SmallString<256> cwd;
llvm::sys::fs::current_path(cwd);
Opts.DebugCompilationDir = cwd.str();
}
}
for (const Arg *A : make_range(Args.filtered_begin(OPT_l, OPT_framework),
Args.filtered_end())) {
LibraryKind Kind;
if (A->getOption().matches(OPT_l)) {
Kind = LibraryKind::Library;
} else if (A->getOption().matches(OPT_framework)) {
Kind = LibraryKind::Framework;
} else {
llvm_unreachable("Unknown LinkLibrary option kind");
}
Opts.LinkLibraries.push_back(LinkLibrary(A->getValue(), Kind));
}
if (auto valueNames = Args.getLastArg(OPT_disable_llvm_value_names,
OPT_enable_llvm_value_names)) {
Opts.HasValueNamesSetting = true;
Opts.ValueNames =
valueNames->getOption().matches(OPT_enable_llvm_value_names);
}
Opts.DisableLLVMOptzns |= Args.hasArg(OPT_disable_llvm_optzns);
Opts.DisableLLVMARCOpts |= Args.hasArg(OPT_disable_llvm_arc_opts);
Opts.DisableLLVMSLPVectorizer |= Args.hasArg(OPT_disable_llvm_slp_vectorizer);
if (Args.hasArg(OPT_disable_llvm_verify))
Opts.Verify = false;
Opts.EmitStackPromotionChecks |= Args.hasArg(OPT_stack_promotion_checks);
if (const Arg *A = Args.getLastArg(OPT_stack_promotion_limit)) {
unsigned limit;
if (StringRef(A->getValue()).getAsInteger(10, limit)) {
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
A->getAsString(Args), A->getValue());
return true;
}
Opts.StackPromotionSizeLimit = limit;
}
if (Args.hasArg(OPT_autolink_force_load))
Opts.ForceLoadSymbolName = Args.getLastArgValue(OPT_module_link_name);
// TODO: investigate whether these should be removed, in favor of definitions
// in other classes.
if (FrontendOpts.PrimaryInput && FrontendOpts.PrimaryInput->isFilename()) {
unsigned Index = FrontendOpts.PrimaryInput->Index;
Opts.MainInputFilename = FrontendOpts.InputFilenames[Index];
} else if (FrontendOpts.InputFilenames.size() == 1) {
Opts.MainInputFilename = FrontendOpts.InputFilenames.front();
}
Opts.OutputFilenames = FrontendOpts.OutputFilenames;
Opts.ModuleName = FrontendOpts.ModuleName;
if (Args.hasArg(OPT_use_jit))
Opts.UseJIT = true;
for (const Arg *A : make_range(Args.filtered_begin(OPT_verify_type_layout),
Args.filtered_end())) {
Opts.VerifyTypeLayoutNames.push_back(A->getValue());
}
for (const Arg *A : make_range(Args.filtered_begin(
OPT_disable_autolink_framework),
Args.filtered_end())) {
Opts.DisableAutolinkFrameworks.push_back(A->getValue());
}
Opts.GenerateProfile |= Args.hasArg(OPT_profile_generate);
Opts.PrintInlineTree |= Args.hasArg(OPT_print_llvm_inline_tree);
if (Args.hasArg(OPT_embed_bitcode))
//.........这里部分代码省略.........
示例5: ParseIRGenArgs
//.........这里部分代码省略.........
if (StringRef(A->getValue()).getAsInteger(10, limit)) {
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
A->getAsString(Args), A->getValue());
return true;
}
Opts.StackPromotionSizeLimit = limit;
}
if (Args.hasArg(OPT_autolink_force_load))
Opts.ForceLoadSymbolName = Args.getLastArgValue(OPT_module_link_name);
Opts.ModuleName = FrontendOpts.ModuleName;
if (Args.hasArg(OPT_use_jit))
Opts.UseJIT = true;
for (const Arg *A : Args.filtered(OPT_verify_type_layout)) {
Opts.VerifyTypeLayoutNames.push_back(A->getValue());
}
for (const Arg *A : Args.filtered(OPT_disable_autolink_framework)) {
Opts.DisableAutolinkFrameworks.push_back(A->getValue());
}
Opts.GenerateProfile |= Args.hasArg(OPT_profile_generate);
const Arg *ProfileUse = Args.getLastArg(OPT_profile_use);
Opts.UseProfile = ProfileUse ? ProfileUse->getValue() : "";
Opts.PrintInlineTree |= Args.hasArg(OPT_print_llvm_inline_tree);
Opts.UseSwiftCall = Args.hasArg(OPT_enable_swiftcall);
// This is set to true by default.
Opts.UseIncrementalLLVMCodeGen &=
!Args.hasArg(OPT_disable_incremental_llvm_codegeneration);
if (Args.hasArg(OPT_embed_bitcode))
Opts.EmbedMode = IRGenEmbedMode::EmbedBitcode;
else if (Args.hasArg(OPT_embed_bitcode_marker))
Opts.EmbedMode = IRGenEmbedMode::EmbedMarker;
if (Opts.EmbedMode == IRGenEmbedMode::EmbedBitcode) {
// Keep track of backend options so we can embed them in a separate data
// section and use them when building from the bitcode. This can be removed
// when all the backend options are recorded in the IR.
for (const Arg *A : Args) {
// Do not encode output and input.
if (A->getOption().getID() == options::OPT_o ||
A->getOption().getID() == options::OPT_INPUT ||
A->getOption().getID() == options::OPT_primary_file ||
A->getOption().getID() == options::OPT_embed_bitcode)
continue;
ArgStringList ASL;
A->render(Args, ASL);
for (ArgStringList::iterator it = ASL.begin(), ie = ASL.end();
it != ie; ++ it) {
StringRef ArgStr(*it);
Opts.CmdArgs.insert(Opts.CmdArgs.end(), ArgStr.begin(), ArgStr.end());
// using \00 to terminate to avoid problem decoding.
Opts.CmdArgs.push_back('\0');
}
}
}
if (const Arg *A = Args.getLastArg(options::OPT_sanitize_coverage_EQ)) {
Opts.SanitizeCoverage =
parseSanitizerCoverageArgValue(A, Triple, Diags, Opts.Sanitizers);
} else if (Opts.Sanitizers & SanitizerKind::Fuzzer) {
// Automatically set coverage flags, unless coverage type was explicitly
// requested.
Opts.SanitizeCoverage.IndirectCalls = true;
Opts.SanitizeCoverage.TraceCmp = true;
Opts.SanitizeCoverage.TracePCGuard = true;
Opts.SanitizeCoverage.CoverageType = llvm::SanitizerCoverageOptions::SCK_Edge;
}
if (Args.hasArg(OPT_disable_reflection_metadata)) {
Opts.EnableReflectionMetadata = false;
Opts.EnableReflectionNames = false;
}
if (Args.hasArg(OPT_disable_reflection_names)) {
Opts.EnableReflectionNames = false;
}
if (Args.hasArg(OPT_enable_class_resilience)) {
Opts.EnableClassResilience = true;
}
if (Args.hasArg(OPT_enable_resilience_bypass)) {
Opts.EnableResilienceBypass = true;
}
for (const auto &Lib : Args.getAllArgValues(options::OPT_autolink_library))
Opts.LinkLibraries.push_back(LinkLibrary(Lib, LibraryKind::Library));
return false;
}
示例6: ParseIRGenArgs
//.........这里部分代码省略.........
Opts.GenerateProfile |= Args.hasArg(OPT_profile_generate);
const Arg *ProfileUse = Args.getLastArg(OPT_profile_use);
Opts.UseProfile = ProfileUse ? ProfileUse->getValue() : "";
Opts.PrintInlineTree |= Args.hasArg(OPT_print_llvm_inline_tree);
Opts.EnableDynamicReplacementChaining |=
Args.hasArg(OPT_enable_dynamic_replacement_chaining);
Opts.UseSwiftCall = Args.hasArg(OPT_enable_swiftcall);
// This is set to true by default.
Opts.UseIncrementalLLVMCodeGen &=
!Args.hasArg(OPT_disable_incremental_llvm_codegeneration);
if (Args.hasArg(OPT_embed_bitcode))
Opts.EmbedMode = IRGenEmbedMode::EmbedBitcode;
else if (Args.hasArg(OPT_embed_bitcode_marker))
Opts.EmbedMode = IRGenEmbedMode::EmbedMarker;
if (Opts.EmbedMode == IRGenEmbedMode::EmbedBitcode) {
// Keep track of backend options so we can embed them in a separate data
// section and use them when building from the bitcode. This can be removed
// when all the backend options are recorded in the IR.
for (const Arg *A : Args) {
// Do not encode output and input.
if (A->getOption().getID() == options::OPT_o ||
A->getOption().getID() == options::OPT_INPUT ||
A->getOption().getID() == options::OPT_primary_file ||
A->getOption().getID() == options::OPT_embed_bitcode)
continue;
ArgStringList ASL;
A->render(Args, ASL);
for (ArgStringList::iterator it = ASL.begin(), ie = ASL.end();
it != ie; ++ it) {
StringRef ArgStr(*it);
Opts.CmdArgs.insert(Opts.CmdArgs.end(), ArgStr.begin(), ArgStr.end());
// using \00 to terminate to avoid problem decoding.
Opts.CmdArgs.push_back('\0');
}
}
}
if (const Arg *A = Args.getLastArg(options::OPT_sanitize_coverage_EQ)) {
Opts.SanitizeCoverage =
parseSanitizerCoverageArgValue(A, Triple, Diags, Opts.Sanitizers);
} else if (Opts.Sanitizers & SanitizerKind::Fuzzer) {
// Automatically set coverage flags, unless coverage type was explicitly
// requested.
Opts.SanitizeCoverage.IndirectCalls = true;
Opts.SanitizeCoverage.TraceCmp = true;
Opts.SanitizeCoverage.TracePCGuard = true;
Opts.SanitizeCoverage.CoverageType = llvm::SanitizerCoverageOptions::SCK_Edge;
}
if (Args.hasArg(OPT_disable_reflection_metadata)) {
Opts.EnableReflectionMetadata = false;
Opts.EnableReflectionNames = false;
}
if (Args.hasArg(OPT_disable_reflection_names)) {
Opts.EnableReflectionNames = false;
}