diff options
| -rw-r--r-- | llvm/include/llvm/ADT/Triple.h | 7 | ||||
| -rw-r--r-- | llvm/lib/Support/Triple.cpp | 2 | ||||
| -rw-r--r-- | llvm/unittests/ADT/TripleTest.cpp | 9 |
3 files changed, 17 insertions, 1 deletions
diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h index f8fec5d0da7..761e0ad98db 100644 --- a/llvm/include/llvm/ADT/Triple.h +++ b/llvm/include/llvm/ADT/Triple.h @@ -205,7 +205,8 @@ public: AMDOpenCL, CoreCLR, OpenCL, - LastEnvironmentType = OpenCL + Simulator, // Simulator variants of other systems, e.g., Apple's iOS + LastEnvironmentType = Simulator }; enum ObjectFormatType { UnknownObjectFormat, @@ -470,6 +471,10 @@ public: return isMacOSX() || isiOS() || isWatchOS(); } + bool isSimulatorEnvironment() const { + return getEnvironment() == Triple::Simulator; + } + bool isOSNetBSD() const { return getOS() == Triple::NetBSD; } diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp index 69c99ac907a..4f0a30042b7 100644 --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp @@ -235,6 +235,7 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) { case AMDOpenCL: return "amdopencl"; case CoreCLR: return "coreclr"; case OpenCL: return "opencl"; + case Simulator: return "simulator"; } llvm_unreachable("Invalid EnvironmentType!"); @@ -525,6 +526,7 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) { .StartsWith("amdopencl", Triple::AMDOpenCL) .StartsWith("coreclr", Triple::CoreCLR) .StartsWith("opencl", Triple::OpenCL) + .StartsWith("simulator", Triple::Simulator) .Default(Triple::UnknownEnvironment); } diff --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/ADT/TripleTest.cpp index b78aee4f33d..ed4a88067b1 100644 --- a/llvm/unittests/ADT/TripleTest.cpp +++ b/llvm/unittests/ADT/TripleTest.cpp @@ -1000,6 +1000,15 @@ TEST(TripleTest, getOSVersion) { EXPECT_EQ((unsigned)7, Major); EXPECT_EQ((unsigned)0, Minor); EXPECT_EQ((unsigned)0, Micro); + EXPECT_FALSE(T.isSimulatorEnvironment()); + + T = Triple("x86_64-apple-ios10.3-simulator"); + EXPECT_TRUE(T.isiOS()); + T.getiOSVersion(Major, Minor, Micro); + EXPECT_EQ((unsigned)10, Major); + EXPECT_EQ((unsigned)3, Minor); + EXPECT_EQ((unsigned)0, Micro); + EXPECT_TRUE(T.isSimulatorEnvironment()); } TEST(TripleTest, FileFormat) { |

