Fix the type of 1<<31 integer constants.
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 24 Sep 2018 17:51:15 +0000 (17:51 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 24 Sep 2018 17:51:15 +0000 (17:51 +0000)
Shifting into the sign bit is technically undefined behavior. No known
compiler exploits it though.

llvm-svn: 342909

clang/include/clang/Basic/SourceManager.h
clang/lib/CodeGen/CGBlocks.h

index af7dbbc..c5a5396 100644 (file)
@@ -449,7 +449,7 @@ namespace SrcMgr {
     }
 
     static SLocEntry get(unsigned Offset, const FileInfo &FI) {
-      assert(!(Offset & (1 << 31)) && "Offset is too large");
+      assert(!(Offset & (1u << 31)) && "Offset is too large");
       SLocEntry E;
       E.Offset = Offset;
       E.IsExpansion = false;
@@ -458,7 +458,7 @@ namespace SrcMgr {
     }
 
     static SLocEntry get(unsigned Offset, const ExpansionInfo &Expansion) {
-      assert(!(Offset & (1 << 31)) && "Offset is too large");
+      assert(!(Offset & (1u << 31)) && "Offset is too large");
       SLocEntry E;
       E.Offset = Offset;
       E.IsExpansion = true;
index c802948..3f9fc16 100644 (file)
@@ -60,7 +60,7 @@ enum BlockLiteralFlags {
   BLOCK_IS_GLOBAL =         (1 << 28),
   BLOCK_USE_STRET =         (1 << 29),
   BLOCK_HAS_SIGNATURE  =    (1 << 30),
-  BLOCK_HAS_EXTENDED_LAYOUT = (1 << 31)
+  BLOCK_HAS_EXTENDED_LAYOUT = (1u << 31)
 };
 class BlockFlags {
   uint32_t flags;