[Lldb-commits] [lldb] r170152 - in /lldb/trunk: include/lldb/Core/ source/Commands/ source/Core/ source/Host/macosx/ source/Plugins/ObjectContainer/BSD-Archive/ source/Plugins/ObjectFile/Mach-O/ source/Plugins/Platform/FreeBSD/ source/Plugins/Platform/MacOSX/ source/Target/

Sean Callanan scallanan at apple.com
Thu Dec 13 14:07:14 PST 2012


Author: spyffe
Date: Thu Dec 13 16:07:14 2012
New Revision: 170152

URL: http://llvm.org/viewvc/llvm-project?rev=170152&view=rev
Log:
Removed the == and != operators from ArchSpec, since
equality can be strict or loose and we want code to
explicitly choose one or the other.

Also renamed the Compare function to IsEqualTo, to
avoid confusion.

<rdar://problem/12856749>

Modified:
    lldb/trunk/include/lldb/Core/ArchSpec.h
    lldb/trunk/source/Commands/CommandObjectProcess.cpp
    lldb/trunk/source/Core/ArchSpec.cpp
    lldb/trunk/source/Core/Module.cpp
    lldb/trunk/source/Host/macosx/Symbols.cpp
    lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
    lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
    lldb/trunk/source/Target/Platform.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/Target.cpp
    lldb/trunk/source/Target/TargetList.cpp

Modified: lldb/trunk/include/lldb/Core/ArchSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=170152&r1=170151&r2=170152&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ArchSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ArchSpec.h Thu Dec 13 16:07:14 2012
@@ -389,7 +389,7 @@
 
 protected:
     bool
-    Compare (const ArchSpec& rhs, bool exact_match) const;
+    IsEqualTo (const ArchSpec& rhs, bool exact_match) const;
 
     llvm::Triple m_triple;
     Core m_core;
@@ -401,35 +401,6 @@
     CoreUpdated (bool update_triple);
 };
 
-
-//------------------------------------------------------------------
-/// @fn bool operator== (const ArchSpec& lhs, const ArchSpec& rhs)
-/// @brief Equal to operator.
-///
-/// Tests two ArchSpec objects to see if they are equal.
-///
-/// @param[in] lhs The Left Hand Side ArchSpec object to compare.
-/// @param[in] rhs The Left Hand Side ArchSpec object to compare.
-///
-/// Uses the IsExactMatch() method for comparing the cpu types.
-///
-/// @return true if \a lhs is equal to \a rhs
-//------------------------------------------------------------------
-bool operator==(const ArchSpec& lhs, const ArchSpec& rhs);
-
-//------------------------------------------------------------------
-/// @fn bool operator!= (const ArchSpec& lhs, const ArchSpec& rhs)
-/// @brief Not equal to operator.
-///
-/// Tests two ArchSpec objects to see if they are not equal.
-///
-/// @param[in] lhs The Left Hand Side ArchSpec object to compare.
-/// @param[in] rhs The Left Hand Side ArchSpec object to compare.
-///
-/// @return true if \a lhs is not equal to \a rhs
-//------------------------------------------------------------------
-bool operator!=(const ArchSpec& lhs, const ArchSpec& rhs);
-
 //------------------------------------------------------------------
 /// @fn bool operator< (const ArchSpec& lhs, const ArchSpec& rhs)
 /// @brief Less than operator.

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=170152&r1=170151&r2=170152&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Thu Dec 13 16:07:14 2012
@@ -642,7 +642,7 @@
             {
                 result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetTriple().getTriple().c_str());
             }
