[PATCH] D87347: [NFC] Fix compiler warnings due to integer comparison of different signedness
Yang Fan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 9 00:09:30 PDT 2020
nullptr.cpp created this revision.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, sbc100.
Herald added projects: clang, LLVM.
nullptr.cpp requested review of this revision.
Herald added a subscriber: aheejin.
Fix by explicitly expressing the conversions that caused by comparison.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87347
Files:
clang/lib/Lex/Pragma.cpp
llvm/lib/Analysis/VectorUtils.cpp
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2037,7 +2037,8 @@
if (Mask[i] == UndefMaskElem)
continue;
uint64_t LSBIndex = IsBigEndian ? (i + 1) * TruncRatio - 1 : i * TruncRatio;
- assert(LSBIndex <= std::numeric_limits<int32_t>::max() &&
+ assert(LSBIndex <=
+ static_cast<uint64_t>(std::numeric_limits<int32_t>::max()) &&
"Overflowed 32-bits");
if (Mask[i] != (int)LSBIndex)
return nullptr;
Index: llvm/lib/MC/WasmObjectWriter.cpp
===================================================================
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -939,9 +939,10 @@
if (Segment.InitFlags & wasm::WASM_SEGMENT_HAS_MEMINDEX)
encodeULEB128(0, W.OS); // memory index
if ((Segment.InitFlags & wasm::WASM_SEGMENT_IS_PASSIVE) == 0) {
- W.OS << char(Segment.Offset > std::numeric_limits<int32_t>().max()
- ? wasm::WASM_OPCODE_I64_CONST
- : wasm::WASM_OPCODE_I32_CONST);
+ W.OS << char(Segment.Offset > static_cast<uint64_t>(
+ std::numeric_limits<int32_t>().max())
+ ? wasm::WASM_OPCODE_I64_CONST
+ : wasm::WASM_OPCODE_I32_CONST);
encodeSLEB128(Segment.Offset, W.OS); // offset
W.OS << char(wasm::WASM_OPCODE_END);
}
Index: llvm/lib/Analysis/VectorUtils.cpp
===================================================================
--- llvm/lib/Analysis/VectorUtils.cpp
+++ llvm/lib/Analysis/VectorUtils.cpp
@@ -417,7 +417,7 @@
for (int MaskElt : Mask) {
if (MaskElt >= 0) {
assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <=
- std::numeric_limits<int32_t>::max() &&
+ static_cast<uint64_t>(std::numeric_limits<int32_t>::max()) &&
"Overflowed 32-bits");
}
for (int SliceElt = 0; SliceElt != Scale; ++SliceElt)
Index: clang/lib/Lex/Pragma.cpp
===================================================================
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -1356,7 +1356,7 @@
while (Tok.is(tok::numeric_constant)) {
uint64_t Value;
if (!PP.parseSimpleIntegerLiteral(Tok, Value) || Value == 0 ||
- Value > std::numeric_limits<int>::max()) {
+ Value > static_cast<uint64_t>(std::numeric_limits<int>::max())) {
PP.Diag(Tok, diag::warn_pragma_warning_expected_number);
return;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87347.290648.patch
Type: text/x-patch
Size: 2715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200909/5c2dcdd5/attachment.bin>
More information about the cfe-commits
mailing list