当前位置: 首页>>代码示例>>C++>>正文


C++ opt::ArgList类代码示例

本文整理汇总了C++中llvm::opt::ArgList的典型用法代码示例。如果您正苦于以下问题:C++ ArgList类的具体用法?C++ ArgList怎么用?C++ ArgList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ArgList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addArgs

void SanitizerArgs::addArgs(const llvm::opt::ArgList &Args,
                            llvm::opt::ArgStringList &CmdArgs) const {
  if (!Kind)
    return;
  SmallString<256> SanitizeOpt("-fsanitize=");
#define SANITIZER(NAME, ID) \
  if (Kind & ID) \
    SanitizeOpt += NAME ",";
#include "clang/Basic/Sanitizers.def"
  SanitizeOpt.pop_back();
  CmdArgs.push_back(Args.MakeArgString(SanitizeOpt));
  if (!BlacklistFile.empty()) {
    SmallString<64> BlacklistOpt("-fsanitize-blacklist=");
    BlacklistOpt += BlacklistFile;
    CmdArgs.push_back(Args.MakeArgString(BlacklistOpt));
  }

  if (MsanTrackOrigins)
    CmdArgs.push_back(Args.MakeArgString("-fsanitize-memory-track-origins=" +
                                         llvm::utostr(MsanTrackOrigins)));

  // Workaround for PR16386.
  if (needsMsanRt())
    CmdArgs.push_back(Args.MakeArgString("-fno-assume-sane-operator-new"));
}
开发者ID:DragonToothSoftware,项目名称:clang,代码行数:25,代码来源:SanitizerArgs.cpp

示例2: addClangTargetOptions

void HIPToolChain::addClangTargetOptions(
    const llvm::opt::ArgList &DriverArgs,
    llvm::opt::ArgStringList &CC1Args,
    Action::OffloadKind DeviceOffloadingKind) const {
  HostTC.addClangTargetOptions(DriverArgs, CC1Args, DeviceOffloadingKind);

  StringRef GpuArch = DriverArgs.getLastArgValue(options::OPT_march_EQ);
  assert(!GpuArch.empty() && "Must have an explicit GPU arch.");
  (void) GpuArch;
  assert(DeviceOffloadingKind == Action::OFK_HIP &&
         "Only HIP offloading kinds are supported for GPUs.");

  CC1Args.push_back("-fcuda-is-device");

  if (DriverArgs.hasFlag(options::OPT_fcuda_flush_denormals_to_zero,
                         options::OPT_fno_cuda_flush_denormals_to_zero, false))
    CC1Args.push_back("-fcuda-flush-denormals-to-zero");

  if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
                         options::OPT_fno_cuda_approx_transcendentals, false))
    CC1Args.push_back("-fcuda-approx-transcendentals");

  if (DriverArgs.hasFlag(options::OPT_fcuda_rdc, options::OPT_fno_cuda_rdc,
                         false))
    CC1Args.push_back("-fcuda-rdc");
}
开发者ID:jaredmcneill,项目名称:netbsd-src,代码行数:26,代码来源:HIP.cpp

示例3: AddClangCXXStdlibIncludeArgs

void Cheerp::AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
                                           llvm::opt::ArgStringList &CC1Args) const {
  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
      DriverArgs.hasArg(options::OPT_nostdincxx))
    return;

  // Use the cheerp provided libc++
  addSystemInclude(DriverArgs, CC1Args,
		   LLVM_PREFIX "/include/c++/v1");
}
开发者ID:yohanip,项目名称:cheerp-clang,代码行数:10,代码来源:CheerpToolChain.cpp

示例4: addProfileRTLibs

void Linux::addProfileRTLibs(const llvm::opt::ArgList &Args,
                             llvm::opt::ArgStringList &CmdArgs) const {
  if (!needsProfileRT(Args)) return;

  // Add linker option -u__llvm_runtime_variable to cause runtime
  // initialization module to be linked in.
  if (!Args.hasArg(options::OPT_coverage))
    CmdArgs.push_back(Args.MakeArgString(
        Twine("-u", llvm::getInstrProfRuntimeHookVarName())));
  ToolChain::addProfileRTLibs(Args, CmdArgs);
}
开发者ID:bgabor666,项目名称:clang,代码行数:11,代码来源:Linux.cpp

示例5: lastArgumentForKind

