From: Benjamin Kramer Date: Mon, 24 Sep 2018 17:51:15 +0000 (+0000) Subject: Fix the type of 1<<31 integer constants. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=741801da75c08ada195b05735f77c5426168d8f9;p=clang Fix the type of 1<<31 integer constants. Shifting into the sign bit is technically undefined behavior. No known compiler exploits it though. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342909 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index af7dbbc13c..c5a53960b3 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -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; diff --git a/lib/CodeGen/CGBlocks.h b/lib/CodeGen/CGBlocks.h index c802948af0..3f9fc16d9b 100644 --- a/lib/CodeGen/CGBlocks.h +++ b/lib/CodeGen/CGBlocks.h @@ -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;