diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 29d2d82136018..461a21f44421b 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -631,15 +631,6 @@ static llvm::ArrayRef GetCompatibleArchs(ArchSpec::Core core) { return {}; } -const char *PlatformDarwin::GetCompatibleArch(ArchSpec::Core core, size_t idx) { - llvm::ArrayRef compatible_archs = GetCompatibleArchs(core); - if (!compatible_archs.data()) - return nullptr; - if (idx < compatible_archs.size()) - return compatible_archs[idx]; - return nullptr; -} - /// The architecture selection rules for arm processors These cpu subtypes have /// distinct names (e.g. armv7f) but armv7 binaries run fine on an armv7f /// processor. @@ -647,12 +638,9 @@ void PlatformDarwin::ARMGetSupportedArchitectures( std::vector &archs, llvm::Optional os) { const ArchSpec system_arch = GetSystemArchitecture(); const ArchSpec::Core system_core = system_arch.GetCore(); - - const char *compatible_arch; - for (unsigned idx = 0; - (compatible_arch = GetCompatibleArch(system_core, idx)); ++idx) { + for (const char *arch : GetCompatibleArchs(system_core)) { llvm::Triple triple; - triple.setArchName(compatible_arch); + triple.setArchName(arch); triple.setVendor(llvm::Triple::VendorType::Apple); if (os) triple.setOS(*os); diff --git a/lldb/unittests/Platform/PlatformDarwinTest.cpp b/lldb/unittests/Platform/PlatformDarwinTest.cpp index 73a0b37fbc773..285dc2ee3db78 100644 --- a/lldb/unittests/Platform/PlatformDarwinTest.cpp +++ b/lldb/unittests/Platform/PlatformDarwinTest.cpp @@ -20,7 +20,6 @@ using namespace lldb_private; struct PlatformDarwinTester : public PlatformDarwin { public: using PlatformDarwin::FindComponentInPath; - using PlatformDarwin::GetCompatibleArch; }; TEST(PlatformDarwinTest, TestParseVersionBuildDir) { @@ -67,95 +66,3 @@ TEST(PlatformDarwinTest, FindComponentInPath) { EXPECT_EQ("", PlatformDarwinTester::FindComponentInPath("/path/to/foo", "bar")); } - -TEST(PlatformDarwinTest, GetCompatibleArchARM64) { - const ArchSpec::Core core = ArchSpec::eCore_arm_arm64; - EXPECT_STREQ("arm64", PlatformDarwinTester::GetCompatibleArch(core, 0)); - EXPECT_STREQ("armv7", PlatformDarwinTester::GetCompatibleArch(core, 1)); - EXPECT_STREQ("armv4", PlatformDarwinTester::GetCompatibleArch(core, 10)); - EXPECT_STREQ("arm", PlatformDarwinTester::GetCompatibleArch(core, 11)); - EXPECT_STREQ("thumbv7", PlatformDarwinTester::GetCompatibleArch(core, 12)); - EXPECT_STREQ("thumbv4t", PlatformDarwinTester::GetCompatibleArch(core, 21)); - EXPECT_STREQ("thumb", PlatformDarwinTester::GetCompatibleArch(core, 22)); - EXPECT_EQ(nullptr, PlatformDarwinTester::GetCompatibleArch(core, 23)); -} - -TEST(PlatformDarwinTest, GetCompatibleArchARMv7f) { - const ArchSpec::Core core = ArchSpec::eCore_arm_armv7f; - EXPECT_STREQ("armv7f", PlatformDarwinTester::GetCompatibleArch(core, 0)); - EXPECT_STREQ("armv7", PlatformDarwinTester::GetCompatibleArch(core, 1)); - EXPECT_STREQ("arm", PlatformDarwinTester::GetCompatibleArch(core, 6)); - EXPECT_STREQ("thumbv7f", PlatformDarwinTester::GetCompatibleArch(core, 7)); -} - -TEST(PlatformDarwinTest, GetCompatibleArchARMv7k) { - const ArchSpec::Core core = ArchSpec::eCore_arm_armv7k; - EXPECT_STREQ("armv7k", PlatformDarwinTester::GetCompatibleArch(core, 0)); - EXPECT_STREQ("armv7", PlatformDarwinTester::GetCompatibleArch(core, 1)); - EXPECT_STREQ("arm", PlatformDarwinTester::GetCompatibleArch(core, 6)); - EXPECT_STREQ("thumbv7k", PlatformDarwinTester::GetCompatibleArch(core, 7)); -} - -TEST(PlatformDarwinTest, GetCompatibleArchARMv7s) { - const ArchSpec::Core core = ArchSpec::eCore_arm_armv7s; - EXPECT_STREQ("armv7s", PlatformDarwinTester::GetCompatibleArch(core, 0)); - EXPECT_STREQ("armv7", PlatformDarwinTester::GetCompatibleArch(core, 1)); - EXPECT_STREQ("arm", PlatformDarwinTester::GetCompatibleArch(core, 6)); - EXPECT_STREQ("thumbv7s", PlatformDarwinTester::GetCompatibleArch(core, 7)); -} - -TEST(PlatformDarwinTest, GetCompatibleArchARMv7m) { - const ArchSpec::Core core = ArchSpec::eCore_arm_armv7m; - EXPECT_STREQ("armv7m", PlatformDarwinTester::GetCompatibleArch(core, 0)); - EXPECT_STREQ("armv7", PlatformDarwinTester::GetCompatibleArch(core, 1)); - EXPECT_STREQ("arm", PlatformDarwinTester::GetCompatibleArch(core, 6)); - EXPECT_STREQ("thumbv7m", PlatformDarwinTester::GetCompatibleArch(core, 7)); -} - -TEST(PlatformDarwinTest, GetCompatibleArchARMv7em) { - const ArchSpec::Core core = ArchSpec::eCore_arm_armv7em; - EXPECT_STREQ("armv7em", PlatformDarwinTester::GetCompatibleArch(core, 0)); - EXPECT_STREQ("armv7", PlatformDarwinTester::GetCompatibleArch(core, 1)); - EXPECT_STREQ("arm", PlatformDarwinTester::GetCompatibleArch(core, 6)); - EXPECT_STREQ("thumbv7em", PlatformDarwinTester::GetCompatibleArch(core, 7)); -} - -TEST(PlatformDarwinTest, GetCompatibleArchARMv7) { - const ArchSpec::Core core = ArchSpec::eCore_arm_armv7; - EXPECT_STREQ("armv7", PlatformDarwinTester::GetCompatibleArch(core, 0)); - EXPECT_STREQ("armv6m", PlatformDarwinTester::GetCompatibleArch(core, 1)); - EXPECT_STREQ("arm", PlatformDarwinTester::GetCompatibleArch(core, 5)); - EXPECT_STREQ("thumbv7", PlatformDarwinTester::GetCompatibleArch(core, 6)); -} - -TEST(PlatformDarwinTest, GetCompatibleArchARMv6m) { - const ArchSpec::Core core = ArchSpec::eCore_arm_armv6m; - EXPECT_STREQ("armv6m", PlatformDarwinTester::GetCompatibleArch(core, 0)); - EXPECT_STREQ("armv6", PlatformDarwinTester::GetCompatibleArch(core, 1)); - EXPECT_STREQ("arm", PlatformDarwinTester::GetCompatibleArch(core, 4)); - EXPECT_STREQ("thumbv6m", PlatformDarwinTester::GetCompatibleArch(core, 5)); -} - -TEST(PlatformDarwinTest, GetCompatibleArchARMv6) { - const ArchSpec::Core core = ArchSpec::eCore_arm_armv6; - EXPECT_STREQ("armv6", PlatformDarwinTester::GetCompatibleArch(core, 0)); - EXPECT_STREQ("armv5", PlatformDarwinTester::GetCompatibleArch(core, 1)); - EXPECT_STREQ("arm", PlatformDarwinTester::GetCompatibleArch(core, 3)); - EXPECT_STREQ("thumbv6", PlatformDarwinTester::GetCompatibleArch(core, 4)); -} - -TEST(PlatformDarwinTest, GetCompatibleArchARMv5) { - const ArchSpec::Core core = ArchSpec::eCore_arm_armv5; - EXPECT_STREQ("armv5", PlatformDarwinTester::GetCompatibleArch(core, 0)); - EXPECT_STREQ("armv4", PlatformDarwinTester::GetCompatibleArch(core, 1)); - EXPECT_STREQ("arm", PlatformDarwinTester::GetCompatibleArch(core, 2)); - EXPECT_STREQ("thumbv5", PlatformDarwinTester::GetCompatibleArch(core, 3)); -} - -TEST(PlatformDarwinTest, GetCompatibleArchARMv4) { - const ArchSpec::Core core = ArchSpec::eCore_arm_armv4; - EXPECT_STREQ("armv4", PlatformDarwinTester::GetCompatibleArch(core, 0)); - EXPECT_STREQ("arm", PlatformDarwinTester::GetCompatibleArch(core, 1)); - EXPECT_STREQ("thumbv4t", PlatformDarwinTester::GetCompatibleArch(core, 2)); - EXPECT_STREQ("thumb", PlatformDarwinTester::GetCompatibleArch(core, 3)); -}