aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
diff options
context:
space:
mode:
authorFlightor <jianghaibo9@huawei.com>2023-08-18 16:48:30 +0800
committerZhongyunde <zhongyunde@huawei.com>2023-08-18 16:51:29 +0800
commitefa8374f6b56dff31b81eb712c157bdc4f0cf830 (patch)
tree96adb2ea05d48ef2adfed9cae93772d927053432 /llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
parent25b9696b61e53a958e217bb3d0eab66350dc187f (diff)
downloadllvm-efa8374f6b56dff31b81eb712c157bdc4f0cf830.zip
llvm-efa8374f6b56dff31b81eb712c157bdc4f0cf830.tar.gz
llvm-efa8374f6b56dff31b81eb712c157bdc4f0cf830.tar.bz2
[llvm-cov] Use uint64_t to avoid overflow in addition
Reviewed By: alanphipps Differential Revision: https://reviews.llvm.org/D157608
Diffstat (limited to 'llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp')
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
index 50e3dcc..49f2035 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -668,7 +668,9 @@ void SourceCoverageViewHTML::renderBranchView(raw_ostream &OS, BranchView &BRV,
// Calculate TruePercent and False Percent.
double TruePercent = 0.0;
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.
+ uint64_t Total = R.ExecutionCount + R.FalseExecutionCount;
if (!getOptions().ShowBranchCounts && Total != 0) {
TruePercent = ((double)(R.ExecutionCount) / (double)Total) * 100.0;