aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/include/clang/Basic/DarwinSDKInfo.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/include/clang/Basic/DarwinSDKInfo.h')
-rw-r--r--contrib/llvm-project/clang/include/clang/Basic/DarwinSDKInfo.h62
1 files changed, 39 insertions, 23 deletions
diff --git a/contrib/llvm-project/clang/include/clang/Basic/DarwinSDKInfo.h b/contrib/llvm-project/clang/include/clang/Basic/DarwinSDKInfo.h
index 918dc7c8becc..dedfbd934a7b 100644
--- a/contrib/llvm-project/clang/include/clang/Basic/DarwinSDKInfo.h
+++ b/contrib/llvm-project/clang/include/clang/Basic/DarwinSDKInfo.h
@@ -6,15 +6,16 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_BASIC_DARWIN_SDK_INFO_H
-#define LLVM_CLANG_BASIC_DARWIN_SDK_INFO_H
+#ifndef LLVM_CLANG_BASIC_DARWINSDKINFO_H
+#define LLVM_CLANG_BASIC_DARWINSDKINFO_H
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/Triple.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/VersionTuple.h"
#include "llvm/Support/VirtualFileSystem.h"
+#include "llvm/TargetParser/Triple.h"
+#include <optional>
namespace llvm {
namespace json {
@@ -57,6 +58,20 @@ public:
llvm::Triple::MacOSX, llvm::Triple::UnknownEnvironment);
}
+ /// Returns the os-environment mapping pair that's used to represent the
+ /// iOS -> watchOS version mapping.
+ static inline constexpr OSEnvPair iOStoWatchOSPair() {
+ return OSEnvPair(llvm::Triple::IOS, llvm::Triple::UnknownEnvironment,
+ llvm::Triple::WatchOS, llvm::Triple::UnknownEnvironment);
+ }
+
+ /// Returns the os-environment mapping pair that's used to represent the
+ /// iOS -> tvOS version mapping.
+ static inline constexpr OSEnvPair iOStoTvOSPair() {
+ return OSEnvPair(llvm::Triple::IOS, llvm::Triple::UnknownEnvironment,
+ llvm::Triple::TvOS, llvm::Triple::UnknownEnvironment);
+ }
+
private:
StorageType Value;
@@ -85,12 +100,12 @@ public:
/// 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;
+ /// within the minimum and maximum bounds, std::nullopt is returned.
+ std::optional<VersionTuple>
+ map(const VersionTuple &Key, const VersionTuple &MinimumValue,
+ std::optional<VersionTuple> MaximumValue) const;
- static Optional<RelatedTargetVersionMapping>
+ static std::optional<RelatedTargetVersionMapping>
parseJSON(const llvm::json::Object &Obj,
VersionTuple MaximumDeploymentTarget);
@@ -102,12 +117,13 @@ public:
llvm::DenseMap<VersionTuple, VersionTuple> Mapping;
};
- DarwinSDKInfo(VersionTuple Version, VersionTuple MaximumDeploymentTarget,
- llvm::DenseMap<OSEnvPair::StorageType,
- Optional<RelatedTargetVersionMapping>>
- VersionMappings =
- llvm::DenseMap<OSEnvPair::StorageType,
- Optional<RelatedTargetVersionMapping>>())
+ DarwinSDKInfo(
+ VersionTuple Version, VersionTuple MaximumDeploymentTarget,
+ llvm::DenseMap<OSEnvPair::StorageType,
+ std::optional<RelatedTargetVersionMapping>>
+ VersionMappings =
+ llvm::DenseMap<OSEnvPair::StorageType,
+ std::optional<RelatedTargetVersionMapping>>())
: Version(Version), MaximumDeploymentTarget(MaximumDeploymentTarget),
VersionMappings(std::move(VersionMappings)) {}
@@ -128,11 +144,10 @@ public:
auto Mapping = VersionMappings.find(Kind.Value);
if (Mapping == VersionMappings.end())
return nullptr;
- return Mapping->getSecond().hasValue() ? Mapping->getSecond().getPointer()
- : nullptr;
+ return Mapping->getSecond() ? &*Mapping->getSecond() : nullptr;
}
- static Optional<DarwinSDKInfo>
+ static std::optional<DarwinSDKInfo>
parseDarwinSDKSettingsJSON(const llvm::json::Object *Obj);
private:
@@ -141,17 +156,18 @@ private:
// Need to wrap the value in an optional here as the value has to be default
// constructible, and std::unique_ptr doesn't like DarwinSDKInfo being
// Optional as Optional is trying to copy it in emplace.
- llvm::DenseMap<OSEnvPair::StorageType, Optional<RelatedTargetVersionMapping>>
+ llvm::DenseMap<OSEnvPair::StorageType,
+ std::optional<RelatedTargetVersionMapping>>
VersionMappings;
};
/// Parse the SDK information from the SDKSettings.json file.
///
-/// \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);
+/// \returns an error if the SDKSettings.json file is invalid, std::nullopt if
+/// the SDK has no SDKSettings.json, or a valid \c DarwinSDKInfo otherwise.
+Expected<std::optional<DarwinSDKInfo>>
+parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, StringRef SDKRootPath);
} // end namespace clang
-#endif // LLVM_CLANG_BASIC_DARWIN_SDK_INFO_H
+#endif // LLVM_CLANG_BASIC_DARWINSDKINFO_H