1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01: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.

llvm-svn: 277831
This commit is contained in:
Zachary Turner 2016-08-05 16:45:07 +00:00
parent 94e0f30ae2
commit 5d687dc19f

View File

@ -81,6 +81,13 @@ bool contains(const T (&array)[N], const T element) {
std::end(array); 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) { TEST(TargetParserTest, ARMArchName) {
for (ARM::ArchKind AK = static_cast<ARM::ArchKind>(0); for (ARM::ArchKind AK = static_cast<ARM::ArchKind>(0);
AK <= ARM::ArchKind::AK_LAST; AK <= ARM::ArchKind::AK_LAST;
@ -313,10 +320,12 @@ TEST(TargetParserTest, ARMparseCPUArch) {
"cortex-a73", "cyclone", "exynos-m1", "exynos-m2", "cortex-a73", "cyclone", "exynos-m1", "exynos-m2",
"iwmmxt", "xscale", "swift"}; "iwmmxt", "xscale", "swift"};
for (const auto &ARMCPUName : kARMCPUNames) for (const auto &ARMCPUName : kARMCPUNames) {
EXPECT_TRUE(contains(CPU, ARMCPUName.Name) if (contains(CPU, ARMCPUName.Name))
? (ARM::AK_INVALID != ARM::parseCPUArch(ARMCPUName.Name)) EXPECT_NE(ARM::AK_INVALID, ARM::parseCPUArch(ARMCPUName.Name));
: (ARM::AK_INVALID == ARM::parseCPUArch(ARMCPUName.Name))); else
EXPECT_EQ(ARM::AK_INVALID, ARM::parseCPUArch(ARMCPUName.Name));
}
} }
TEST(TargetParserTest, ARMparseArchEndianAndISA) { TEST(TargetParserTest, ARMparseArchEndianAndISA) {