static const ArchSpec &
GetArchitecture(ArchitectureKind arch_kind = eArchKindDefault);
+ static llvm::Optional<ArchitectureKind> ParseArchitectureKind(llvm::StringRef kind);
+
//------------------------------------------------------------------
/// Find a resource files that are related to LLDB.
///
#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"
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();
}
: 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();
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())
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))
-//===-- HostTest.cpp --------------------------------------------*- C++ -*-===//
+//===-- HostInfoTest.cpp ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/HostInfo.h"
+#include "lldb/lldb-defines.h"
#include "gtest/gtest.h"
using namespace lldb_private;
EXPECT_EQ(spec.GetTriple().getOS(), triple.getOS());
EXPECT_EQ(spec.GetTriple().getVendor(), triple.getVendor());
EXPECT_EQ(spec.GetTriple().getEnvironment(), triple.getEnvironment());
+
+ // Test LLDB_ARCH_DEFAULT
+ EXPECT_EQ(HostInfo::GetAugmentedArchSpec(LLDB_ARCH_DEFAULT).GetTriple(),
+ HostInfo::GetArchitecture(HostInfo::eArchKindDefault).GetTriple());
}