[PATCH] Fix 1 << 31

Eitan Adler lists at eitanadler.com
Mon Dec 2 15:16:09 PST 2013


eax added you to the CC list for the revision "Fix 1 << 31".

1 << 31 is not legal in C++ prior to C++14

http://llvm-reviews.chandlerc.com/D2309

Files:
  include/llvm-c/Core.h
  include/llvm/CodeGen/MachORelocation.h
  lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Index: include/llvm-c/Core.h
===================================================================
--- include/llvm-c/Core.h
+++ include/llvm-c/Core.h
@@ -159,7 +159,7 @@
     LLVMStackAlignment = 7<<26,
     LLVMReturnsTwice = 1 << 29,
     LLVMUWTable = 1 << 30,
-    LLVMNonLazyBind = 1 << 31
+    LLVMNonLazyBind = 1U << 31
 
     /* FIXME: These attributes are currently not included in the C API as
        a temporary measure until the API/ABI impact to the C API is understood
Index: include/llvm/CodeGen/MachORelocation.h
===================================================================
--- include/llvm/CodeGen/MachORelocation.h
+++ include/llvm/CodeGen/MachORelocation.h
@@ -35,7 +35,7 @@
   public:      
     uint32_t getPackedFields() const {
       if (r_scattered)
-        return (1 << 31) | (r_pcrel << 30) | ((r_length & 3) << 28) | 
+        return (1U << 31) | (r_pcrel << 30) | ((r_length & 3) << 28) |
           ((r_type & 15) << 24) | (r_address & 0x00FFFFFF);
       else
         return (r_symbolnum << 8) | (r_pcrel << 7) | ((r_length & 3) << 5) |
Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -6380,14 +6380,14 @@
     llvm::ComputeMaskedBits(const_cast<GlobalValue*>(GV), KnownZero, KnownOne,
                             TLI->getDataLayout());
     unsigned AlignBits = KnownZero.countTrailingOnes();
-    unsigned Align = AlignBits ? 1 << std::min(31U, AlignBits) : 0;
+    unsigned Align = AlignBits ? 1U << std::min(31U, AlignBits) : 0;
     if (Align)
       return MinAlign(Align, GVOffset);
   }
 
   // If this is a direct reference to a stack slot, use information about the
   // stack slot's alignment.
-  int FrameIdx = 1 << 31;
+  int FrameIdx = 1U << 31;
   int64_t FrameOffset = 0;
   if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(Ptr)) {
     FrameIdx = FI->getIndex();
@@ -6398,7 +6398,7 @@
     FrameOffset = Ptr.getConstantOperandVal(1);
   }
 
-  if (FrameIdx != (1 << 31)) {
+  if (FrameIdx != (1U << 31)) {
     const MachineFrameInfo &MFI = *getMachineFunction().getFrameInfo();
     unsigned FIInfoAlign = MinAlign(MFI.getObjectAlignment(FrameIdx),
                                     FrameOffset);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2309.1.patch
Type: text/x-patch
Size: 2329 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131202/6307966e/attachment.bin>


More information about the llvm-commits mailing list