summaryrefslogtreecommitdiff
path: root/include/llvm/Support/MachO.h
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2013-09-23 23:26:57 +0000
committerReid Kleckner <reid@kleckner.net>2013-09-23 23:26:57 +0000
commit118a0659ab8a4d0e0af343b88e5fa71a5c1eb6a6 (patch)
tree0ccf13d04a66fc600e3ecc221f91bc4ced150676 /include/llvm/Support/MachO.h
parent5a63474e2d4c797ca8245edae4064f17b47df3ee (diff)
downloadllvm-118a0659ab8a4d0e0af343b88e5fa71a5c1eb6a6.tar.gz
llvm-118a0659ab8a4d0e0af343b88e5fa71a5c1eb6a6.tar.bz2
llvm-118a0659ab8a4d0e0af343b88e5fa71a5c1eb6a6.tar.xz
Explicitly request unsigned enum types when desired
The underlying type of all plain enums in MSVC is 'int', even if the enumerator contains large 32-bit unsigned values or values greater than UINT_MAX. The only way to get a large or unsigned enum type is to request it explicitly with the C++11 strong enum types feature. However, since LLVM isn't C++11 yet, I had to add a conditional LLVM_ENUM_INT_TYPE to Compiler.h to control its usage. The motivating true positive for this change is compiling PointerIntPair with MSVC for win64. The PointerIntMask value is supposed to be pointer sized value of all ones with some low zeros. Instead, it's truncated to 32-bits! We are only saved later because it is sign extended back in the AND with int64_t, and we happen to want all ones. This silences lots of -Wmicrosoft warnings during a clang self-host targeting Windows. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191241 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/MachO.h')
-rw-r--r--include/llvm/Support/MachO.h25
1 files changed, 13 insertions, 12 deletions
diff --git a/include/llvm/Support/MachO.h b/include/llvm/Support/MachO.h
index 59998ada02..b2ac6b3b5b 100644
--- a/include/llvm/Support/MachO.h
+++ b/include/llvm/Support/MachO.h
@@ -14,13 +14,14 @@
#ifndef LLVM_SUPPORT_MACHO_H
#define LLVM_SUPPORT_MACHO_H
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/Host.h"
namespace llvm {
namespace MachO {
// Enums from <mach-o/loader.h>
- enum {
+ enum LLVM_ENUM_INT_TYPE(uint32_t) {
// Constants for the "magic" field in llvm::MachO::mach_header and
// llvm::MachO::mach_header_64
MH_MAGIC = 0xFEEDFACEu,
@@ -75,12 +76,12 @@ namespace llvm {
MH_DEAD_STRIPPABLE_DYLIB = 0x00400000u
};
- enum {
+ enum LLVM_ENUM_INT_TYPE(uint32_t) {
// Flags for the "cmd" field in llvm::MachO::load_command
LC_REQ_DYLD = 0x80000000u
};
- enum LoadCommandType {
+ enum LoadCommandType LLVM_ENUM_INT_TYPE(uint32_t) {
// Constants for the "cmd" field in llvm::MachO::load_command
LC_SEGMENT = 0x00000001u,
LC_SYMTAB = 0x00000002u,
@@ -130,7 +131,7 @@ namespace llvm {
LC_LINKER_OPTIONS = 0x0000002Du
};
- enum {
+ enum LLVM_ENUM_INT_TYPE(uint32_t) {
// Constant bits for the "flags" field in llvm::MachO::segment_command
SG_HIGHVM = 0x1u,
SG_FVMLIB = 0x2u,
@@ -173,7 +174,7 @@ namespace llvm {
S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 0x15u
};
- enum {
+ enum LLVM_ENUM_INT_TYPE(uint32_t) {
// Constant masks for the "flags[31:24]" field in llvm::MachO::section and
// llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_USR)
S_ATTR_PURE_INSTRUCTIONS = 0x80000000u,
@@ -235,9 +236,9 @@ namespace llvm {
};
enum BindSpecialDylib {
- BIND_SPECIAL_DYLIB_SELF = 0u,
- BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE = -1u,
- BIND_SPECIAL_DYLIB_FLAT_LOOKUP = -2u
+ BIND_SPECIAL_DYLIB_SELF = 0,
+ BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE = -1,
+ BIND_SPECIAL_DYLIB_FLAT_LOOKUP = -2
};
enum {
@@ -347,7 +348,7 @@ namespace llvm {
N_LENG = 0xFEu
};
- enum {
+ enum LLVM_ENUM_INT_TYPE(uint32_t) {
// Constant values for the r_symbolnum field in an
// llvm::MachO::relocation_info structure when r_extern is 0.
R_ABS = 0,
@@ -892,7 +893,7 @@ namespace llvm {
}
// Enums from <mach/machine.h>
- enum {
+ enum LLVM_ENUM_INT_TYPE(uint32_t) {
// Capability bits used in the definition of cpu_type.
CPU_ARCH_MASK = 0xff000000, // Mask for architecture bits
CPU_ARCH_ABI64 = 0x01000000 // 64 bit ABI
@@ -912,13 +913,13 @@ namespace llvm {
CPU_TYPE_POWERPC64 = CPU_TYPE_POWERPC | CPU_ARCH_ABI64
};
- enum {
+ enum LLVM_ENUM_INT_TYPE(uint32_t) {
// Capability bits used in the definition of cpusubtype.
CPU_SUB_TYPE_MASK = 0xff000000, // Mask for architecture bits
CPU_SUB_TYPE_LIB64 = 0x80000000, // 64 bit libraries
// Special CPU subtype constants.
- CPU_SUBTYPE_MULTIPLE = -1
+ CPU_SUBTYPE_MULTIPLE = ~0u
};
// Constants for the cpusubtype field.