[PATCH] D87347: [NFC] Fix compiler warnings due to integer comparison of different signedness
Yang Fan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 02:42:28 PDT 2020
nullptr.cpp updated this revision to Diff 290886.
nullptr.cpp added a comment.
[NFC] Fix pessimizing-move warnings due to std::move in return statements
Gcc warning:
warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move]
return std::move(Err);
^
Fix by removing redundant `std::move` in return statements.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87347/new/
https://reviews.llvm.org/D87347
Files:
clang/lib/Lex/Pragma.cpp
llvm/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h
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,8 +2037,7 @@
if (Mask[i] == UndefMaskElem)
continue;
uint64_t LSBIndex = IsBigEndian ? (i + 1) * TruncRatio - 1 : i * TruncRatio;
- assert(LSBIndex <= std::numeric_limits<int32_t>::max() &&
- "Overflowed 32-bits");
+ assert(LSBIndex <= INT32_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,8 @@
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 > INT32_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
@@ -416,8 +416,7 @@
ScaledMask.clear();
for (int MaskElt : Mask) {
if (MaskElt >= 0) {
- assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <=
- std::numeric_limits<int32_t>::max() &&
+ assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <= INT32_MAX &&
"Overflowed 32-bits");
}
for (int SliceElt = 0; SliceElt != Scale; ++SliceElt)
Index: llvm/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h
===================================================================
--- llvm/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h
+++ llvm/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h
@@ -1525,20 +1525,20 @@
Args...)) {
detail::ResultTraits<typename Func::ReturnType>::consumeAbandoned(
std::move(Result));
- return std::move(Err);
+ return Err;
}
if (auto Err = this->C.send()) {
detail::ResultTraits<typename Func::ReturnType>::consumeAbandoned(
std::move(Result));
- return std::move(Err);
+ return Err;
}
while (!ReceivedResponse) {
if (auto Err = this->handleOne()) {
detail::ResultTraits<typename Func::ReturnType>::consumeAbandoned(
std::move(Result));
- return std::move(Err);
+ return Err;
}
}
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 > INT_MAX) {
PP.Diag(Tok, diag::warn_pragma_warning_expected_number);
return;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87347.290886.patch
Type: text/x-patch
Size: 3463 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200910/91588f1d/attachment.bin>
More information about the llvm-commits
mailing list