Counters are stored as uint64_t in the coverage mapping, but
exporting in JSON requires signed integers. Clamp the values to the
smaller range to make the conversion safe.
Details
Details
- Reviewers
Dor1s vsk - Commits
- rG97c742e6b74e: [llvm-cov] Fix illegal cast from uint64_t to int64_t
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 40988 Build 41137: arc lint + arc unit
Event Timeline
Comment Actions
Discovered this because we were getting negative numbers in some of our coverage data when we had counter overflows.
Comment Actions
Thanks, lgtm with a comment.
llvm/tools/llvm-cov/CoverageExporterJson.cpp | ||
---|---|---|
65 | Please leave a comment explaining why the format makes clamping necessary. |
Comment Actions
Ha, nice! LGTM. Is there any test you could easily update or add to reproduce this corner case?
llvm/tools/llvm-cov/CoverageExporterJson.cpp | ||
---|---|---|
72 | nit: can return std::min(u, std::numeric_limits<int64_t>::max()) |
Comment Actions
I tried to write a loop that would execute INT64_MAX + 10 times, but that takes way too long. Not sure how to test it outside of the case where we have counter overflows.
llvm/tools/llvm-cov/CoverageExporterJson.cpp | ||
---|---|---|
72 | FYI we still needed the static_cast to make template deduction work |
Please leave a comment explaining why the format makes clamping necessary.