-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[formatv][FmtAlign] Use fill count of type size_t instead of uint32_t #78459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
FmtAlign::fill() accepts a uint32_t variable while the usages operate on size_t values. On some platform / compiler combinations, this ends up being a narrowing conversion. Fix this by changing the function's signature. Co-authored-by: Orest Chura <[email protected]>
@llvm/pr-subscribers-llvm-support Author: Andrei Golubev (andrey-golubev) ChangesFmtAlign::fill() accepts a uint32_t variable while the usages operate on size_t values. On some platform / compiler combinations, this ends up being a narrowing conversion. Fix this by changing the function's signature. Full diff: https://github.com/llvm/llvm-project/pull/78459.diff 1 Files Affected:
diff --git a/llvm/include/llvm/Support/FormatCommon.h b/llvm/include/llvm/Support/FormatCommon.h
index 3c119d12529aeed..24a40c325e13148 100644
--- a/llvm/include/llvm/Support/FormatCommon.h
+++ b/llvm/include/llvm/Support/FormatCommon.h
@@ -66,8 +66,8 @@ struct FmtAlign {
}
private:
- void fill(llvm::raw_ostream &S, uint32_t Count) {
- for (uint32_t I = 0; I < Count; ++I)
+ void fill(llvm::raw_ostream &S, size_t Count) {
+ for (size_t I = 0; I < Count; ++I)
S << Fill;
}
};
|
@zturner0826 @labath please take a look (you seem to be the ones who worked on this before)! |
also, I guess @inglorion could have some experience with the surroundings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
For the record, can you please post the compiler message that you see before this PR? (As well as compiler version) |
aha. this would be rather complicated since I'm not the original author (also, this patch was submitted ~1 year ago if not earlier). to the best of my knowledge, it fails on some MSVC version on x86. i can try to ping whoever brought it up in our downstream originally, maybe they still have something of the kind around. |
yeah, no luck. I found the original patch in our fork but the issues were fixed in bulk for MSVC 2019 so there's no special error for this :| from our internal chats I guess it is roughly "conversion from 'size_t' to 'uint32_t' requires a narrowing conversion". |
No worries, thanks for investigating! |
FmtAlign::fill() accepts a uint32_t variable while the usages operate on size_t values. On some platform / compiler combinations, this ends up being a narrowing conversion. Fix this by changing the function's signature.