[Lldb-commits] [lldb] r139762 - /lldb/trunk/source/Core/ArchSpec.cpp

Jim Ingham jingham at apple.com
Wed Sep 14 18:07:30 PDT 2011


Author: jingham
Date: Wed Sep 14 20:07:30 2011
New Revision: 139762

URL: http://llvm.org/viewvc/llvm-project?rev=139762&view=rev
Log:
Fix ArchSpec::operator== to take the Triple into account as well as the Core.  Also make the constructors explicit.

Modified:
    lldb/trunk/source/Core/ArchSpec.cpp

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=139762&r1=139761&r2=139762&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Wed Sep 14 20:07:30 2011
@@ -601,56 +601,78 @@
 bool
 lldb_private::operator== (const ArchSpec& lhs, const ArchSpec& rhs)
 {
+    if (lhs.GetByteOrder() != rhs.GetByteOrder())
+        return false;
+        
     const ArchSpec::Core lhs_core = lhs.GetCore ();
     const ArchSpec::Core rhs_core = rhs.GetCore ();
 
+    bool core_match = false;
     if (lhs_core == rhs_core)
-        return true;
-
-    if (lhs_core == ArchSpec::kCore_any || rhs_core == ArchSpec::kCore_any)
-        return true;
-
-    if (lhs_core == ArchSpec::kCore_arm_any)
-    {
-        if ((rhs_core >= ArchSpec::kCore_arm_first && rhs_core <= ArchSpec::kCore_arm_last) || (rhs_core == ArchSpec::kCore_arm_any))
-            return true;
-    }
-    else if (rhs_core == ArchSpec::kCore_arm_any)
-    {
-        if ((lhs_core >= ArchSpec::kCore_arm_first && lhs_core <= ArchSpec::kCore_arm_last) || (lhs_core == ArchSpec::kCore_arm_any))
-            return true;
-    }
-    else if (lhs_core == ArchSpec::kCore_x86_32_any)
-    {
-        if ((rhs_core >= ArchSpec::kCore_x86_32_first && rhs_core <= ArchSpec::kCore_x86_32_last) || (rhs_core == ArchSpec::kCore_x86_32_any))
-            return true;
-    }
-    else if (rhs_core == ArchSpec::kCore_x86_32_any)
-    {
-        if ((lhs_core >= ArchSpec::kCore_x86_32_first && lhs_core <= ArchSpec::kCore_x86_32_last) || (lhs_core == ArchSpec::kCore_x86_32_any))
-            return true;
-    }
-    else if (lhs_core == ArchSpec::kCore_ppc_any)
-    {
-        if ((rhs_core >= ArchSpec::kCore_ppc_first && rhs_core <= ArchSpec::kCore_ppc_last) || (rhs_core == ArchSpec::kCore_ppc_any))
-            return true;
-    }
-    else if (rhs_core == ArchSpec::kCore_ppc_any)
-    {
-        if ((lhs_core >= ArchSpec::kCore_ppc_first && lhs_core <= ArchSpec::kCore_ppc_last) || (lhs_core == ArchSpec::kCore_ppc_any))
-            return true;
-    }
-    else if (lhs_core == ArchSpec::kCore_ppc64_any)
-    {
-        if ((rhs_core >= ArchSpec::kCore_ppc64_first && rhs_core <= ArchSpec::kCore_ppc64_last) || (rhs_core == ArchSpec::kCore_ppc64_any))
-            return true;
-    }
-    else if (rhs_core == ArchSpec::kCore_ppc64_any)
+        core_match = true;
+    else
     {
-        if ((lhs_core >= ArchSpec::kCore_ppc64_first && lhs_core <= ArchSpec::kCore_ppc64_last) || (lhs_core == ArchSpec::kCore_ppc64_any))
+
+        if (lhs_core == ArchSpec::kCore_any || rhs_core == ArchSpec::kCore_any)
+            core_match = true;
+        else
+        {
+            if (lhs_core == ArchSpec::kCore_arm_any)
+            {
+                if ((rhs_core >= ArchSpec::kCore_arm_first && rhs_core <= ArchSpec::kCore_arm_last) || (rhs_core == ArchSpec::kCore_arm_any))
+                    core_match = true;
+            }
+            else if (rhs_core == ArchSpec::kCore_arm_any)
+            {
+                if ((lhs_core >= ArchSpec::kCore_arm_first && lhs_core <= ArchSpec::kCore_arm_last) || (lhs_core == ArchSpec::kCore_arm_any))
+                    core_match = true;
+            }
+            else if (lhs_core == ArchSpec::kCore_x86_32_any)
+            {
+                if ((rhs_core >= ArchSpec::kCore_x86_32_first && rhs_core <= ArchSpec::kCore_x86_32_last) || (rhs_core == ArchSpec::kCore_x86_32_any))
+                    core_match = true;
+            }
+            else if (rhs_core == ArchSpec::kCore_x86_32_any)
+            {
+                if ((lhs_core >= ArchSpec::kCore_x86_32_first && lhs_core <= ArchSpec::kCore_x86_32_last) || (lhs_core == ArchSpec::kCore_x86_32_any))
+                    core_match = true;
+            }
+            else if (lhs_core == ArchSpec::kCore_ppc_any)
+            {
+                if ((rhs_core >= ArchSpec::kCore_ppc_first && rhs_core <= ArchSpec::kCore_ppc_last) || (rhs_core == ArchSpec::kCore_ppc_any))
+                    core_match = true;
+            }
+            else if (rhs_core == ArchSpec::kCore_ppc_any)
+            {
+                if ((lhs_core >= ArchSpec::kCore_ppc_first && lhs_core <= ArchSpec::kCore_ppc_last) || (lhs_core == ArchSpec::kCore_ppc_any))
+                    core_match = true;
+            }
+            else if (lhs_core == ArchSpec::kCore_ppc64_any)
+            {
+                if ((rhs_core >= ArchSpec::kCore_ppc64_first && rhs_core <= ArchSpec::kCore_ppc64_last) || (rhs_core == ArchSpec::kCore_ppc64_any))
+                    core_match = true;
+            }
+            else if (rhs_core == ArchSpec::kCore_ppc64_any)
+            {
+                if ((lhs_core >= ArchSpec::kCore_ppc64_first && lhs_core <= ArchSpec::kCore_ppc64_last) || (lhs_core == ArchSpec::kCore_ppc64_any))
+                    core_match = true;
+            }
+        }
+    }
+    if (!core_match)
+        return false;
+    else
+    {
+        const llvm::Triple &lhs_triple = lhs.GetTriple();
+        const llvm::Triple &rhs_triple = rhs.GetTriple();
+        if (lhs_triple.getVendor() != rhs_triple.getVendor()
+            || lhs_triple.getOS() != rhs_triple.getOS()
+            || lhs_triple.getArch() != rhs_triple.getArch()
+            || lhs_triple.getEnvironment() != rhs_triple.getEnvironment())
+            return false;
+        else
             return true;
     }
-    return false;
 }
 
 bool





More information about the lldb-commits mailing list