std::string SanitizerArgs::lastArgumentForKind(const Driver &D,
                                               const llvm::opt::ArgList &Args,
                                               unsigned Kind) {
  for (llvm::opt::ArgList::const_reverse_iterator I = Args.rbegin(),
                                                  E = Args.rend();
       I != E; ++I) {
    unsigned Add, Remove;
    if (parse(D, Args, *I, Add, Remove, false) &&
        (expandGroups(Add) & Kind))
      return describeSanitizeArg(Args, *I, Kind);
    Kind &= ~Remove;
  }
  llvm_unreachable("arg list didn't provide expected value");
}
开发者ID:DragonToothSoftware,项目名称:clang,代码行数:14,代码来源:SanitizerArgs.cpp

示例6: AddClangSystemIncludeArgs

void CrossWindowsToolChain::
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
                          llvm::opt::ArgStringList &CC1Args) const {
    const Driver &D = getDriver();
    const std::string &SysRoot = D.SysRoot;

    if (DriverArgs.hasArg(options::OPT_nostdlibinc))
        return;

    addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
    if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
        SmallString<128> ResourceDir(D.ResourceDir);
        llvm::sys::path::append(ResourceDir, "include");
        addSystemInclude(DriverArgs, CC1Args, ResourceDir);
    }
    addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
}
开发者ID:kwasimensah,项目名称:clang,代码行数:17,代码来源:CrossWindowsToolChain.cpp

示例7: ToolChain

Cheerp::Cheerp(const Driver &D, const llvm::Triple& Triple, const llvm::opt::ArgList &Args)
  : ToolChain(D, Triple, Args) {

  getProgramPaths().push_back(LLVM_PREFIX "/bin");

  path_list& filePaths = getFilePaths();

  // Add default path
  filePaths.push_back(LLVM_PREFIX "/lib");

  // Add paths passed from the command line
  for (arg_iterator it = Args.filtered_begin(options::OPT_L),
         ie = Args.filtered_end(); it != ie; ++it) {
    (*it)->claim();
    filePaths.push_back((*it)->getValue());
  }
}
开发者ID:yohanip,项目名称:cheerp-clang,代码行数:17,代码来源:CheerpToolChain.cpp

示例8: addClangTargetOptions

void CudaToolChain::addClangTargetOptions(
    const llvm::opt::ArgList &DriverArgs,
    llvm::opt::ArgStringList &CC1Args,
    Action::OffloadKind DeviceOffloadingKind) const {
  HostTC.addClangTargetOptions(DriverArgs, CC1Args, DeviceOffloadingKind);

  StringRef GpuArch = DriverArgs.getLastArgValue(options::OPT_march_EQ);
  assert(!GpuArch.empty() && "Must have an explicit GPU arch.");
  assert((DeviceOffloadingKind == Action::OFK_OpenMP ||
          DeviceOffloadingKind == Action::OFK_Cuda) &&
         "Only OpenMP or CUDA offloading kinds are supported for NVIDIA GPUs.");

  if (DeviceOffloadingKind == Action::OFK_Cuda) {
    CC1Args.push_back("-fcuda-is-device");

    if (DriverArgs.hasFlag(options::OPT_fcuda_flush_denormals_to_zero,
                           options::OPT_fno_cuda_flush_denormals_to_zero, false))
      CC1Args.push_back("-fcuda-flush-denormals-to-zero");

    if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
                           options::OPT_fno_cuda_approx_transcendentals, false))
      CC1Args.push_back("-fcuda-approx-transcendentals");

    if (DriverArgs.hasArg(options::OPT_nocudalib))
      return;
  }

  std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);

  if (LibDeviceFile.empty()) {
    getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
    return;
  }

  CC1Args.push_back("-mlink-cuda-bitcode");
  CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));

  // Libdevice in CUDA-7.0 requires PTX version that's more recent
  // than LLVM defaults to. Use PTX4.2 which is the PTX version that
  // came with CUDA-7.0.
  CC1Args.push_back("-target-feature");
  CC1Args.push_back("+ptx42");
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:43,代码来源:Cuda.cpp

示例9: lastArgumentForMask

