/// Returns the mapped key, or the appropriate Minimum / MaximumValue if
/// they key is outside of the mapping bounds. If they key isn't mapped, but
/// within the minimum and maximum bounds, None is returned.
- Optional<VersionTuple> map(const VersionTuple &Key,
- const VersionTuple &MinimumValue,
- Optional<VersionTuple> MaximumValue) const;
+ std::optional<VersionTuple>
+ map(const VersionTuple &Key, const VersionTuple &MinimumValue,
+ std::optional<VersionTuple> MaximumValue) const;
static Optional<RelatedTargetVersionMapping>
parseJSON(const llvm::json::Object &Obj,
return Mapping->getSecond() ? &*Mapping->getSecond() : nullptr;
}
- static Optional<DarwinSDKInfo>
+ static std::optional<DarwinSDKInfo>
parseDarwinSDKSettingsJSON(const llvm::json::Object *Obj);
private:
///
/// \returns an error if the SDKSettings.json file is invalid, None if the
/// SDK has no SDKSettings.json, or a valid \c DarwinSDKInfo otherwise.
-Expected<Optional<DarwinSDKInfo>> parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS,
- StringRef SDKRootPath);
+Expected<std::optional<DarwinSDKInfo>>
+parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, StringRef SDKRootPath);
} // end namespace clang
/// Get the conflicted pair of target IDs for a compilation or a bundled code
/// object, assuming \p TargetIDs are canonicalized. If there is no conflicts,
/// returns None.
-llvm::Optional<std::pair<llvm::StringRef, llvm::StringRef>>
+std::optional<std::pair<llvm::StringRef, llvm::StringRef>>
getConflictTargetIDCombination(const std::set<llvm::StringRef> &TargetIDs);
/// Check whether the provided target ID is compatible with the requested
EffectiveTriple = std::move(ET);
}
- mutable llvm::Optional<CXXStdlibType> cxxStdlibType;
- mutable llvm::Optional<RuntimeLibType> runtimeLibType;
- mutable llvm::Optional<UnwindLibType> unwindLibType;
+ mutable std::optional<CXXStdlibType> cxxStdlibType;
+ mutable std::optional<RuntimeLibType> runtimeLibType;
+ mutable std::optional<UnwindLibType> unwindLibType;
protected:
MultilibSet Multilibs;
using namespace clang;
-Optional<VersionTuple> DarwinSDKInfo::RelatedTargetVersionMapping::map(
+std::optional<VersionTuple> DarwinSDKInfo::RelatedTargetVersionMapping::map(
const VersionTuple &Key, const VersionTuple &MinimumValue,
- Optional<VersionTuple> MaximumValue) const {
+ std::optional<VersionTuple> MaximumValue) const {
if (Key < MinimumKeyVersion)
return MinimumValue;
if (Key > MaximumKeyVersion)
return Version;
}
-Optional<DarwinSDKInfo>
+std::optional<DarwinSDKInfo>
DarwinSDKInfo::parseDarwinSDKSettingsJSON(const llvm::json::Object *Obj) {
auto Version = getVersionKey(*Obj, "Version");
if (!Version)
std::move(VersionMappings));
}
-Expected<Optional<DarwinSDKInfo>>
+Expected<std::optional<DarwinSDKInfo>>
clang::parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, StringRef SDKRootPath) {
llvm::SmallString<256> Filepath = SDKRootPath;
llvm::sys::path::append(Filepath, "SDKSettings.json");
// For a specific processor, a feature either shows up in all target IDs, or
// does not show up in any target IDs. Otherwise the target ID combination
// is invalid.
-llvm::Optional<std::pair<llvm::StringRef, llvm::StringRef>>
+std::optional<std::pair<llvm::StringRef, llvm::StringRef>>
getConflictTargetIDCombination(const std::set<llvm::StringRef> &TargetIDs) {
struct Info {
llvm::StringRef TargetID;
using namespace clang;
using namespace llvm::opt;
-static llvm::Optional<llvm::Triple>
-getOffloadTargetTriple(const Driver &D, const ArgList &Args) {
+static std::optional<llvm::Triple> getOffloadTargetTriple(const Driver &D,
+ const ArgList &Args) {
auto OffloadTargets = Args.getAllArgValues(options::OPT_offload_EQ);
// Offload compilation flow does not support multiple targets for now. We
// need the HIPActionBuilder (and possibly the CudaActionBuilder{,Base}too)
return llvm::Triple(OffloadTargets[0]);
}
-static llvm::Optional<llvm::Triple>
+static std::optional<llvm::Triple>
getNVIDIAOffloadTargetTriple(const Driver &D, const ArgList &Args,
const llvm::Triple &HostTriple) {
if (!Args.hasArg(options::OPT_offload_EQ)) {
D.Diag(diag::err_drv_invalid_or_unsupported_offload_target) << TT->str();
return std::nullopt;
}
-static llvm::Optional<llvm::Triple>
+static std::optional<llvm::Triple>
getHIPOffloadTargetTriple(const Driver &D, const ArgList &Args) {
if (!Args.hasArg(options::OPT_offload_EQ)) {
return llvm::Triple("amdgcn-amd-amdhsa"); // Default HIP triple.
void Driver::setDriverMode(StringRef Value) {
static const std::string OptName =
getOpts().getOption(options::OPT_driver_mode).getPrefixedName();
- if (auto M = llvm::StringSwitch<llvm::Optional<DriverMode>>(Value)
+ if (auto M = llvm::StringSwitch<std::optional<DriverMode>>(Value)
.Case("gcc", GCCMode)
.Case("g++", GXXMode)
.Case("cpp", CPPMode)
/// option is invalid.
virtual StringRef getCanonicalOffloadArch(StringRef Arch) = 0;
- virtual llvm::Optional<std::pair<llvm::StringRef, llvm::StringRef>>
+ virtual std::optional<std::pair<llvm::StringRef, llvm::StringRef>>
getConflictOffloadArchCombination(const std::set<StringRef> &GpuArchs) = 0;
bool initialize() override {
return CudaArchToString(Arch);
}
- llvm::Optional<std::pair<llvm::StringRef, llvm::StringRef>>
+ std::optional<std::pair<llvm::StringRef, llvm::StringRef>>
getConflictOffloadArchCombination(
const std::set<StringRef> &GpuArchs) override {
return std::nullopt;
// Bundle code objects except --no-gpu-output is specified for device
// only compilation. Bundle other type of output files only if
// --gpu-bundle-output is specified for device only compilation.
- Optional<bool> BundleOutput;
+ std::optional<bool> BundleOutput;
public:
HIPActionBuilder(Compilation &C, DerivedArgList &Args,
return Args.MakeArgStringRef(CanId);
};
- llvm::Optional<std::pair<llvm::StringRef, llvm::StringRef>>
+ std::optional<std::pair<llvm::StringRef, llvm::StringRef>>
getConflictOffloadArchCombination(
const std::set<StringRef> &GpuArchs) override {
return getConflictTargetIDCombination(GpuArchs);
/// Checks if the set offloading architectures does not conflict. Returns the
/// incompatible pair if a conflict occurs.
-static llvm::Optional<std::pair<llvm::StringRef, llvm::StringRef>>
+static std::optional<std::pair<llvm::StringRef, llvm::StringRef>>
getConflictOffloadArchCombination(const llvm::DenseSet<StringRef> &Archs,
Action::OffloadKind Kind) {
if (Kind != Action::OFK_HIP)
std::string Driver::GetFilePath(StringRef Name, const ToolChain &TC) const {
// Search for Name in a list of paths.
auto SearchPaths = [&](const llvm::SmallVectorImpl<std::string> &P)
- -> llvm::Optional<std::string> {
+ -> std::optional<std::string> {
// Respect a limited subset of the '-Bprefix' functionality in GCC by
// attempting to use this prefix when looking for file paths.
for (const auto &Dir : P) {
/// Read the marker of the next bundled to be read in the file. The bundle
/// name is returned if there is one in the file, or `None` if there are no
/// more bundles to be read.
- virtual Expected<Optional<StringRef>>
+ virtual Expected<std::optional<StringRef>>
ReadBundleStart(MemoryBuffer &Input) = 0;
/// Read the marker that closes the current bundle.
Error forEachBundle(MemoryBuffer &Input,
std::function<Error(const BundleInfo &)> Func) {
while (true) {
- Expected<Optional<StringRef>> CurTripleOrErr = ReadBundleStart(Input);
+ Expected<std::optional<StringRef>> CurTripleOrErr =
+ ReadBundleStart(Input);
if (!CurTripleOrErr)
return CurTripleOrErr.takeError();
return Error::success();
}
- Expected<Optional<StringRef>> ReadBundleStart(MemoryBuffer &Input) final {
+ Expected<std::optional<StringRef>>
+ ReadBundleStart(MemoryBuffer &Input) final {
if (NextBundleInfo == BundlesInfo.end())
return std::nullopt;
CurBundleInfo = NextBundleInfo++;
}
// Creates temporary file with given contents.
- Expected<StringRef> Create(Optional<ArrayRef<char>> Contents) {
+ Expected<StringRef> Create(std::optional<ArrayRef<char>> Contents) {
SmallString<128u> File;
if (std::error_code EC =
sys::fs::createTemporaryFile("clang-offload-bundler", "tmp", File))
/// Return bundle name (<kind>-<triple>) if the provided section is an offload
/// section.
- static Expected<Optional<StringRef>> IsOffloadSection(SectionRef CurSection) {
+ static Expected<std::optional<StringRef>>
+ IsOffloadSection(SectionRef CurSection) {
Expected<StringRef> NameOrErr = CurSection.getName();
if (!NameOrErr)
return NameOrErr.takeError();
Error ReadHeader(MemoryBuffer &Input) final { return Error::success(); }
- Expected<Optional<StringRef>> ReadBundleStart(MemoryBuffer &Input) final {
+ Expected<std::optional<StringRef>>
+ ReadBundleStart(MemoryBuffer &Input) final {
while (NextSection != Obj->section_end()) {
CurrentSection = NextSection;
++NextSection;
// Check if the current section name starts with the reserved prefix. If
// so, return the triple.
- Expected<Optional<StringRef>> TripleOrErr =
+ Expected<std::optional<StringRef>> TripleOrErr =
IsOffloadSection(*CurrentSection);
if (!TripleOrErr)
return TripleOrErr.takeError();
protected:
Error ReadHeader(MemoryBuffer &Input) final { return Error::success(); }
- Expected<Optional<StringRef>> ReadBundleStart(MemoryBuffer &Input) final {
+ Expected<std::optional<StringRef>>
+ ReadBundleStart(MemoryBuffer &Input) final {
StringRef FC = Input.getBuffer();
// Find start of the bundle.
// assume the file is meant for the host target.
bool FoundHostBundle = false;
while (!Worklist.empty()) {
- Expected<Optional<StringRef>> CurTripleOrErr = FH->ReadBundleStart(Input);
+ Expected<std::optional<StringRef>> CurTripleOrErr =
+ FH->ReadBundleStart(Input);
if (!CurTripleOrErr)
return CurTripleOrErr.takeError();
if (Error ReadErr = FileHandler.get()->ReadHeader(*CodeObjectBuffer))
return ReadErr;
- Expected<Optional<StringRef>> CurBundleIDOrErr =
+ Expected<std::optional<StringRef>> CurBundleIDOrErr =
FileHandler->ReadBundleStart(*CodeObjectBuffer);
if (!CurBundleIDOrErr)
return CurBundleIDOrErr.takeError();
- Optional<StringRef> OptionalCurBundleID = *CurBundleIDOrErr;
+ std::optional<StringRef> OptionalCurBundleID = *CurBundleIDOrErr;
// No device code in this child, skip.
if (!OptionalCurBundleID)
continue;
if (Error Err = FileHandler.get()->ReadBundleEnd(*CodeObjectBuffer))
return Err;
- Expected<Optional<StringRef>> NextTripleOrErr =
+ Expected<std::optional<StringRef>> NextTripleOrErr =
FileHandler->ReadBundleStart(*CodeObjectBuffer);
if (!NextTripleOrErr)
return NextTripleOrErr.takeError();
/// The struct type returned by getParsedTargetID.
struct ParsedTargetIDType {
- Optional<std::string> OptionalTargetID;
- Optional<std::string> OptionalGPUArch;
- Optional<llvm::StringMap<bool>> OptionalFeatures;
+ std::optional<std::string> OptionalTargetID;
+ std::optional<std::string> OptionalGPUArch;
+ std::optional<llvm::StringMap<bool>> OptionalFeatures;
};
/// Get target ID, GPU arch, and target ID features if the target ID is
return "";
}
-llvm::Optional<StringRef> GetMCUFamilyName(StringRef MCUName) {
+std::optional<StringRef> GetMCUFamilyName(StringRef MCUName) {
for (const auto &MCU : MCUInfo)
if (MCU.Name == MCUName)
- return Optional<StringRef>(MCU.Family);
+ return std::optional<StringRef>(MCU.Family);
return std::nullopt;
}
-llvm::Optional<unsigned> GetMCUSectionAddressData(StringRef MCUName) {
+std::optional<unsigned> GetMCUSectionAddressData(StringRef MCUName) {
for (const auto &MCU : MCUInfo)
if (MCU.Name == MCUName && MCU.DataAddr > 0)
- return Optional<unsigned>(MCU.DataAddr);
+ return std::optional<unsigned>(MCU.DataAddr);
return std::nullopt;
}
return;
// Omit if there is no avr-libc installed.
- Optional<std::string> AVRLibcRoot = findAVRLibcInstallation();
+ std::optional<std::string> AVRLibcRoot = findAVRLibcInstallation();
if (!AVRLibcRoot)
return;
// Compute information about the target AVR.
std::string CPU = getCPUName(D, Args, getToolChain().getTriple());
- llvm::Optional<StringRef> FamilyName = GetMCUFamilyName(CPU);
- llvm::Optional<std::string> AVRLibcRoot = TC.findAVRLibcInstallation();
- llvm::Optional<unsigned> SectionAddressData = GetMCUSectionAddressData(CPU);
+ std::optional<StringRef> FamilyName = GetMCUFamilyName(CPU);
+ std::optional<std::string> AVRLibcRoot = TC.findAVRLibcInstallation();
+ std::optional<unsigned> SectionAddressData = GetMCUSectionAddressData(CPU);
// Compute the linker program path, and use GNU "avr-ld" as default.
const Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ);
CmdArgs, Inputs, Output));
}
-llvm::Optional<std::string> AVRToolChain::findAVRLibcInstallation() const {
+std::optional<std::string> AVRToolChain::findAVRLibcInstallation() const {
// Search avr-libc installation according to avr-gcc installation.
std::string GCCParent(GCCInstallation.getParentLibPath());
std::string Path(GCCParent + "/avr");
llvm::opt::ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadKind) const override;
- llvm::Optional<std::string> findAVRLibcInstallation() const;
+ std::optional<std::string> findAVRLibcInstallation() const;
StringRef getGCCInstallPath() const { return GCCInstallPath; }
std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
FileType Type) const override;
bool KernelOrKext =
Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
arm::FloatABI ABI = arm::getARMFloatABI(D, Triple, Args);
- llvm::Optional<std::pair<const Arg *, StringRef>> WaCPU, WaFPU, WaHDiv,
- WaArch;
+ std::optional<std::pair<const Arg *, StringRef>> WaCPU, WaFPU, WaHDiv, WaArch;
// This vector will accumulate features from the architecture
// extension suffixes on -mcpu and -march (e.g. the 'bar' in
using namespace clang;
using namespace llvm::opt;
-llvm::Optional<llvm::StringRef>
+std::optional<llvm::StringRef>
csky::getCSKYArchName(const Driver &D, const ArgList &Args,
const llvm::Triple &Triple) {
if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
D.Diag(clang::diag::err_drv_invalid_arch_name) << A->getAsString(Args);
return std::nullopt;
}
- return llvm::Optional<llvm::StringRef>(A->getValue());
+ return std::optional<llvm::StringRef>(A->getValue());
}
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) {
D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
return std::nullopt;
}
- return llvm::Optional<llvm::StringRef>(llvm::CSKY::getArchName(ArchKind));
+ return std::optional<llvm::StringRef>(llvm::CSKY::getArchName(ArchKind));
}
- return llvm::Optional<llvm::StringRef>("ck810");
+ return std::optional<llvm::StringRef>("ck810");
}
csky::FloatABI csky::getCSKYFloatABI(const Driver &D, const ArgList &Args) {
llvm::opt::ArgStringList &CmdArgs,
std::vector<llvm::StringRef> &Features);
-llvm::Optional<llvm::StringRef> getCSKYArchName(const Driver &D,
- const llvm::opt::ArgList &Args,
- const llvm::Triple &Triple);
+std::optional<llvm::StringRef> getCSKYArchName(const Driver &D,
+ const llvm::opt::ArgList &Args,
+ const llvm::Triple &Triple);
} // end namespace csky
} // namespace tools
// None otherwise.
auto StartsWithWords =
[](llvm::StringRef Line,
- const SmallVector<StringRef, 3> words) -> llvm::Optional<StringRef> {
+ const SmallVector<StringRef, 3> words) -> std::optional<StringRef> {
for (StringRef word : words) {
if (!Line.consume_front(word))
return {};
/// Returns true if the simulator environment can be inferred from the arch.
bool canInferSimulatorFromArch() const { return InferSimulatorFromArch; }
- const Optional<llvm::Triple> &getTargetVariantTriple() const {
+ const std::optional<llvm::Triple> &getTargetVariantTriple() const {
return TargetVariantTriple;
}
void setEnvironment(llvm::Triple::EnvironmentType EnvType,
const VersionTuple &OSVersion,
- const Optional<DarwinSDKInfo> &SDKInfo) {
+ const std::optional<DarwinSDKInfo> &SDKInfo) {
switch (EnvType) {
case llvm::Triple::Simulator:
Environment = DarwinEnvironmentKind::Simulator;
static DarwinPlatform
createFromTarget(const llvm::Triple &TT, StringRef OSVersion, Arg *A,
- Optional<llvm::Triple> TargetVariantTriple,
- const Optional<DarwinSDKInfo> &SDKInfo) {
+ std::optional<llvm::Triple> TargetVariantTriple,
+ const std::optional<DarwinSDKInfo> &SDKInfo) {
DarwinPlatform Result(TargetArg, getPlatformFromOS(TT.getOS()), OSVersion,
A);
VersionTuple OsVersion = TT.getOSVersion();
static DarwinPlatform
createFromMTargetOS(llvm::Triple::OSType OS, VersionTuple OSVersion,
llvm::Triple::EnvironmentType Environment, Arg *A,
- const Optional<DarwinSDKInfo> &SDKInfo) {
+ const std::optional<DarwinSDKInfo> &SDKInfo) {
DarwinPlatform Result(MTargetOSArg, getPlatformFromOS(OS),
OSVersion.getAsString(), A);
Result.InferSimulatorFromArch = false;
bool HasOSVersion = true, InferSimulatorFromArch = true;
Arg *Argument;
StringRef EnvVarName;
- Optional<llvm::Triple> TargetVariantTriple;
+ std::optional<llvm::Triple> TargetVariantTriple;
};
/// Returns the deployment target that's specified using the -m<os>-version-min
/// argument.
-Optional<DarwinPlatform>
+std::optional<DarwinPlatform>
getDeploymentTargetFromOSVersionArg(DerivedArgList &Args,
const Driver &TheDriver) {
Arg *macOSVersion = Args.getLastArg(options::OPT_mmacos_version_min_EQ);
/// Returns the deployment target that's specified using the
/// OS_DEPLOYMENT_TARGET environment variable.
-Optional<DarwinPlatform>
+std::optional<DarwinPlatform>
getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver,
const llvm::Triple &Triple) {
std::string Targets[Darwin::LastDarwinPlatform + 1];
/// Tries to infer the deployment target from the SDK specified by -isysroot
/// (or SDKROOT). Uses the version specified in the SDKSettings.json file if
/// it's available.
-Optional<DarwinPlatform>
+std::optional<DarwinPlatform>
inferDeploymentTargetFromSDK(DerivedArgList &Args,
- const Optional<DarwinSDKInfo> &SDKInfo) {
+ const std::optional<DarwinSDKInfo> &SDKInfo) {
const Arg *A = Args.getLastArg(options::OPT_isysroot);
if (!A)
return std::nullopt;
return std::nullopt;
auto CreatePlatformFromSDKName =
- [&](StringRef SDK) -> Optional<DarwinPlatform> {
+ [&](StringRef SDK) -> std::optional<DarwinPlatform> {
if (SDK.startswith("iPhoneOS") || SDK.startswith("iPhoneSimulator"))
return DarwinPlatform::createFromSDK(
Darwin::IPhoneOS, Version,
}
/// Tries to infer the target OS from the -arch.
-Optional<DarwinPlatform>
+std::optional<DarwinPlatform>
inferDeploymentTargetFromArch(DerivedArgList &Args, const Darwin &Toolchain,
const llvm::Triple &Triple,
const Driver &TheDriver) {
}
/// Returns the deployment target that's specified using the -target option.
-Optional<DarwinPlatform> getDeploymentTargetFromTargetArg(
+std::optional<DarwinPlatform> getDeploymentTargetFromTargetArg(
DerivedArgList &Args, const llvm::Triple &Triple, const Driver &TheDriver,
- const Optional<DarwinSDKInfo> &SDKInfo) {
+ const std::optional<DarwinSDKInfo> &SDKInfo) {
if (!Args.hasArg(options::OPT_target))
return std::nullopt;
if (Triple.getOS() == llvm::Triple::Darwin ||
Triple.getOS() == llvm::Triple::UnknownOS)
return std::nullopt;
std::string OSVersion = getOSVersion(Triple.getOS(), Triple, TheDriver);
- Optional<llvm::Triple> TargetVariantTriple;
+ std::optional<llvm::Triple> TargetVariantTriple;
for (const Arg *A : Args.filtered(options::OPT_darwin_target_variant)) {
llvm::Triple TVT(A->getValue());
// Find a matching <arch>-<vendor> target variant triple that can be used.
}
/// Returns the deployment target that's specified using the -mtargetos option.
-Optional<DarwinPlatform>
-getDeploymentTargetFromMTargetOSArg(DerivedArgList &Args,
- const Driver &TheDriver,
- const Optional<DarwinSDKInfo> &SDKInfo) {
+std::optional<DarwinPlatform> getDeploymentTargetFromMTargetOSArg(
+ DerivedArgList &Args, const Driver &TheDriver,
+ const std::optional<DarwinSDKInfo> &SDKInfo) {
auto *A = Args.getLastArg(options::OPT_mtargetos_EQ);
if (!A)
return std::nullopt;
TT.getEnvironment(), A, SDKInfo);
}
-Optional<DarwinSDKInfo> parseSDKSettings(llvm::vfs::FileSystem &VFS,
- const ArgList &Args,
- const Driver &TheDriver) {
+std::optional<DarwinSDKInfo> parseSDKSettings(llvm::vfs::FileSystem &VFS,
+ const ArgList &Args,
+ const Driver &TheDriver) {
const Arg *A = Args.getLastArg(options::OPT_isysroot);
if (!A)
return std::nullopt;
SDKInfo = parseSDKSettings(getVFS(), Args, getDriver());
// The OS and the version can be specified using the -target argument.
- Optional<DarwinPlatform> OSTarget =
+ std::optional<DarwinPlatform> OSTarget =
getDeploymentTargetFromTargetArg(Args, getTriple(), getDriver(), SDKInfo);
if (OSTarget) {
// Disallow mixing -target and -mtargetos=.
getDriver().Diag(diag::err_drv_cannot_mix_options)
<< TargetArgStr << MTargetOSArgStr;
}
- Optional<DarwinPlatform> OSVersionArgTarget =
+ std::optional<DarwinPlatform> OSVersionArgTarget =
getDeploymentTargetFromOSVersionArg(Args, getDriver());
if (OSVersionArgTarget) {
unsigned TargetMajor, TargetMinor, TargetMicro;
SDKInfo))) {
// The OS target can be specified using the -mtargetos= argument.
// Disallow mixing -mtargetos= and -m<os>version-min=.
- Optional<DarwinPlatform> OSVersionArgTarget =
+ std::optional<DarwinPlatform> OSVersionArgTarget =
getDeploymentTargetFromOSVersionArg(Args, getDriver());
if (OSVersionArgTarget) {
std::string MTargetOSArgStr = OSTarget->getAsString(Args, Opts);
getDeploymentTargetFromEnvironmentVariables(getDriver(), getTriple());
if (OSTarget) {
// Don't infer simulator from the arch when the SDK is also specified.
- Optional<DarwinPlatform> SDKTarget =
+ std::optional<DarwinPlatform> SDKTarget =
inferDeploymentTargetFromSDK(Args, SDKInfo);
if (SDKTarget)
OSTarget->setEnvironment(SDKTarget->getEnvironment());
if (isTargetMacCatalyst()) {
if (const auto *MacOStoMacCatalystMapping = SDKInfo->getVersionMapping(
DarwinSDKInfo::OSEnvPair::macOStoMacCatalystPair())) {
- Optional<VersionTuple> SDKVersion = MacOStoMacCatalystMapping->map(
+ std::optional<VersionTuple> SDKVersion = MacOStoMacCatalystMapping->map(
SDKInfo->getVersion(), minimumMacCatalystDeploymentTarget(),
std::nullopt);
EmitTargetSDKVersionArg(
} else if (const auto *MacOStoMacCatalystMapping =
SDKInfo->getVersionMapping(
DarwinSDKInfo::OSEnvPair::macOStoMacCatalystPair())) {
- if (Optional<VersionTuple> SDKVersion = MacOStoMacCatalystMapping->map(
- SDKInfo->getVersion(), minimumMacCatalystDeploymentTarget(),
- std::nullopt)) {
+ if (std::optional<VersionTuple> SDKVersion =
+ MacOStoMacCatalystMapping->map(
+ SDKInfo->getVersion(), minimumMacCatalystDeploymentTarget(),
+ std::nullopt)) {
std::string Arg;
llvm::raw_string_ostream OS(Arg);
OS << "-darwin-target-variant-sdk-version=" << *SDKVersion;
if (TargetPlatform == IPhoneOS && TargetEnvironment == MacCatalyst) {
// Mac Catalyst programs must use the appropriate iOS SDK version
// that corresponds to the macOS SDK version used for the compilation.
- Optional<VersionTuple> iOSSDKVersion;
+ std::optional<VersionTuple> iOSSDKVersion;
if (SDKInfo) {
if (const auto *MacOStoMacCatalystMapping =
SDKInfo->getVersionMapping(
mutable std::unique_ptr<tools::darwin::VerifyDebug> VerifyDebug;
/// The version of the linker known to be available in the tool chain.
- mutable Optional<VersionTuple> LinkerVersion;
+ mutable std::optional<VersionTuple> LinkerVersion;
public:
MachO(const Driver &D, const llvm::Triple &Triple,
mutable VersionTuple OSTargetVersion;
/// The information about the darwin SDK that was used.
- mutable Optional<DarwinSDKInfo> SDKInfo;
+ mutable std::optional<DarwinSDKInfo> SDKInfo;
/// The target variant triple that was specified (if any).
- mutable Optional<llvm::Triple> TargetVariantTriple;
+ mutable std::optional<llvm::Triple> TargetVariantTriple;
CudaInstallationDetector CudaInstallation;
RocmInstallationDetector RocmInstallation;
FilterNonExistent NonExistent(Path, "/crtbegin.o", D.getVFS());
tools::csky::FloatABI TheFloatABI = tools::csky::getCSKYFloatABI(D, Args);
- llvm::Optional<llvm::StringRef> Res = tools::csky::getCSKYArchName(D, Args, TargetTriple);
+ std::optional<llvm::StringRef> Res =
+ tools::csky::getCSKYArchName(D, Args, TargetTriple);
if (!Res)
return;
/// On Biarch systems, this corresponds to the default multilib when
/// targeting the non-default multilib. Otherwise, it is empty.
- llvm::Optional<Multilib> BiarchSibling;
+ std::optional<Multilib> BiarchSibling;
};
bool findMIPSMultilibs(const Driver &D, const llvm::Triple &TargetTriple,
Multilib SelectedMultilib;
/// On Biarch systems, this corresponds to the default multilib when
/// targeting the non-default multilib. Otherwise, it is empty.
- llvm::Optional<Multilib> BiarchSibling;
+ std::optional<Multilib> BiarchSibling;
GCCVersion Version;
return false;
}
-llvm::Optional<std::string> tryParseProfile(StringRef Profile) {
+std::optional<std::string> tryParseProfile(StringRef Profile) {
// [ps|vs|gs|hs|ds|cs|ms|as]_[major]_[minor]
SmallVector<StringRef, 3> Parts;
Profile.split(Parts, "_");
const ArgList &Args)
: ToolChain(D, Triple, Args) {}
-llvm::Optional<std::string>
+std::optional<std::string>
clang::driver::toolchains::HLSLToolChain::parseTargetProfile(
StringRef TargetProfile) {
return tryParseProfile(TargetProfile);
llvm::opt::DerivedArgList *
TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
Action::OffloadKind DeviceOffloadKind) const override;
- static llvm::Optional<std::string>
- parseTargetProfile(StringRef TargetProfile);
+ static std::optional<std::string> parseTargetProfile(StringRef TargetProfile);
};
} // end namespace toolchains
HvxVerNum = 0;
// Handle HVX floating point flags.
- auto checkFlagHvxVersion = [&](auto FlagOn, auto FlagOff,
- unsigned MinVerNum) -> Optional<StringRef> {
- // Return an Optional<StringRef>:
+ auto checkFlagHvxVersion =
+ [&](auto FlagOn, auto FlagOff,
+ unsigned MinVerNum) -> std::optional<StringRef> {
+ // Return an std::optional<StringRef>:
// - None indicates a verification failure, or that the flag was not
// present in Args.
// - Otherwise the returned value is that name of the feature to add
return InstalledDir;
}
-Optional<unsigned> HexagonToolChain::getSmallDataThreshold(
- const ArgList &Args) {
+std::optional<unsigned>
+HexagonToolChain::getSmallDataThreshold(const ArgList &Args) {
StringRef Gn = "";
if (Arg *A = Args.getLastArg(options::OPT_G)) {
Gn = A->getValue();
static StringRef GetDefaultCPU();
static StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args);
- static Optional<unsigned> getSmallDataThreshold(
- const llvm::opt::ArgList &Args);
+ static std::optional<unsigned>
+ getSmallDataThreshold(const llvm::opt::ArgList &Args);
};
} // end namespace toolchains
if (getDriver().getInstalledDir() != getDriver().Dir)
getProgramPaths().push_back(getDriver().Dir);
- Optional<llvm::StringRef> VCToolsDir, VCToolsVersion;
+ std::optional<llvm::StringRef> VCToolsDir, VCToolsVersion;
if (Arg *A = Args.getLastArg(options::OPT__SLASH_vctoolsdir))
VCToolsDir = A->getValue();
if (Arg *A = Args.getLastArg(options::OPT__SLASH_vctoolsversion))
Tool *buildLinker() const override;
Tool *buildAssembler() const override;
private:
- llvm::Optional<llvm::StringRef> WinSdkDir, WinSdkVersion, WinSysRoot;
+ std::optional<llvm::StringRef> WinSdkDir, WinSdkVersion, WinSysRoot;
std::string VCToolChainPath;
llvm::ToolsetLayout VSLayout = llvm::ToolsetLayout::OlderVS;
CudaInstallationDetector CudaInstallation;
// attributes that are inferred from 'ios'.
NewII = &S.Context.Idents.get("maccatalyst");
auto RemapMacOSVersion =
- [&](const VersionTuple &V) -> Optional<VersionTuple> {
+ [&](const VersionTuple &V) -> std::optional<VersionTuple> {
if (V.empty())
return std::nullopt;
// API_TO_BE_DEPRECATED is 100000.
return MacOStoMacCatalystMapping->map(V, VersionTuple(13, 1),
std::nullopt);
};
- Optional<VersionTuple> NewIntroduced =
- RemapMacOSVersion(Introduced.Version),
- NewDeprecated =
- RemapMacOSVersion(Deprecated.Version),
- NewObsoleted =
- RemapMacOSVersion(Obsoleted.Version);
+ std::optional<VersionTuple> NewIntroduced =
+ RemapMacOSVersion(Introduced.Version),
+ NewDeprecated =
+ RemapMacOSVersion(Deprecated.Version),
+ NewObsoleted =
+ RemapMacOSVersion(Obsoleted.Version);
if (NewIntroduced || NewDeprecated || NewObsoleted) {
auto VersionOrEmptyVersion =
- [](const Optional<VersionTuple> &V) -> VersionTuple {
+ [](const std::optional<VersionTuple> &V) -> VersionTuple {
return V ? *V : VersionTuple();
};
AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
+#include <optional>
#include <string>
namespace llvm {
/// Get Windows SDK installation directory.
bool getWindowsSDKDir(vfs::FileSystem &VFS,
- llvm::Optional<llvm::StringRef> WinSdkDir,
- llvm::Optional<llvm::StringRef> WinSdkVersion,
- llvm::Optional<llvm::StringRef> WinSysRoot,
+ std::optional<llvm::StringRef> WinSdkDir,
+ std::optional<llvm::StringRef> WinSdkVersion,
+ std::optional<llvm::StringRef> WinSysRoot,
std::string &Path, int &Major,
std::string &WindowsSDKIncludeVersion,
std::string &WindowsSDKLibVersion);
bool getUniversalCRTSdkDir(vfs::FileSystem &VFS,
- llvm::Optional<llvm::StringRef> WinSdkDir,
- llvm::Optional<llvm::StringRef> WinSdkVersion,
- llvm::Optional<llvm::StringRef> WinSysRoot,
- std::string &Path,
- std::string &UCRTVersion);
+ std::optional<llvm::StringRef> WinSdkDir,
+ std::optional<llvm::StringRef> WinSdkVersion,
+ std::optional<llvm::StringRef> WinSysRoot,
+ std::string &Path, std::string &UCRTVersion);
// Check command line arguments to try and find a toolchain.
bool findVCToolChainViaCommandLine(
- vfs::FileSystem &VFS, llvm::Optional<llvm::StringRef> VCToolsDir,
- llvm::Optional<llvm::StringRef> VCToolsVersion,
- llvm::Optional<llvm::StringRef> WinSysRoot, std::string &Path,
+ vfs::FileSystem &VFS, std::optional<llvm::StringRef> VCToolsDir,
+ std::optional<llvm::StringRef> VCToolsVersion,
+ std::optional<llvm::StringRef> WinSysRoot, std::string &Path,
ToolsetLayout &VSLayout);
// Check various environment variables to try and find a toolchain.
}
static bool getWindowsSDKDirViaCommandLine(
- llvm::vfs::FileSystem &VFS, llvm::Optional<llvm::StringRef> WinSdkDir,
- llvm::Optional<llvm::StringRef> WinSdkVersion,
- llvm::Optional<llvm::StringRef> WinSysRoot, std::string &Path, int &Major,
+ llvm::vfs::FileSystem &VFS, std::optional<llvm::StringRef> WinSdkDir,
+ std::optional<llvm::StringRef> WinSdkVersion,
+ std::optional<llvm::StringRef> WinSysRoot, std::string &Path, int &Major,
std::string &Version) {
if (WinSdkDir || WinSysRoot) {
// Don't validate the input; trust the value supplied by the user.
return !VFS.exists(TestPath);
}
-bool getWindowsSDKDir(vfs::FileSystem &VFS, Optional<StringRef> WinSdkDir,
- Optional<StringRef> WinSdkVersion,
- Optional<StringRef> WinSysRoot, std::string &Path,
+bool getWindowsSDKDir(vfs::FileSystem &VFS, std::optional<StringRef> WinSdkDir,
+ std::optional<StringRef> WinSdkVersion,
+ std::optional<StringRef> WinSysRoot, std::string &Path,
int &Major, std::string &WindowsSDKIncludeVersion,
std::string &WindowsSDKLibVersion) {
// Trust /winsdkdir and /winsdkversion if present.
return false;
}
-bool getUniversalCRTSdkDir(vfs::FileSystem &VFS, Optional<StringRef> WinSdkDir,
- Optional<StringRef> WinSdkVersion,
- Optional<StringRef> WinSysRoot, std::string &Path,
- std::string &UCRTVersion) {
+bool getUniversalCRTSdkDir(vfs::FileSystem &VFS,
+ std::optional<StringRef> WinSdkDir,
+ std::optional<StringRef> WinSdkVersion,
+ std::optional<StringRef> WinSysRoot,
+ std::string &Path, std::string &UCRTVersion) {
// If /winsdkdir is passed, use it as location for the UCRT too.
// FIXME: Should there be a dedicated /ucrtdir to override /winsdkdir?
int Major;
}
bool findVCToolChainViaCommandLine(vfs::FileSystem &VFS,
- Optional<StringRef> VCToolsDir,
- Optional<StringRef> VCToolsVersion,
- Optional<StringRef> WinSysRoot,
+ std::optional<StringRef> VCToolsDir,
+ std::optional<StringRef> VCToolsVersion,
+ std::optional<StringRef> WinSysRoot,
std::string &Path, ToolsetLayout &VSLayout) {
// Don't validate the input; trust the value supplied by the user.
// The primary motivation is to prevent unnecessary file and registry access.