diff options
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/Core/ArchSpec.cpp | 13 | ||||
-rw-r--r-- | lldb/source/Host/common/HostInfoBase.cpp | 11 | ||||
-rw-r--r-- | lldb/source/Target/Platform.cpp | 3 |
3 files changed, 15 insertions, 12 deletions
diff --git a/lldb/source/Core/ArchSpec.cpp b/lldb/source/Core/ArchSpec.cpp index 5e256b8a07e..a3a7a9aca9b 100644 --- a/lldb/source/Core/ArchSpec.cpp +++ b/lldb/source/Core/ArchSpec.cpp @@ -9,7 +9,6 @@ #include "lldb/Core/ArchSpec.h" -#include "lldb/Host/HostInfo.h" #include "lldb/Utility/NameMatches.h" #include "lldb/Utility/Stream.h" // for Stream #include "lldb/Utility/StringList.h" @@ -874,17 +873,7 @@ bool ArchSpec::SetTriple(llvm::StringRef triple) { if (ParseMachCPUDashSubtypeTriple(triple, *this)) return true; - if (triple.startswith(LLDB_ARCH_DEFAULT)) { - // Special case for the current host default architectures... - if (triple.equals(LLDB_ARCH_DEFAULT_32BIT)) - *this = HostInfo::GetArchitecture(HostInfo::eArchKind32); - else if (triple.equals(LLDB_ARCH_DEFAULT_64BIT)) - *this = HostInfo::GetArchitecture(HostInfo::eArchKind64); - else if (triple.equals(LLDB_ARCH_DEFAULT)) - *this = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); - } else { - SetTriple(llvm::Triple(llvm::Triple::normalize(triple))); - } + SetTriple(llvm::Triple(llvm::Triple::normalize(triple))); return IsValid(); } diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp index 1362a0cdd46..c703a93566a 100644 --- a/lldb/source/Host/common/HostInfoBase.cpp +++ b/lldb/source/Host/common/HostInfoBase.cpp @@ -103,6 +103,14 @@ const ArchSpec &HostInfoBase::GetArchitecture(ArchitectureKind arch_kind) { : g_fields->m_host_arch_32; } +llvm::Optional<HostInfoBase::ArchitectureKind> HostInfoBase::ParseArchitectureKind(llvm::StringRef kind) { + return llvm::StringSwitch<llvm::Optional<ArchitectureKind>>(kind) + .Case(LLDB_ARCH_DEFAULT, eArchKindDefault) + .Case(LLDB_ARCH_DEFAULT_32BIT, eArchKind32) + .Case(LLDB_ARCH_DEFAULT_64BIT, eArchKind64) + .Default(llvm::None); +} + bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) { file_spec.Clear(); @@ -258,6 +266,9 @@ ArchSpec HostInfoBase::GetAugmentedArchSpec(llvm::StringRef triple) { if (!ArchSpec::ContainsOnlyArch(normalized_triple)) return ArchSpec(triple); + if (auto kind = HostInfo::ParseArchitectureKind(triple)) + return HostInfo::GetArchitecture(*kind); + llvm::Triple host_triple(llvm::sys::getDefaultTargetTriple()); if (normalized_triple.getVendorName().empty()) diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index 60aa0079060..25aa7159122 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -976,6 +976,9 @@ ArchSpec Platform::GetAugmentedArchSpec(llvm::StringRef triple) { if (!ArchSpec::ContainsOnlyArch(normalized_triple)) return ArchSpec(triple); + if (auto kind = HostInfo::ParseArchitectureKind(triple)) + return HostInfo::GetArchitecture(*kind); + ArchSpec compatible_arch; ArchSpec raw_arch(triple); if (!IsCompatibleArchitecture(raw_arch, false, &compatible_arch)) |