std::string lastArgumentForMask(const Driver &D, const llvm::opt::ArgList &Args,
                                SanitizerMask Mask) {
  for (llvm::opt::ArgList::const_reverse_iterator I = Args.rbegin(),
                                                  E = Args.rend();
       I != E; ++I) {
    const auto *Arg = *I;
    if (Arg->getOption().matches(options::OPT_fsanitize_EQ)) {
      SanitizerMask AddKinds =
          expandSanitizerGroups(parseArgValues(D, Arg, false));
      if (AddKinds & Mask)
        return describeSanitizeArg(Arg, Mask);
    } else if (Arg->getOption().matches(options::OPT_fno_sanitize_EQ)) {
      SanitizerMask RemoveKinds =
          expandSanitizerGroups(parseArgValues(D, Arg, false));
      Mask &= ~RemoveKinds;
    }
  }
  llvm_unreachable("arg list didn't provide expected value");
}
开发者ID:alessandrostone,项目名称:metashell,代码行数:19,代码来源:SanitizerArgs.cpp

示例10: AddClangSystemIncludeArgs

void Cheerp::AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
                                        llvm::opt::ArgStringList &CC1Args) const {
  if (DriverArgs.hasArg(options::OPT_nostdinc))
    return;

  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
    SmallString<128> P(getDriver().ResourceDir);
    llvm::sys::path::append(P, "include");
    addSystemInclude(DriverArgs, CC1Args, P.str());
  }

  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
    return;

  addExternCSystemInclude(DriverArgs, CC1Args,
		  LLVM_PREFIX "/include");
  addExternCSystemInclude(DriverArgs, CC1Args,
		  LLVM_PREFIX "/include/client");
}
开发者ID:yohanip,项目名称:cheerp-clang,代码行数:19,代码来源:CheerpToolChain.cpp

示例11: parseSanitizeTrapArgs

static SanitizerMask parseSanitizeTrapArgs(const Driver &D,
                                           const llvm::opt::ArgList &Args) {
  SanitizerMask TrapRemove = 0; // During the loop below, the accumulated set of
                                // sanitizers disabled by the current sanitizer
                                // argument or any argument after it.
  SanitizerMask TrappingKinds = 0;
  SanitizerMask TrappingSupportedWithGroups = setGroupBits(TrappingSupported);

  for (ArgList::const_reverse_iterator I = Args.rbegin(), E = Args.rend();
       I != E; ++I) {
    const auto *Arg = *I;
    if (Arg->getOption().matches(options::OPT_fsanitize_trap_EQ)) {
      Arg->claim();
      SanitizerMask Add = parseArgValues(D, Arg, true);
      Add &= ~TrapRemove;
      if (SanitizerMask InvalidValues = Add & ~TrappingSupportedWithGroups) {
        SanitizerSet S;
        S.Mask = InvalidValues;
        D.Diag(diag::err_drv_unsupported_option_argument) << "-fsanitize-trap"
                                                          << toString(S);
      }
      TrappingKinds |= expandSanitizerGroups(Add) & ~TrapRemove;
    } else if (Arg->getOption().matches(options::OPT_fno_sanitize_trap_EQ)) {
      Arg->claim();
      TrapRemove |= expandSanitizerGroups(parseArgValues(D, Arg, true));
    } else if (Arg->getOption().matches(
                   options::OPT_fsanitize_undefined_trap_on_error)) {
      Arg->claim();
      TrappingKinds |=
          expandSanitizerGroups(UndefinedGroup & ~TrapRemove) & ~TrapRemove;
    } else if (Arg->getOption().matches(
                   options::OPT_fno_sanitize_undefined_trap_on_error)) {
      Arg->claim();
      TrapRemove |= expandSanitizerGroups(UndefinedGroup);
    }
  }

  // Apply default trapping behavior.
  TrappingKinds |= TrappingDefault & ~TrapRemove;

  return TrappingKinds;
}
开发者ID:alessandrostone,项目名称:metashell,代码行数:42,代码来源:SanitizerArgs.cpp

示例12: VersionTuple

