This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Avoid overflow when dumping unsigned integer values
Needs ReviewPublic

Authored by ealcdan on Aug 14 2023, 6:58 AM.

Details

Reviewers
njames93
Summary

Some options take the maximum unsigned integer value as default, but
they are being dumped to a string as integers. This makes -dump-config
write invalid '-1' values for these options. This change fixes this
issue by using utostr if the option is unsigned.

Change-Id: I22d481047330a89984d6eb27bb02f85c71d42bdb

Fixes: #60217

Diff Detail

Event Timeline

ealcdan created this revision.Aug 14 2023, 6:58 AM
ealcdan requested review of this revision.Aug 14 2023, 6:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2023, 6:58 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ealcdan changed the visibility from "Public (No Login Required)" to "No One".Aug 14 2023, 6:59 AM
ealcdan changed the edit policy from "All Users" to "No One".
ealcdan changed the visibility from "No One" to "Public (No Login Required)".Aug 14 2023, 7:03 AM
ealcdan changed the edit policy from "No One" to "All Users".

This wont fix issue, simply because problem happen during reading -1, not during dumping, and per documentation -1 was a valid value. Same issue happen in other checks that use -1. Most probably best way would be to change those variables into std::int64_t, in C++ creating any structure of size above max int will fail with error anyway, so using signed i64 should be sufficient, and would also accept -1.

I agree that this change is an improvement that is welcome, but that's not a fix for a #60217.

Thanks for the review. How should I procceed? Should I remove the "Fixes:" entry from the commit message?