]> granicus.if.org Git - clang/commitdiff
Fix many -Wsign-compare and -Wtautological-constant-compare warnings.
authorZachary Turner <zturner@google.com>
Thu, 14 Dec 2017 22:07:03 +0000 (22:07 +0000)
committerZachary Turner <zturner@google.com>
Thu, 14 Dec 2017 22:07:03 +0000 (22:07 +0000)
Most of the -Wsign-compare warnings are due to the fact that
enums are signed by default in the MS ABI, while the
tautological comparison warnings trigger on x86 builds where
sizeof(size_t) is 4 bytes, so N > numeric_limits<unsigned>::max()
is always false.

Differential Revision: https://reviews.llvm.org/D41256

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320750 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp

index c61bc0d642252332c32d9ca3ea46c645afafc58e..98740e8f9aabe5e9b0e2d1c52e82cf8161f84ac7 100644 (file)
@@ -2825,7 +2825,7 @@ void CodeGenFunction::EmitCheck(
   assert(IsSanitizerScope);
   assert(Checked.size() > 0);
   assert(CheckHandler >= 0 &&
-         CheckHandler < sizeof(SanitizerHandlers) / sizeof(*SanitizerHandlers));
+         size_t(CheckHandler) < llvm::array_lengthof(SanitizerHandlers));
   const StringRef CheckName = SanitizerHandlers[CheckHandler].Name;
 
   llvm::Value *FatalCond = nullptr;