VersionTuple
ToolChain::computeMSVCVersion(const Driver *D,
                              const llvm::opt::ArgList &Args) const {
  const Arg *MSCVersion = Args.getLastArg(options::OPT_fmsc_version);
  const Arg *MSCompatibilityVersion =
      Args.getLastArg(options::OPT_fms_compatibility_version);

  if (MSCVersion && MSCompatibilityVersion) {
    if (D)
      D->Diag(diag::err_drv_argument_not_allowed_with)
          << MSCVersion->getAsString(Args)
          << MSCompatibilityVersion->getAsString(Args);
    return VersionTuple();
  }

  if (MSCompatibilityVersion) {
    VersionTuple MSVT;
    if (MSVT.tryParse(MSCompatibilityVersion->getValue())) {
      if (D)
        D->Diag(diag::err_drv_invalid_value)
            << MSCompatibilityVersion->getAsString(Args)
            << MSCompatibilityVersion->getValue();
    } else {
      return MSVT;
    }
  }

  if (MSCVersion) {
    unsigned Version = 0;
    if (StringRef(MSCVersion->getValue()).getAsInteger(10, Version)) {
      if (D)
        D->Diag(diag::err_drv_invalid_value)
            << MSCVersion->getAsString(Args) << MSCVersion->getValue();
    } else {
      return separateMSVCFullVersion(Version);
    }
  }

  return VersionTuple();
}
开发者ID:LegalizeAdulthood,项目名称:clang,代码行数:40,代码来源:ToolChain.cpp

示例13: addIncludeLinkerOption

static void addIncludeLinkerOption(const ToolChain &TC,
                                   const llvm::opt::ArgList &Args,
                                   llvm::opt::ArgStringList &CmdArgs,
                                   StringRef SymbolName) {
  SmallString<64> LinkerOptionFlag;
  LinkerOptionFlag = "--linker-option=/include:";
  if (TC.getTriple().getArch() == llvm::Triple::x86) {
    // Win32 mangles C function names with a '_' prefix.
    LinkerOptionFlag += '_';
  }
  LinkerOptionFlag += SymbolName;
  CmdArgs.push_back(Args.MakeArgString(LinkerOptionFlag));
}
开发者ID:bytefactory73,项目名称:clang,代码行数:13,代码来源:SanitizerArgs.cpp

示例14: AddClangCXXStdlibIncludeArgs

void CrossWindowsToolChain::
AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
                             llvm::opt::ArgStringList &CC1Args) const {
  const llvm::Triple &Triple = getTriple();
  const std::string &SysRoot = getDriver().SysRoot;

  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
      DriverArgs.hasArg(options::OPT_nostdincxx))
    return;

  switch (GetCXXStdlibType(DriverArgs)) {
  case ToolChain::CST_Libcxx:
    addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include/c++/v1");
    break;

  case ToolChain::CST_Libstdcxx:
    addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include/c++");
    addSystemInclude(DriverArgs, CC1Args,
                     SysRoot + "/usr/include/c++/" + Triple.str());
    addSystemInclude(DriverArgs, CC1Args,
                     SysRoot + "/usr/include/c++/backwards");
  }
}
开发者ID:Aj0Ay,项目名称:clang,代码行数:23,代码来源:CrossWindowsToolChain.cpp

示例15: addArgs

void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
                            llvm::opt::ArgStringList &CmdArgs) const {
  if (!Kind)
    return;
  const Driver &D = TC.getDriver();
  SmallString<256> SanitizeOpt("-fsanitize=");
#define SANITIZER(NAME, ID) \
  if (Kind & ID) \
    SanitizeOpt += NAME ",";
#include "clang/Basic/Sanitizers.def"
  SanitizeOpt.pop_back();
  CmdArgs.push_back(Args.MakeArgString(SanitizeOpt));
  if (!BlacklistFile.empty()) {
    SmallString<64> BlacklistOpt("-fsanitize-blacklist=");
    BlacklistOpt += BlacklistFile;
    CmdArgs.push_back(Args.MakeArgString(BlacklistOpt));
  }

  if (MsanTrackOrigins)
    CmdArgs.push_back(Args.MakeArgString("-fsanitize-memory-track-origins"));

  if (needsAsanRt()) {
    if (hasAsanZeroBaseShadow(TC)) {
      CmdArgs.push_back(
          Args.MakeArgString("-fsanitize-address-zero-base-shadow"));
    } else if (TC.getTriple().getEnvironment() == llvm::Triple::Android) {
      // Zero-base shadow is a requirement on Android.
      D.Diag(diag::err_drv_argument_not_allowed_with)
          << "-fno-sanitize-address-zero-base-shadow"
          << lastArgumentForKind(D, Args, Address);
    }
  }

  // Workaround for PR16386.
  if (needsMsanRt())
    CmdArgs.push_back(Args.MakeArgString("-fno-assume-sane-operator-new"));
}
开发者ID:EasyHard,项目名称:clang,代码行数:37,代码来源:SanitizerArgs.cpp


注:本文中的llvm::opt::ArgList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。