-            else if (old_arch_spec != target->GetArchitecture())
+            else if (!old_arch_spec.IsExactMatch(target->GetArchitecture()))
             {
                 result.AppendWarningWithFormat("Architecture changed from %s to %s.\n", 
                                                old_arch_spec.GetTriple().getTriple().c_str(),

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=170152&r1=170151&r2=170152&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Thu Dec 13 16:07:14 2012
@@ -717,17 +717,17 @@
 bool
 ArchSpec::IsExactMatch (const ArchSpec& rhs) const
 {
-    return Compare (rhs, true);
+    return IsEqualTo (rhs, true);
 }
 
 bool
 ArchSpec::IsCompatibleMatch (const ArchSpec& rhs) const
 {
-    return Compare (rhs, false);
+    return IsEqualTo (rhs, false);
 }
 
 bool
-ArchSpec::Compare (const ArchSpec& rhs, bool exact_match) const
+ArchSpec::IsEqualTo (const ArchSpec& rhs, bool exact_match) const
 {
     if (GetByteOrder() != rhs.GetByteOrder())
         return false;
@@ -746,12 +746,15 @@
         const llvm::Triple::VendorType rhs_triple_vendor = rhs_triple.getVendor();
         if (lhs_triple_vendor != rhs_triple_vendor)
         {
-            const bool rhs_vendor_specified = rhs.TripleVendorWasSpecified();
-            const bool lhs_vendor_specified = TripleVendorWasSpecified();
-            // Both architectures had the vendor specified, so if they aren't
-            // equal then we return false
-            if (rhs_vendor_specified && lhs_vendor_specified)
-                return false;
+            if (exact_match)
+            {
+                const bool rhs_vendor_specified = rhs.TripleVendorWasSpecified();
+                const bool lhs_vendor_specified = TripleVendorWasSpecified();
+                // Both architectures had the vendor specified, so if they aren't
+                // equal then we return false
+                if (rhs_vendor_specified && lhs_vendor_specified)
+                    return false;
+            }
             
             // Only fail if both vendor types are not unknown
             if (lhs_triple_vendor != llvm::Triple::UnknownVendor &&
@@ -763,12 +766,15 @@
         const llvm::Triple::OSType rhs_triple_os = rhs_triple.getOS();
         if (lhs_triple_os != rhs_triple_os)
         {
-            const bool rhs_os_specified = rhs.TripleOSWasSpecified();
-            const bool lhs_os_specified = TripleOSWasSpecified();
-            // Both architectures had the OS specified, so if they aren't
-            // equal then we return false
-            if (rhs_os_specified && lhs_os_specified)
-                return false;
+            if (exact_match)
+            {
+                const bool rhs_os_specified = rhs.TripleOSWasSpecified();
+                const bool lhs_os_specified = TripleOSWasSpecified();
+                // Both architectures had the OS specified, so if they aren't
+                // equal then we return false
+                if (rhs_os_specified && lhs_os_specified)
+                    return false;
+            }
             // Only fail if both os types are not unknown
             if (lhs_triple_os != llvm::Triple::UnknownOS &&
                 rhs_triple_os != llvm::Triple::UnknownOS)
@@ -869,18 +875,6 @@
 }
 
 bool
-lldb_private::operator== (const ArchSpec& lhs, const ArchSpec& rhs)
-{
-    return lhs.IsExactMatch (rhs);
-}
-
-bool
-lldb_private::operator!= (const ArchSpec& lhs, const ArchSpec& rhs)
-{
-    return !(lhs == rhs);
-}
-
-bool
 lldb_private::operator<(const ArchSpec& lhs, const ArchSpec& rhs)
 {
     const ArchSpec::Core lhs_core = lhs.GetCore ();

Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=170152&r1=170151&r2=170152&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Thu Dec 13 16:07:14 2012
@@ -1202,7 +1202,7 @@
         m_arch = new_arch;
         return true;
     }    
-    return m_arch == new_arch;
+    return m_arch.IsExactMatch(new_arch);
 }
 
 bool 
@@ -1268,7 +1268,7 @@
     const ArchSpec &arch = module_ref.GetArchitecture();
     if (arch.IsValid())
     {
-        if (m_arch != arch)
+        if (!m_arch.IsCompatibleMatch(arch))
             return false;
     }
     

Modified: lldb/trunk/source/Host/macosx/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=170152&r1=170151&r2=170152&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Symbols.cpp (original)
+++ lldb/trunk/source/Host/macosx/Symbols.cpp Thu Dec 13 16:07:14 2012
@@ -83,7 +83,7 @@
     {
         ArchSpec file_arch(eArchTypeMachO, cputype, cpusubtype);
 
-        if (file_arch != *arch)
+        if (file_arch.IsCompatibleMatch(*arch))
             return false;
     }
 
@@ -181,7 +181,7 @@
         if (arch)
         {
             ArchSpec fat_arch(eArchTypeMachO, arch_cputype, arch_cpusubtype);
-            if (fat_arch != *arch)
+            if (fat_arch.IsCompatibleMatch(*arch))
                 continue;
         }
 
@@ -797,7 +797,7 @@
                                         ModuleSpec curr_module_spec;
                                         if (GetModuleSpecInfoFromUUIDDictionary (values[i], curr_module_spec))
                                         {
-                                            if (module_spec.GetArchitecture() == curr_module_spec.GetArchitecture())
+                                            if (module_spec.GetArchitecture().IsCompatibleMatch(curr_module_spec.GetArchitecture()))
                                             {
                                                 module_spec = curr_module_spec;
                                                 return true;

Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp?rev=170152&r1=170151&r2=170152&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Thu Dec 13 16:07:14 2012
@@ -165,7 +165,7 @@
     // delete an archive entry...
     while (pos != archive_map.end() && pos->first == file)
     {
-        if (pos->second->GetArchitecture() == arch)
+        if (pos->second->GetArchitecture().IsCompatibleMatch(arch))
         {
             if (pos->second->GetModificationTime() == time)
             {

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=170152&r1=170151&r2=170152&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Thu Dec 13 16:07:14 2012
@@ -564,7 +564,7 @@
             
             // Check if the module has a required architecture
             const ArchSpec &module_arch = module_sp->GetArchitecture();
-            if (module_arch.IsValid() && !module_arch.IsExactMatch(mach_arch))
+            if (module_arch.IsValid() && !module_arch.IsCompatibleMatch(mach_arch))
                 return false;
 
             if (SetModulesArchitecture (mach_arch))

Modified: lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp?rev=170152&r1=170151&r2=170152&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp Thu Dec 13 16:07:14 2012
@@ -630,7 +630,7 @@
     {
         ArchSpec platform_arch (Host::GetArchitecture (Host::eSystemDefaultArchitecture));
         ArchSpec platform_arch64 (Host::GetArchitecture (Host::eSystemDefaultArchitecture64));
-        if (platform_arch == platform_arch64)
+        if (platform_arch.IsExactMatch(platform_arch64))
         {
             // This freebsd platform supports both 32 and 64 bit. Since we already
             // returned the 64 bit arch for idx == 0, return the 32 bit arch

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=170152&r1=170151&r2=170152&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Thu Dec 13 16:07:14 2012
@@ -678,7 +678,7 @@
     {
         ArchSpec platform_arch (Host::GetArchitecture (Host::eSystemDefaultArchitecture));
         ArchSpec platform_arch64 (Host::GetArchitecture (Host::eSystemDefaultArchitecture64));
-        if (platform_arch == platform_arch64)
+        if (platform_arch.IsExactMatch(platform_arch64))
         {
             // This macosx platform supports both 32 and 64 bit. Since we already
             // returned the 64 bit arch for idx == 0, return the 32 bit arch 

Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=170152&r1=170151&r2=170152&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Thu Dec 13 16:07:14 2012
@@ -688,7 +688,7 @@
         ArchSpec platform_arch;
         for (uint32_t arch_idx=0; GetSupportedArchitectureAtIndex (arch_idx, platform_arch); ++arch_idx)
         {
-            if (arch == platform_arch)
+            if (arch.IsCompatibleMatch(platform_arch))
             {
                 if (compatible_arch_ptr)
                     *compatible_arch_ptr = platform_arch;

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=170152&r1=170151&r2=170152&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu Dec 13 16:07:14 2012
@@ -831,7 +831,7 @@
         return false;
     
     if (m_match_info.GetArchitecture().IsValid() && 
-        m_match_info.GetArchitecture() != proc_info.GetArchitecture())
+        !m_match_info.GetArchitecture().IsCompatibleMatch(proc_info.GetArchitecture()))
         return false;
     return true;
 }
@@ -2971,7 +2971,7 @@
             ProcessInstanceInfo process_info;
             platform_sp->GetProcessInfo (GetID(), process_info);
             const ArchSpec &process_arch = process_info.GetArchitecture();
-            if (process_arch.IsValid() && m_target.GetArchitecture() != process_arch)
+            if (process_arch.IsValid() && !m_target.GetArchitecture().IsExactMatch(process_arch))
                 m_target.SetArchitecture (process_arch);
         }
     }

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=170152&r1=170151&r2=170152&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Dec 13 16:07:14 2012
@@ -1054,7 +1054,7 @@
 Target::SetArchitecture (const ArchSpec &arch_spec)
 {
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET));
-    if (m_arch == arch_spec || !m_arch.IsValid())
+    if (m_arch.IsCompatibleMatch(arch_spec) || !m_arch.IsValid())
     {
         // If we haven't got a valid arch spec, or the architectures are
         // compatible, so just update the architecture. Architectures can be

Modified: lldb/trunk/source/Target/TargetList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=170152&r1=170151&r2=170152&view=diff
==============================================================================
--- lldb/trunk/source/Target/TargetList.cpp (original)
+++ lldb/trunk/source/Target/TargetList.cpp Thu Dec 13 16:07:14 2012
@@ -301,7 +301,7 @@
             {
                 if (exe_arch_ptr)
                 {
-                    if (*exe_arch_ptr != exe_module->GetArchitecture())
+                    if (!exe_arch_ptr->IsCompatibleMatch(exe_module->GetArchitecture()))
                         continue;
                 }
                 target_sp = *pos;





More information about the lldb-commits mailing list