[llvm] r357733 - [TextAPI] Prefix all architecture enums to fix the build on i386.
Juergen Ributzka via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 4 15:56:50 PDT 2019
Author: ributzka
Date: Thu Apr 4 15:56:50 2019
New Revision: 357733
URL: http://llvm.org/viewvc/llvm-project?rev=357733&view=rev
Log:
[TextAPI] Prefix all architecture enums to fix the build on i386.
Summary: This changes the Architecture enum to use a prefix (AK_) to prevent the
preprocessor from replacing i386 with 1 when building llvm/clang for i386.
Reviewers: steven_wu, lhames, mstorsjo
Reviewed By: mstorsjo
Subscribers: hiraditya, jkorous, dexonsmith, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60241
Modified:
llvm/trunk/include/llvm/TextAPI/MachO/Architecture.h
llvm/trunk/include/llvm/TextAPI/MachO/ArchitectureSet.h
llvm/trunk/lib/TextAPI/MachO/Architecture.cpp
llvm/trunk/lib/TextAPI/MachO/ArchitectureSet.cpp
llvm/trunk/lib/TextAPI/MachO/TextStubCommon.cpp
llvm/trunk/unittests/TextAPI/TextStubV1Tests.cpp
llvm/trunk/unittests/TextAPI/TextStubV2Tests.cpp
Modified: llvm/trunk/include/llvm/TextAPI/MachO/Architecture.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TextAPI/MachO/Architecture.h?rev=357733&r1=357732&r2=357733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TextAPI/MachO/Architecture.h (original)
+++ llvm/trunk/include/llvm/TextAPI/MachO/Architecture.h Thu Apr 4 15:56:50 2019
@@ -20,11 +20,11 @@ namespace llvm {
namespace MachO {
/// Defines the architecture slices that are supported by Text-based Stub files.
-enum class Architecture : uint8_t {
-#define ARCHINFO(Arch, Type, SubType) Arch,
+enum Architecture : uint8_t {
+#define ARCHINFO(Arch, Type, SubType) AK_##Arch,
#include "llvm/TextAPI/MachO/Architecture.def"
#undef ARCHINFO
- unknown, // this has to go last.
+ AK_unknown, // this has to go last.
};
/// Convert a CPU Type and Subtype pair to an architecture slice.
Modified: llvm/trunk/include/llvm/TextAPI/MachO/ArchitectureSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TextAPI/MachO/ArchitectureSet.h?rev=357733&r1=357732&r2=357733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TextAPI/MachO/ArchitectureSet.h (original)
+++ llvm/trunk/include/llvm/TextAPI/MachO/ArchitectureSet.h Thu Apr 4 15:56:50 2019
@@ -38,7 +38,7 @@ public:
ArchitectureSet(const std::vector<Architecture> &Archs);
void set(Architecture Arch) {
- if (Arch == Architecture::unknown)
+ if (Arch == AK_unknown)
return;
ArchSet |= 1U << static_cast<int>(Arch);
}
Modified: llvm/trunk/lib/TextAPI/MachO/Architecture.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TextAPI/MachO/Architecture.cpp?rev=357733&r1=357732&r2=357733&view=diff
==============================================================================
--- llvm/trunk/lib/TextAPI/MachO/Architecture.cpp (original)
+++ llvm/trunk/lib/TextAPI/MachO/Architecture.cpp Thu Apr 4 15:56:50 2019
@@ -21,29 +21,29 @@ Architecture getArchitectureFromCpuType(
#define ARCHINFO(Arch, Type, Subtype) \
if (CPUType == (Type) && \
(CPUSubType & ~MachO::CPU_SUBTYPE_MASK) == (Subtype)) \
- return Architecture::Arch;
+ return AK_##Arch;
#include "llvm/TextAPI/MachO/Architecture.def"
#undef ARCHINFO
- return Architecture::unknown;
+ return AK_unknown;
}
Architecture getArchitectureFromName(StringRef Name) {
return StringSwitch<Architecture>(Name)
-#define ARCHINFO(Arch, Type, Subtype) .Case(#Arch, Architecture::Arch)
+#define ARCHINFO(Arch, Type, Subtype) .Case(#Arch, AK_##Arch)
#include "llvm/TextAPI/MachO/Architecture.def"
#undef ARCHINFO
- .Default(Architecture::unknown);
+ .Default(AK_unknown);
}
StringRef getArchitectureName(Architecture Arch) {
switch (Arch) {
#define ARCHINFO(Arch, Type, Subtype) \
- case Architecture::Arch: \
+ case AK_##Arch: \
return #Arch;
#include "llvm/TextAPI/MachO/Architecture.def"
#undef ARCHINFO
- case Architecture::unknown:
+ case AK_unknown:
return "unknown";
}
@@ -55,11 +55,11 @@ StringRef getArchitectureName(Architectu
std::pair<uint32_t, uint32_t> getCPUTypeFromArchitecture(Architecture Arch) {
switch (Arch) {
#define ARCHINFO(Arch, Type, Subtype) \
- case Architecture::Arch: \
+ case AK_##Arch: \
return std::make_pair(Type, Subtype);
#include "llvm/TextAPI/MachO/Architecture.def"
#undef ARCHINFO
- case Architecture::unknown:
+ case AK_unknown:
return std::make_pair(0, 0);
}
Modified: llvm/trunk/lib/TextAPI/MachO/ArchitectureSet.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TextAPI/MachO/ArchitectureSet.cpp?rev=357733&r1=357732&r2=357733&view=diff
==============================================================================
--- llvm/trunk/lib/TextAPI/MachO/ArchitectureSet.cpp (original)
+++ llvm/trunk/lib/TextAPI/MachO/ArchitectureSet.cpp Thu Apr 4 15:56:50 2019
@@ -18,7 +18,7 @@ namespace MachO {
ArchitectureSet::ArchitectureSet(const std::vector<Architecture> &Archs)
: ArchitectureSet() {
for (auto Arch : Archs) {
- if (Arch == Architecture::unknown)
+ if (Arch == AK_unknown)
continue;
set(Arch);
}
@@ -51,7 +51,7 @@ ArchitectureSet::operator std::string()
ArchitectureSet::operator std::vector<Architecture>() const {
std::vector<Architecture> archs;
for (auto arch : *this) {
- if (arch == Architecture::unknown)
+ if (arch == AK_unknown)
continue;
archs.emplace_back(arch);
}
Modified: llvm/trunk/lib/TextAPI/MachO/TextStubCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TextAPI/MachO/TextStubCommon.cpp?rev=357733&r1=357732&r2=357733&view=diff
==============================================================================
--- llvm/trunk/lib/TextAPI/MachO/TextStubCommon.cpp (original)
+++ llvm/trunk/lib/TextAPI/MachO/TextStubCommon.cpp Thu Apr 4 15:56:50 2019
@@ -85,7 +85,7 @@ QuotingType ScalarTraits<PlatformKind>::
void ScalarBitSetTraits<ArchitectureSet>::bitset(IO &IO,
ArchitectureSet &Archs) {
#define ARCHINFO(arch, type, subtype) \
- IO.bitSetCase(Archs, #arch, 1U << static_cast<int>(Architecture::arch));
+ IO.bitSetCase(Archs, #arch, 1U << static_cast<int>(AK_##arch));
#include "llvm/TextAPI/MachO/Architecture.def"
#undef ARCHINFO
}
Modified: llvm/trunk/unittests/TextAPI/TextStubV1Tests.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/TextAPI/TextStubV1Tests.cpp?rev=357733&r1=357732&r2=357733&view=diff
==============================================================================
--- llvm/trunk/unittests/TextAPI/TextStubV1Tests.cpp (original)
+++ llvm/trunk/unittests/TextAPI/TextStubV1Tests.cpp Thu Apr 4 15:56:50 2019
@@ -87,8 +87,7 @@ TEST(TBDv1, ReadFile) {
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
- auto Archs = Architecture::armv7 | Architecture::armv7s |
- Architecture::armv7k | Architecture::arm64;
+ auto Archs = AK_armv7 | AK_armv7s | AK_armv7k | AK_arm64;
EXPECT_EQ(Archs, File->getArchitectures());
EXPECT_EQ(PlatformKind::iOS, File->getPlatform());
EXPECT_EQ(std::string("Test.dylib"), File->getInstallName());
@@ -133,8 +132,7 @@ TEST(TBDv1, ReadFile2) {
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
- auto Archs = Architecture::armv7 | Architecture::armv7s |
- Architecture::armv7k | Architecture::arm64;
+ auto Archs = AK_armv7 | AK_armv7s | AK_armv7k | AK_arm64;
EXPECT_EQ(Archs, File->getArchitectures());
EXPECT_EQ(PlatformKind::iOS, File->getPlatform());
EXPECT_EQ(std::string("Test.dylib"), File->getInstallName());
@@ -178,23 +176,22 @@ TEST(TBDv1, WriteFile) {
File.setPath("libfoo.dylib");
File.setInstallName("/usr/lib/libfoo.dylib");
File.setFileType(FileType::TBD_V1);
- File.setArchitectures(Architecture::i386 | Architecture::x86_64);
+ File.setArchitectures(AK_i386 | AK_x86_64);
File.setPlatform(PlatformKind::macOS);
File.setCurrentVersion(PackedVersion(1, 2, 3));
File.setSwiftABIVersion(5);
File.setObjCConstraint(ObjCConstraintType::Retain_Release);
- File.addAllowableClient("clientA", Architecture::x86_64);
- File.addReexportedLibrary("/usr/lib/libfoo.dylib", Architecture::x86_64);
- File.addSymbol(SymbolKind::GlobalSymbol, "_sym1", Architecture::i386);
- File.addSymbol(SymbolKind::GlobalSymbol, "_sym2", Architecture::i386,
+ File.addAllowableClient("clientA", AK_x86_64);
+ File.addReexportedLibrary("/usr/lib/libfoo.dylib", AK_x86_64);
+ File.addSymbol(SymbolKind::GlobalSymbol, "_sym1", AK_i386);
+ File.addSymbol(SymbolKind::GlobalSymbol, "_sym2", AK_i386,
SymbolFlags::WeakDefined);
- File.addSymbol(SymbolKind::GlobalSymbol, "_sym3", Architecture::i386,
+ File.addSymbol(SymbolKind::GlobalSymbol, "_sym3", AK_i386,
SymbolFlags::ThreadLocalValue);
- File.addSymbol(SymbolKind::ObjectiveCClass, "Class1", Architecture::x86_64);
- File.addSymbol(SymbolKind::ObjectiveCClassEHType, "Class1",
- Architecture::x86_64);
+ File.addSymbol(SymbolKind::ObjectiveCClass, "Class1", AK_x86_64);
+ File.addSymbol(SymbolKind::ObjectiveCClassEHType, "Class1", AK_x86_64);
File.addSymbol(SymbolKind::ObjectiveCInstanceVariable, "Class1._ivar1",
- Architecture::x86_64);
+ AK_x86_64);
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
Modified: llvm/trunk/unittests/TextAPI/TextStubV2Tests.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/TextAPI/TextStubV2Tests.cpp?rev=357733&r1=357732&r2=357733&view=diff
==============================================================================
--- llvm/trunk/unittests/TextAPI/TextStubV2Tests.cpp (original)
+++ llvm/trunk/unittests/TextAPI/TextStubV2Tests.cpp Thu Apr 4 15:56:50 2019
@@ -89,8 +89,7 @@ TEST(TBDv2, ReadFile) {
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
- auto Archs = Architecture::armv7 | Architecture::armv7s |
- Architecture::armv7k | Architecture::arm64;
+ auto Archs = AK_armv7 | AK_armv7s | AK_armv7k | AK_arm64;
EXPECT_EQ(Archs, File->getArchitectures());
EXPECT_EQ(PlatformKind::iOS, File->getPlatform());
EXPECT_EQ(std::string("Test.dylib"), File->getInstallName());
@@ -157,8 +156,7 @@ TEST(TBDv2, ReadFile2) {
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
- auto Archs = Architecture::armv7 | Architecture::armv7s |
- Architecture::armv7k | Architecture::arm64;
+ auto Archs = AK_armv7 | AK_armv7s | AK_armv7k | AK_arm64;
EXPECT_EQ(Archs, File->getArchitectures());
EXPECT_EQ(PlatformKind::iOS, File->getPlatform());
EXPECT_EQ(std::string("Test.dylib"), File->getInstallName());
@@ -201,25 +199,24 @@ TEST(TBDv2, WriteFile) {
File.setPath("libfoo.dylib");
File.setInstallName("/usr/lib/libfoo.dylib");
File.setFileType(FileType::TBD_V2);
- File.setArchitectures(Architecture::i386 | Architecture::x86_64);
+ File.setArchitectures(AK_i386 | AK_x86_64);
File.setPlatform(PlatformKind::macOS);
File.setCurrentVersion(PackedVersion(1, 2, 3));
File.setTwoLevelNamespace();
File.setApplicationExtensionSafe();
File.setSwiftABIVersion(5);
File.setObjCConstraint(ObjCConstraintType::Retain_Release);
- File.addAllowableClient("clientA", Architecture::x86_64);
- File.addReexportedLibrary("/usr/lib/libfoo.dylib", Architecture::x86_64);
- File.addSymbol(SymbolKind::GlobalSymbol, "_sym1", Architecture::i386);
- File.addSymbol(SymbolKind::GlobalSymbol, "_sym2", Architecture::i386,
+ File.addAllowableClient("clientA", AK_x86_64);
+ File.addReexportedLibrary("/usr/lib/libfoo.dylib", AK_x86_64);
+ File.addSymbol(SymbolKind::GlobalSymbol, "_sym1", AK_i386);
+ File.addSymbol(SymbolKind::GlobalSymbol, "_sym2", AK_i386,
SymbolFlags::WeakDefined);
- File.addSymbol(SymbolKind::GlobalSymbol, "_sym3", Architecture::i386,
+ File.addSymbol(SymbolKind::GlobalSymbol, "_sym3", AK_i386,
SymbolFlags::ThreadLocalValue);
- File.addSymbol(SymbolKind::ObjectiveCClass, "Class1", Architecture::x86_64);
- File.addSymbol(SymbolKind::ObjectiveCClassEHType, "Class1",
- Architecture::x86_64);
+ File.addSymbol(SymbolKind::ObjectiveCClass, "Class1", AK_x86_64);
+ File.addSymbol(SymbolKind::ObjectiveCClassEHType, "Class1", AK_x86_64);
File.addSymbol(SymbolKind::ObjectiveCInstanceVariable, "Class1._ivar1",
- Architecture::x86_64);
+ AK_x86_64);
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
More information about the llvm-commits
mailing list