Skip to content

Commit

Permalink
[ODS][NFC] Cast range.size() to int32_t in accumulation (llvm#85629)
Browse files Browse the repository at this point in the history
Using range.size() "as is" means we accumulate 'size_t' values into
'int32_t' variable. This may produce narrowing conversion warnings
(particularly, on MSVC). The surrounding code seems to cast <x>.size()
to 'int32_t' so following this practice seems safe enough.

Co-authored-by: Ovidiu Pintican <ovidiu.pintican@intel.com>
(cherry picked from commit bce1703)
  • Loading branch information
andrey-golubev authored and llvmbot committed Mar 26, 2024
1 parent 2498e3a commit 6b3fe35
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3058,7 +3058,7 @@ void OpEmitter::genCodeForAddingArgAndRegionForBuilder(
body << llvm::formatv(
"static_cast<int32_t>(std::accumulate({0}.begin(), {0}.end(), 0, "
"[](int32_t curSum, ::mlir::ValueRange range) {{ return curSum + "
"range.size(); }))",
"static_cast<int32_t>(range.size()); }))",
operandName);
} else {
body << "static_cast<int32_t>(" << getArgumentName(op, i) << ".size())";
Expand Down

0 comments on commit 6b3fe35

Please sign in to comment.