mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-18 02:16:43 +00:00
Fix TargetParser unit tests for ARM / AArch64.
String pooling is not guaranteed by the standard, so if you're comparing two different string literals for equality, you have to use strcmp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277831 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e648a0611e
commit
3c7b828443
@ -81,6 +81,13 @@ bool contains(const T (&array)[N], const T element) {
|
||||
std::end(array);
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
bool contains(const char *(&array)[N], const char *element) {
|
||||
return std::find_if(std::begin(array), std::end(array), [&](const char *S) {
|
||||
return ::strcmp(S, element) == 0;
|
||||
}) != std::end(array);
|
||||
}
|
||||
|
||||
TEST(TargetParserTest, ARMArchName) {
|
||||
for (ARM::ArchKind AK = static_cast<ARM::ArchKind>(0);
|
||||
AK <= ARM::ArchKind::AK_LAST;
|
||||
@ -313,10 +320,12 @@ TEST(TargetParserTest, ARMparseCPUArch) {
|
||||
"cortex-a73", "cyclone", "exynos-m1", "exynos-m2",
|
||||
"iwmmxt", "xscale", "swift"};
|
||||
|
||||
for (const auto &ARMCPUName : kARMCPUNames)
|
||||
EXPECT_TRUE(contains(CPU, ARMCPUName.Name)
|
||||
? (ARM::AK_INVALID != ARM::parseCPUArch(ARMCPUName.Name))
|
||||
: (ARM::AK_INVALID == ARM::parseCPUArch(ARMCPUName.Name)));
|
||||
for (const auto &ARMCPUName : kARMCPUNames) {
|
||||
if (contains(CPU, ARMCPUName.Name))
|
||||
EXPECT_NE(ARM::AK_INVALID, ARM::parseCPUArch(ARMCPUName.Name));
|
||||
else
|
||||
EXPECT_EQ(ARM::AK_INVALID, ARM::parseCPUArch(ARMCPUName.Name));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(TargetParserTest, ARMparseArchEndianAndISA) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user