diff options
author | Reid Kleckner <reid@kleckner.net> | 2013-09-23 23:26:57 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2013-09-23 23:26:57 +0000 |
commit | 118a0659ab8a4d0e0af343b88e5fa71a5c1eb6a6 (patch) | |
tree | 0ccf13d04a66fc600e3ecc221f91bc4ced150676 /include/llvm/MC | |
parent | 5a63474e2d4c797ca8245edae4064f17b47df3ee (diff) | |
download | external_llvm-118a0659ab8a4d0e0af343b88e5fa71a5c1eb6a6.zip external_llvm-118a0659ab8a4d0e0af343b88e5fa71a5c1eb6a6.tar.gz external_llvm-118a0659ab8a4d0e0af343b88e5fa71a5c1eb6a6.tar.bz2 |
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/MC')
-rw-r--r-- | include/llvm/MC/MCSectionMachO.h | 2 | ||||
-rw-r--r-- | include/llvm/MC/MachineLocation.h | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/include/llvm/MC/MCSectionMachO.h b/include/llvm/MC/MCSectionMachO.h index b68bd85..d7e88ea 100644 --- a/include/llvm/MC/MCSectionMachO.h +++ b/include/llvm/MC/MCSectionMachO.h @@ -41,7 +41,7 @@ public: /// These are the section type and attributes fields. A MachO section can /// have only one Type, but can have any of the attributes specified. - enum { + enum LLVM_ENUM_INT_TYPE(uint32_t) { // TypeAndAttributes bitmasks. SECTION_TYPE = 0x000000FFU, SECTION_ATTRIBUTES = 0xFFFFFF00U, diff --git a/include/llvm/MC/MachineLocation.h b/include/llvm/MC/MachineLocation.h index 7d9abc3..b3fbee7 100644 --- a/include/llvm/MC/MachineLocation.h +++ b/include/llvm/MC/MachineLocation.h @@ -16,6 +16,9 @@ #ifndef LLVM_MC_MACHINELOCATION_H #define LLVM_MC_MACHINELOCATION_H +#include "llvm/Support/Compiler.h" +#include "llvm/Support/DataTypes.h" + namespace llvm { class MCSymbol; @@ -25,7 +28,7 @@ private: unsigned Register; // gcc/gdb register number. int Offset; // Displacement if not register. public: - enum { + enum LLVM_ENUM_INT_TYPE(uint32_t) { // The target register number for an abstract frame pointer. The value is // an arbitrary value that doesn't collide with any real target register. VirtualFP = ~0U |