summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Langford <apl@fb.com>2019-02-27 00:47:39 +0000
committerAlex Langford <apl@fb.com>2019-02-27 00:47:39 +0000
commit6d6288ae977bfdb08dc2b731f34d9b1ebfc68748 (patch)
treea3bc029e5711bd673b7510fe31d09ac6c337660f
parent49ef2a4acdbba941d67d65b42d302191424c4119 (diff)
downloadbcm5719-llvm-6d6288ae977bfdb08dc2b731f34d9b1ebfc68748.tar.gz
bcm5719-llvm-6d6288ae977bfdb08dc2b731f34d9b1ebfc68748.zip
[Utility] Fix ArchSpec.MergeFrom to correctly merge environments
Summary: This behavior was originally added in rL252264 (git commit 76a7f365da) in order to be extra careful with handling platforms like watchos and tvos. However, as far as triples go, those two (and others) are treated as OSes and not environments, so that should not really apply here. Additionally, this behavior is incorrect and can lead to incorrect ArchSpecs. Because android is specified as an environment and not an OS, not propogating the environment can lead to modules and targets being misidentified. Differential Revision: https://reviews.llvm.org/D58664 llvm-svn: 354938
-rw-r--r--lldb/source/Utility/ArchSpec.cpp5
-rw-r--r--lldb/unittests/Utility/ArchSpecTest.cpp56
2 files changed, 42 insertions, 19 deletions
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index b28119b3b9d..f53b7d2da47 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -903,9 +903,8 @@ void ArchSpec::MergeFrom(const ArchSpec &other) {
UpdateCore();
}
if (!TripleEnvironmentWasSpecified() &&
- other.TripleEnvironmentWasSpecified() && !TripleVendorWasSpecified()) {
- if (other.TripleVendorWasSpecified())
- GetTriple().setEnvironment(other.GetTriple().getEnvironment());
+ other.TripleEnvironmentWasSpecified()) {
+ GetTriple().setEnvironment(other.GetTriple().getEnvironment());
}
// If this and other are both arm ArchSpecs and this ArchSpec is a generic
// "some kind of arm" spec but the other ArchSpec is a specific arm core,
diff --git a/lldb/unittests/Utility/ArchSpecTest.cpp b/lldb/unittests/Utility/ArchSpecTest.cpp
index 99d07bc71a0..b41d221fd57 100644
--- a/lldb/unittests/Utility/ArchSpecTest.cpp
+++ b/lldb/unittests/Utility/ArchSpecTest.cpp
@@ -134,22 +134,46 @@ TEST(ArchSpecTest, TestSetTriple) {
}
TEST(ArchSpecTest, MergeFrom) {
- ArchSpec A;
- ArchSpec B("x86_64-pc-linux");
-
- EXPECT_FALSE(A.IsValid());
- ASSERT_TRUE(B.IsValid());
- EXPECT_EQ(llvm::Triple::ArchType::x86_64, B.GetTriple().getArch());
- EXPECT_EQ(llvm::Triple::VendorType::PC, B.GetTriple().getVendor());
- EXPECT_EQ(llvm::Triple::OSType::Linux, B.GetTriple().getOS());
- EXPECT_EQ(ArchSpec::eCore_x86_64_x86_64, B.GetCore());
-
- A.MergeFrom(B);
- ASSERT_TRUE(A.IsValid());
- EXPECT_EQ(llvm::Triple::ArchType::x86_64, A.GetTriple().getArch());
- EXPECT_EQ(llvm::Triple::VendorType::PC, A.GetTriple().getVendor());
- EXPECT_EQ(llvm::Triple::OSType::Linux, A.GetTriple().getOS());
- EXPECT_EQ(ArchSpec::eCore_x86_64_x86_64, A.GetCore());
+ {
+ ArchSpec A;
+ ArchSpec B("x86_64-pc-linux");
+
+ EXPECT_FALSE(A.IsValid());
+ ASSERT_TRUE(B.IsValid());
+ EXPECT_EQ(llvm::Triple::ArchType::x86_64, B.GetTriple().getArch());
+ EXPECT_EQ(llvm::Triple::VendorType::PC, B.GetTriple().getVendor());
+ EXPECT_EQ(llvm::Triple::OSType::Linux, B.GetTriple().getOS());
+ EXPECT_EQ(ArchSpec::eCore_x86_64_x86_64, B.GetCore());
+
+ A.MergeFrom(B);
+ ASSERT_TRUE(A.IsValid());
+ EXPECT_EQ(llvm::Triple::ArchType::x86_64, A.GetTriple().getArch());
+ EXPECT_EQ(llvm::Triple::VendorType::PC, A.GetTriple().getVendor());
+ EXPECT_EQ(llvm::Triple::OSType::Linux, A.GetTriple().getOS());
+ EXPECT_EQ(ArchSpec::eCore_x86_64_x86_64, A.GetCore());
+ }
+ {
+ ArchSpec A("aarch64");
+ ArchSpec B("aarch64--linux-android");
+
+ EXPECT_TRUE(A.IsValid());
+ EXPECT_TRUE(B.IsValid());
+
+ EXPECT_EQ(llvm::Triple::ArchType::aarch64, B.GetTriple().getArch());
+ EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor,
+ B.GetTriple().getVendor());
+ EXPECT_EQ(llvm::Triple::OSType::Linux, B.GetTriple().getOS());
+ EXPECT_EQ(llvm::Triple::EnvironmentType::Android,
+ B.GetTriple().getEnvironment());
+
+ A.MergeFrom(B);
+ EXPECT_EQ(llvm::Triple::ArchType::aarch64, A.GetTriple().getArch());
+ EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor,
+ A.GetTriple().getVendor());
+ EXPECT_EQ(llvm::Triple::OSType::Linux, A.GetTriple().getOS());
+ EXPECT_EQ(llvm::Triple::EnvironmentType::Android,
+ A.GetTriple().getEnvironment());
+ }
}
TEST(ArchSpecTest, MergeFromMachOUnknown) {
OpenPOWER on IntegriCloud