Skip to content

Commit

Permalink
[triple] add 'macCatalyst' environment type
Browse files Browse the repository at this point in the history
Mac Catalyst is a new deployment platform in macOS Catalina.

Differential Revision: https://reviews.llvm.org/D64097

llvm-svn: 364971
  • Loading branch information
hyp committed Jul 2, 2019
1 parent e97aa96 commit 31dee6d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
9 changes: 7 additions & 2 deletions llvm/include/llvm/ADT/Triple.h
Expand Up @@ -214,8 +214,9 @@ class Triple {
Itanium,
Cygnus,
CoreCLR,
Simulator, // Simulator variants of other systems, e.g., Apple's iOS
LastEnvironmentType = Simulator
Simulator, // Simulator variants of other systems, e.g., Apple's iOS
MacCatalyst,
LastEnvironmentType = MacCatalyst
};
enum ObjectFormatType {
UnknownObjectFormat,
Expand Down Expand Up @@ -485,6 +486,10 @@ class Triple {
return getEnvironment() == Triple::Simulator;
}

bool isMacCatalystEnvironment() const {
return getEnvironment() == Triple::MacCatalyst;
}

bool isOSNetBSD() const {
return getOS() == Triple::NetBSD;
}
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Support/Triple.cpp
Expand Up @@ -239,6 +239,7 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) {
case Cygnus: return "cygnus";
case CoreCLR: return "coreclr";
case Simulator: return "simulator";
case MacCatalyst: return "maccatalyst";
}

llvm_unreachable("Invalid EnvironmentType!");
Expand Down Expand Up @@ -541,6 +542,7 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
.StartsWith("cygnus", Triple::Cygnus)
.StartsWith("coreclr", Triple::CoreCLR)
.StartsWith("simulator", Triple::Simulator)
.StartsWith("maccatalyst", Triple::MacCatalyst)
.Default(Triple::UnknownEnvironment);
}

Expand Down
11 changes: 11 additions & 0 deletions llvm/unittests/ADT/TripleTest.cpp
Expand Up @@ -1237,6 +1237,17 @@ TEST(TripleTest, getOSVersion) {
EXPECT_EQ((unsigned)3, Minor);
EXPECT_EQ((unsigned)0, Micro);
EXPECT_TRUE(T.isSimulatorEnvironment());
EXPECT_FALSE(T.isMacCatalystEnvironment());

T = Triple("x86_64-apple-ios13.0-maccatalyst");
EXPECT_TRUE(T.isiOS());
T.getiOSVersion(Major, Minor, Micro);
EXPECT_EQ((unsigned)13, Major);
EXPECT_EQ((unsigned)0, Minor);
EXPECT_EQ((unsigned)0, Micro);
EXPECT_TRUE(T.getEnvironment() == Triple::MacCatalyst);
EXPECT_TRUE(T.isMacCatalystEnvironment());
EXPECT_FALSE(T.isSimulatorEnvironment());
}

TEST(TripleTest, FileFormat) {
Expand Down

0 comments on commit 31dee6d

Please sign in to comment.