From: Zachary Turner Date: Thu, 14 Dec 2017 22:07:03 +0000 (+0000) Subject: Fix many -Wsign-compare and -Wtautological-constant-compare warnings. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c0bbfc6da1c653acfd2c047bb1f334cef3a14ad5;p=clang Fix many -Wsign-compare and -Wtautological-constant-compare warnings. 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::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 --- diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index c61bc0d642..98740e8f9a 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -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;