summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2012-12-13 22:07:14 +0000
committerSean Callanan <scallanan@apple.com>2012-12-13 22:07:14 +0000
commitbf4b7be68ee9da3cc43fedee101457140d3330cd (patch)
tree504cacce4cac1112fd46c89a9e5f39a3d3c232e4 /lldb/source
parent3960540e305dd27dc20e5e038f499149ddf5c4db (diff)
downloadbcm5719-llvm-bf4b7be68ee9da3cc43fedee101457140d3330cd.tar.gz
bcm5719-llvm-bf4b7be68ee9da3cc43fedee101457140d3330cd.zip
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> llvm-svn: 170152
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp2
-rw-r--r--lldb/source/Core/ArchSpec.cpp48
-rw-r--r--lldb/source/Core/Module.cpp4
-rw-r--r--lldb/source/Host/macosx/Symbols.cpp6
-rw-r--r--lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp2
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp2
-rw-r--r--lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp2
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp2
-rw-r--r--lldb/source/Target/Platform.cpp2
-rw-r--r--lldb/source/Target/Process.cpp4
-rw-r--r--lldb/source/Target/Target.cpp2
-rw-r--r--lldb/source/Target/TargetList.cpp2
12 files changed, 36 insertions, 42 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 1996cee57b0..9b5e2054f06 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -642,7 +642,7 @@ protected:
{
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(),
diff --git a/lldb/source/Core/ArchSpec.cpp b/lldb/source/Core/ArchSpec.cpp
index 30b057b4fa6..e020c2107b5 100644
--- a/lldb/source/Core/ArchSpec.cpp
+++ b/lldb/source/Core/ArchSpec.cpp
@@ -717,17 +717,17 @@ ArchSpec::GetMaximumOpcodeByteSize() const
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 @@ ArchSpec::Compare (const ArchSpec& rhs, bool exact_match) const
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 @@ ArchSpec::Compare (const ArchSpec& rhs, bool exact_match) const
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 @@ cores_match (const ArchSpec::Core core1, const ArchSpec::Core core2, bool try_in
}
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 ();
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index ffc9f7f2dc9..64426992c96 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1202,7 +1202,7 @@ Module::SetArchitecture (const ArchSpec &new_arch)
m_arch = new_arch;
return true;
}
- return m_arch == new_arch;
+ return m_arch.IsExactMatch(new_arch);
}
bool
@@ -1268,7 +1268,7 @@ Module::MatchesModuleSpec (const ModuleSpec &module_ref)
const ArchSpec &arch = module_ref.GetArchitecture();
if (arch.IsValid())
{
- if (m_arch != arch)
+ if (!m_arch.IsCompatibleMatch(arch))
return false;
}
diff --git a/lldb/source/Host/macosx/Symbols.cpp b/lldb/source/Host/macosx/Symbols.cpp
index a358336b4ee..e696d2782c8 100644
--- a/lldb/source/Host/macosx/Symbols.cpp
+++ b/lldb/source/Host/macosx/Symbols.cpp
@@ -83,7 +83,7 @@ SkinnyMachOFileContainsArchAndUUID
{
ArchSpec file_arch(eArchTypeMachO, cputype, cpusubtype);
- if (file_arch != *arch)
+ if (file_arch.IsCompatibleMatch(*arch))
return false;
}
@@ -181,7 +181,7 @@ UniversalMachOFileContainsArchAndUUID
if (arch)
{
ArchSpec fat_arch(eArchTypeMachO, arch_cputype, arch_cpusubtype);
- if (fat_arch != *arch)
+ if (fat_arch.IsCompatibleMatch(*arch))
continue;
}
@@ -797,7 +797,7 @@ Symbols::DownloadObjectAndSymbolFile (ModuleSpec &module_spec, bool force_lookup
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;
diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
index 08748f70b08..97aed1a323b 100644
--- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -165,7 +165,7 @@ ObjectContainerBSDArchive::Archive::FindCachedArchive (const FileSpec &file, con
// 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)
{
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 4d6d00755a5..926f17f6648 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -564,7 +564,7 @@ ObjectFileMachO::ParseHeader ()
// 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))
diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
index db9c079f1c1..f6cd4c2c684 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -630,7 +630,7 @@ PlatformFreeBSD::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
{
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
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 25acfdff2c2..b2ac6f22499 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -678,7 +678,7 @@ PlatformDarwin::x86GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch
{
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
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 86ef2a022ea..22fb9978711 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -688,7 +688,7 @@ Platform::IsCompatibleArchitecture (const ArchSpec &arch, ArchSpec *compatible_a
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;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 7ed4cb09b9a..5394923af39 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -831,7 +831,7 @@ ProcessInstanceInfoMatch::Matches (const ProcessInstanceInfo &proc_info) const
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 @@ Process::CompleteAttach ()
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);
}
}
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 888545a0f1a..e373efeea0a 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1054,7 +1054,7 @@ bool
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
diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp
index ff9e8558ccd..c67b42fa1fc 100644
--- a/lldb/source/Target/TargetList.cpp
+++ b/lldb/source/Target/TargetList.cpp
@@ -301,7 +301,7 @@ TargetList::FindTargetWithExecutableAndArchitecture
{
if (exe_arch_ptr)
{
- if (*exe_arch_ptr != exe_module->GetArchitecture())
+ if (!exe_arch_ptr->IsCompatibleMatch(exe_module->GetArchitecture()))
continue;
}
target_sp = *pos;
OpenPOWER on IntegriCloud