[PATCH] D157608: [llvm-cov] Use uint64_t to avoid overflow in addition

Alan Phipps via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 10 07:50:04 PDT 2023


alanphipps accepted this revision.
alanphipps added a comment.
This revision is now accepted and ready to land.

LGTM thanks



================
Comment at: llvm/tools/llvm-cov/SourceCoverageViewText.cpp:235
     double FalsePercent = 0.0;
-    unsigned Total = R.ExecutionCount + R.FalseExecutionCount;
+    // FIXME: It may overflow when the data is too large, but I have not
+    // encountered it in actual use, and not sure whether to use __uint128_t.
----------------
Thanks for catching this.  I believe CoverageSummaryInfo.cpp uses size_t to add the counters, but I am OK with using uint64_t for the source coverage views.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157608/new/

https://reviews.llvm.org/D157608



More information about the llvm-commits mailing list