[clang] [clang][driver][darwin] Prefer DarwinSDKInfo for platform identification and compatibility over the -isysroot path (PR #176541)

Ian Anderson via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 17 00:41:10 PST 2026


================
@@ -1382,26 +1382,61 @@ std::string Darwin::getCompilerRT(const ArgList &Args, StringRef Component,
   return std::string(FullPath);
 }
 
-StringRef Darwin::getPlatformFamily() const {
+static StringRef getPlatformFamily(Darwin::DarwinPlatformKind TargetPlatform) {
   switch (TargetPlatform) {
-    case DarwinPlatformKind::MacOS:
-      return "MacOSX";
-    case DarwinPlatformKind::IPhoneOS:
-      if (TargetEnvironment == MacCatalyst)
-        return "MacOSX";
-      return "iPhone";
-    case DarwinPlatformKind::TvOS:
-      return "AppleTV";
-    case DarwinPlatformKind::WatchOS:
-      return "Watch";
-    case DarwinPlatformKind::DriverKit:
-      return "DriverKit";
-    case DarwinPlatformKind::XROS:
-      return "XR";
+  case Darwin::DarwinPlatformKind::MacOS:
+    return "MacOSX";
+  case Darwin::DarwinPlatformKind::IPhoneOS:
+    return "iPhone";
+  case Darwin::DarwinPlatformKind::TvOS:
+    return "AppleTV";
+  case Darwin::DarwinPlatformKind::WatchOS:
+    return "Watch";
+  case Darwin::DarwinPlatformKind::DriverKit:
+    return "DriverKit";
+  default:
+    break;
   }
   llvm_unreachable("Unsupported platform");
 }
 
+static std::string getPlatformAndEnvironmentString(
----------------
ian-twilightcoder wrote:

This is just used in the diagnostic message for `-Wincompatible-sysroot`. The effective triple hasn't been computed when that diagnostic is emitted, but the platform/environment have been.

https://github.com/llvm/llvm-project/pull/176541


More information about the cfe-commits mailing list