[Lldb-commits] [PATCH] D61659: Fix bug in ArchSpec::MergeFrom

Phabricator via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed May 8 15:01:04 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL360292: Fix bug in ArchSpec::MergeFrom (authored by gclayton, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61659?vs=198538&id=198734#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61659/new/

https://reviews.llvm.org/D61659

Files:
  lldb/trunk/source/Utility/ArchSpec.cpp
  lldb/trunk/unittests/Utility/ArchSpecTest.cpp


Index: lldb/trunk/unittests/Utility/ArchSpecTest.cpp
===================================================================
--- lldb/trunk/unittests/Utility/ArchSpecTest.cpp
+++ lldb/trunk/unittests/Utility/ArchSpecTest.cpp
@@ -10,6 +10,7 @@
 
 #include "lldb/Utility/ArchSpec.h"
 #include "llvm/BinaryFormat/MachO.h"
+#include "llvm/BinaryFormat/ELF.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -174,6 +175,31 @@
     EXPECT_EQ(llvm::Triple::EnvironmentType::Android,
               A.GetTriple().getEnvironment());
   }
+  {
+    ArchSpec A, B;
+    A.SetArchitecture(eArchTypeELF, llvm::ELF::EM_ARM,
+                      LLDB_INVALID_CPUTYPE, llvm::ELF::ELFOSABI_NONE);
+    B.SetArchitecture(eArchTypeELF, llvm::ELF::EM_ARM,
+                      LLDB_INVALID_CPUTYPE, llvm::ELF::ELFOSABI_LINUX);
+
+    EXPECT_TRUE(A.IsValid());
+    EXPECT_TRUE(B.IsValid());
+    
+    EXPECT_EQ(llvm::Triple::ArchType::arm, 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::UnknownEnvironment,
+              B.GetTriple().getEnvironment());
+    
+    A.MergeFrom(B);
+    EXPECT_EQ(llvm::Triple::ArchType::arm, 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::UnknownEnvironment,
+              A.GetTriple().getEnvironment());
+  }
 }
 
 TEST(ArchSpecTest, MergeFromMachOUnknown) {
Index: lldb/trunk/source/Utility/ArchSpec.cpp
===================================================================
--- lldb/trunk/source/Utility/ArchSpec.cpp
+++ lldb/trunk/source/Utility/ArchSpec.cpp
@@ -859,7 +859,7 @@
 void ArchSpec::MergeFrom(const ArchSpec &other) {
   if (!TripleVendorWasSpecified() && other.TripleVendorWasSpecified())
     GetTriple().setVendor(other.GetTriple().getVendor());
-  if (!TripleOSWasSpecified() && other.TripleVendorWasSpecified())
+  if (!TripleOSWasSpecified() && other.TripleOSWasSpecified())
     GetTriple().setOS(other.GetTriple().getOS());
   if (GetTriple().getArch() == llvm::Triple::UnknownArch) {
     GetTriple().setArch(other.GetTriple().getArch());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61659.198734.patch
Type: text/x-patch
Size: 2373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190508/04e9d829/attachment-0001.bin>


More information about the lldb-commits mailing list