llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

<details>
<summary>Changes</summary>

Ignore case when parsing the Xcode SDK. The BridgeOS SDK is capitalized, but 
previously failed to parse because we were looking for bridgeOS. This PR 
updates the enum value and the canonical spelling, and also relaxes the parsing 
to be case insensitive.

rdar://162641896

---
Full diff: https://github.com/llvm/llvm-project/pull/163479.diff


4 Files Affected:

- (modified) lldb/include/lldb/Utility/XcodeSDK.h (+1-1) 
- (modified) lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (+1-1) 
- (modified) lldb/source/Utility/XcodeSDK.cpp (+17-16) 
- (modified) lldb/unittests/Utility/XcodeSDKTest.cpp (+2) 


``````````diff
diff --git a/lldb/include/lldb/Utility/XcodeSDK.h 
b/lldb/include/lldb/Utility/XcodeSDK.h
index 5b345a4965cf9..5f89019537689 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -38,7 +38,7 @@ class XcodeSDK {
     watchOS,
     XRSimulator,
     XROS,
-    bridgeOS,
+    BridgeOS,
     Linux,
     unknown = -1
   };
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index cd72454fe0287..5aad4470091bc 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1150,7 +1150,7 @@ void 
PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
     case XcodeSDK::Type::XRSimulator:
     case XcodeSDK::Type::XROS:
       // FIXME: Pass the right argument once it exists.
-    case XcodeSDK::Type::bridgeOS:
+    case XcodeSDK::Type::BridgeOS:
     case XcodeSDK::Type::Linux:
     case XcodeSDK::Type::unknown:
       if (Log *log = GetLog(LLDBLog::Host)) {
diff --git a/lldb/source/Utility/XcodeSDK.cpp b/lldb/source/Utility/XcodeSDK.cpp
index 2040791882fd0..d20d485e64328 100644
--- a/lldb/source/Utility/XcodeSDK.cpp
+++ b/lldb/source/Utility/XcodeSDK.cpp
@@ -38,8 +38,8 @@ static llvm::StringRef GetName(XcodeSDK::Type type) {
     return "XRSimulator";
   case XcodeSDK::XROS:
     return "XROS";
-  case XcodeSDK::bridgeOS:
-    return "bridgeOS";
+  case XcodeSDK::BridgeOS:
+    return "BridgeOS";
   case XcodeSDK::Linux:
     return "Linux";
   case XcodeSDK::unknown:
@@ -65,27 +65,27 @@ bool XcodeSDK::operator==(const XcodeSDK &other) const {
 }
 
 static XcodeSDK::Type ParseSDKName(llvm::StringRef &name) {
-  if (name.consume_front("MacOSX"))
+  if (name.consume_front_insensitive("MacOSX"))
     return XcodeSDK::MacOSX;
-  if (name.consume_front("iPhoneSimulator"))
+  if (name.consume_front_insensitive("iPhoneSimulator"))
     return XcodeSDK::iPhoneSimulator;
-  if (name.consume_front("iPhoneOS"))
+  if (name.consume_front_insensitive("iPhoneOS"))
     return XcodeSDK::iPhoneOS;
-  if (name.consume_front("AppleTVSimulator"))
+  if (name.consume_front_insensitive("AppleTVSimulator"))
     return XcodeSDK::AppleTVSimulator;
-  if (name.consume_front("AppleTVOS"))
+  if (name.consume_front_insensitive("AppleTVOS"))
     return XcodeSDK::AppleTVOS;
-  if (name.consume_front("WatchSimulator"))
+  if (name.consume_front_insensitive("WatchSimulator"))
     return XcodeSDK::WatchSimulator;
-  if (name.consume_front("WatchOS"))
+  if (name.consume_front_insensitive("WatchOS"))
     return XcodeSDK::watchOS;
-  if (name.consume_front("XRSimulator"))
+  if (name.consume_front_insensitive("XRSimulator"))
     return XcodeSDK::XRSimulator;
-  if (name.consume_front("XROS"))
+  if (name.consume_front_insensitive("XROS"))
     return XcodeSDK::XROS;
-  if (name.consume_front("bridgeOS"))
-    return XcodeSDK::bridgeOS;
-  if (name.consume_front("Linux"))
+  if (name.consume_front_insensitive("BridgeOS"))
+    return XcodeSDK::BridgeOS;
+  if (name.consume_front_insensitive("Linux"))
     return XcodeSDK::Linux;
   static_assert(XcodeSDK::Linux == XcodeSDK::numSDKTypes - 1,
                 "New SDK type was added, update this list!");
@@ -110,7 +110,8 @@ static llvm::VersionTuple ParseSDKVersion(llvm::StringRef 
&name) {
 }
 
 static bool ParseAppleInternalSDK(llvm::StringRef &name) {
-  return name.consume_front("Internal.") || name.consume_front(".Internal.");
+  return name.consume_front_insensitive("Internal.") ||
+         name.consume_front_insensitive(".Internal.");
 }
 
 XcodeSDK::Info XcodeSDK::Parse() const {
@@ -204,7 +205,7 @@ std::string XcodeSDK::GetCanonicalName(XcodeSDK::Info info) 
{
   case XROS:
     name = "xros";
     break;
-  case bridgeOS:
+  case BridgeOS:
     name = "bridgeos";
     break;
   case Linux:
diff --git a/lldb/unittests/Utility/XcodeSDKTest.cpp 
b/lldb/unittests/Utility/XcodeSDKTest.cpp
index de9f91a04d53e..f3964f25c821b 100644
--- a/lldb/unittests/Utility/XcodeSDKTest.cpp
+++ b/lldb/unittests/Utility/XcodeSDKTest.cpp
@@ -27,6 +27,8 @@ TEST(XcodeSDKTest, ParseTest) {
   EXPECT_EQ(XcodeSDK("AppleTVOS.sdk").GetType(), XcodeSDK::AppleTVOS);
   EXPECT_EQ(XcodeSDK("WatchSimulator.sdk").GetType(), 
XcodeSDK::WatchSimulator);
   EXPECT_EQ(XcodeSDK("WatchOS.sdk").GetType(), XcodeSDK::watchOS);
+  EXPECT_EQ(XcodeSDK("BridgeOS.sdk").GetType(), XcodeSDK::BridgeOS);
+  EXPECT_EQ(XcodeSDK("bridgeOS.sdk").GetType(), XcodeSDK::BridgeOS);
   EXPECT_EQ(XcodeSDK("XRSimulator.sdk").GetType(), XcodeSDK::XRSimulator);
   EXPECT_EQ(XcodeSDK("XROS.sdk").GetType(), XcodeSDK::XROS);
   EXPECT_EQ(XcodeSDK("Linux.sdk").GetType(), XcodeSDK::Linux);

``````````

</details>


https://github.com/llvm/llvm-project/pull/163479
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to