[Lldb-commits] [lldb] e937840 - Upstream macCatalyst support in ArchSpec and associated unit tests.
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Fri Jul 24 18:01:59 PDT 2020
Author: Adrian Prantl
Date: 2020-07-24T18:01:41-07:00
New Revision: e937840dbdce20f2ab7ca4dcd9f04c3fd89e56e3
URL: https://github.com/llvm/llvm-project/commit/e937840dbdce20f2ab7ca4dcd9f04c3fd89e56e3
DIFF: https://github.com/llvm/llvm-project/commit/e937840dbdce20f2ab7ca4dcd9f04c3fd89e56e3.diff
LOG: Upstream macCatalyst support in ArchSpec and associated unit tests.
Added:
Modified:
lldb/source/Utility/ArchSpec.cpp
lldb/unittests/Utility/ArchSpecTest.cpp
Removed:
################################################################################
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index f220f4e30b29..a77ae8633070 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -846,6 +846,15 @@ bool ArchSpec::ContainsOnlyArch(const llvm::Triple &normalized_triple) {
}
void ArchSpec::MergeFrom(const ArchSpec &other) {
+ // ios-macabi always wins over macosx.
+ if ((GetTriple().getOS() == llvm::Triple::MacOSX ||
+ GetTriple().getOS() == llvm::Triple::UnknownOS) &&
+ other.GetTriple().getOS() == llvm::Triple::IOS &&
+ other.GetTriple().getEnvironment() == llvm::Triple::MacABI) {
+ (*this) = other;
+ return;
+ }
+
if (!TripleVendorWasSpecified() && other.TripleVendorWasSpecified())
GetTriple().setVendor(other.GetTriple().getVendor());
if (!TripleOSWasSpecified() && other.TripleOSWasSpecified())
@@ -1031,6 +1040,22 @@ bool ArchSpec::IsEqualTo(const ArchSpec &rhs, bool exact_match) const {
const llvm::Triple::OSType lhs_triple_os = lhs_triple.getOS();
const llvm::Triple::OSType rhs_triple_os = rhs_triple.getOS();
+ const llvm::Triple::EnvironmentType lhs_triple_env =
+ lhs_triple.getEnvironment();
+ const llvm::Triple::EnvironmentType rhs_triple_env =
+ rhs_triple.getEnvironment();
+
+ if (!exact_match) {
+ // x86_64-apple-ios-macabi, x86_64-apple-macosx are compatible, no match.
+ if ((lhs_triple_os == llvm::Triple::IOS &&
+ lhs_triple_env == llvm::Triple::MacABI &&
+ rhs_triple_os == llvm::Triple::MacOSX) ||
+ (lhs_triple_os == llvm::Triple::MacOSX &&
+ rhs_triple_os == llvm::Triple::IOS &&
+ rhs_triple_env == llvm::Triple::MacABI))
+ return true;
+ }
+
if (lhs_triple_os != rhs_triple_os) {
const bool rhs_os_specified = rhs.TripleOSWasSpecified();
const bool lhs_os_specified = TripleOSWasSpecified();
@@ -1045,10 +1070,13 @@ bool ArchSpec::IsEqualTo(const ArchSpec &rhs, bool exact_match) const {
return false;
}
- const llvm::Triple::EnvironmentType lhs_triple_env =
- lhs_triple.getEnvironment();
- const llvm::Triple::EnvironmentType rhs_triple_env =
- rhs_triple.getEnvironment();
+ // x86_64-apple-ios-macabi and x86_64-apple-ios are not compatible.
+ if (lhs_triple_os == llvm::Triple::IOS &&
+ rhs_triple_os == llvm::Triple::IOS &&
+ (lhs_triple_env == llvm::Triple::MacABI ||
+ rhs_triple_env == llvm::Triple::MacABI) &&
+ lhs_triple_env != rhs_triple_env)
+ return false;
return IsCompatibleEnvironment(lhs_triple_env, rhs_triple_env);
}
diff --git a/lldb/unittests/Utility/ArchSpecTest.cpp b/lldb/unittests/Utility/ArchSpecTest.cpp
index 4e8e2f3c34d7..a8f43ed7dc7c 100644
--- a/lldb/unittests/Utility/ArchSpecTest.cpp
+++ b/lldb/unittests/Utility/ArchSpecTest.cpp
@@ -328,6 +328,40 @@ TEST(ArchSpecTest, Compatibility) {
ASSERT_TRUE(A.IsExactMatch(B));
ASSERT_TRUE(A.IsCompatibleMatch(B));
}
+ {
+ ArchSpec A("x86_64");
+ ArchSpec B("x86_64-apple-ios12.0.0-macabi");
+ // FIXME: The exact match also looks unintuitive.
+ ASSERT_TRUE(A.IsExactMatch(B));
+ ASSERT_TRUE(A.IsCompatibleMatch(B));
+ }
+ {
+ ArchSpec A("x86_64-apple-ios12.0.0");
+ ArchSpec B("x86_64-apple-ios12.0.0-macabi");
+ ASSERT_FALSE(A.IsExactMatch(B));
+ ASSERT_FALSE(A.IsCompatibleMatch(B));
+ }
+ {
+ ArchSpec A("x86_64-apple-macosx10.14.2");
+ ArchSpec B("x86_64-apple-ios12.0.0-macabi");
+ ASSERT_FALSE(A.IsExactMatch(B));
+ ASSERT_TRUE(A.IsCompatibleMatch(B));
+ }
+ {
+ ArchSpec A("x86_64-apple-macosx10.14.2");
+ ArchSpec B("x86_64-apple-ios12.0.0-macabi");
+ // ios-macabi wins.
+ A.MergeFrom(B);
+ ASSERT_TRUE(A.IsExactMatch(B));
+ }
+ {
+ ArchSpec A("x86_64-apple-macosx10.14.2");
+ ArchSpec B("x86_64-apple-ios12.0.0-macabi");
+ ArchSpec C(B);
+ // ios-macabi wins.
+ B.MergeFrom(A);
+ ASSERT_TRUE(B.IsExactMatch(C));
+ }
}
TEST(ArchSpecTest, OperatorBool) {
More information about the lldb-commits
mailing list