Make Triple::getOSVersion make sense for Android.
authorDan Albert <danalbert@google.com>
Tue, 3 Mar 2015 18:23:51 +0000 (18:23 +0000)
committerDan Albert <danalbert@google.com>
Tue, 3 Mar 2015 18:23:51 +0000 (18:23 +0000)
Reviewers: srhines

Reviewed By: srhines

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D7928

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231090 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Triple.cpp

index e74b23ca0cacf7a697b4bcd7759f1f98d7b4efe6..33472e51d17a4a7b1082daafd4cae12ca560926f 100644 (file)
@@ -714,6 +714,14 @@ void Triple::getOSVersion(unsigned &Major, unsigned &Minor,
                           unsigned &Micro) const {
   StringRef OSName = getOSName();
 
+  // For Android, we care about the Android version rather than the Linux
+  // version.
+  if (getEnvironment() == Android) {
+    OSName = getEnvironmentName().substr(strlen("android"));
+    if (OSName.startswith("eabi"))
+      OSName = OSName.substr(strlen("eabi"));
+  }
+
   // Assume that the OS portion of the triple starts with the canonical name.
   StringRef OSTypeName = getOSTypeName(getOS());
   if (OSName.startswith(OSTypeName))