This is an archive of the discontinued LLVM Phabricator instance.

[clang][NFC] Use a more accurate size type in the new operation, prevent issues when PointerWidth and the SizeType width are not same.
ClosedPublic

Authored by CaprYang on Jun 5 2023, 6:48 AM.

Diff Detail

Event Timeline

CaprYang created this revision.Jun 5 2023, 6:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 6:48 AM
CaprYang requested review of this revision.Jun 5 2023, 6:48 AM
shafik added reviewers: Restricted Project, erichkeane.Jun 5 2023, 8:11 AM
shafik added a subscriber: shafik.

Adding reviewers for more visibility.

Can you add a test case and a more detailed description of the issue ? Thanks!

Can you add a test case and a more detailed description of the issue ? Thanks!

here: https://github.com/llvm/llvm-project/issues/63116
Sorry. I don't know how to building a backend where PointerWidth and SizeTy width are not the same. so I can't add the test... can you tell me how to do it?

@aaron.ballman you have an opinion on that?

Presumably this is with a custom downstream 'target' here? I don't see how we'd do that either. However, I think I've seen basically this same patch up for review about a month and a half ago that I think we did a few round of reviews on? Or am I misremembering this?

This needs to be submitted for review with 'context' as well (-U999999 when generating the patch).

I think this ends up being a 'fine' change, I don't have a problem with it, and it seems more 'accurate' to make it the size type. So 1 nit, but else I think this is going to be fine.

clang/lib/Sema/SemaExprCXX.cpp
2646

Since you're capturing the size type above in SizeTy, just use it here too.

@aaron.ballman you have an opinion on that?

I'm not usually in favor of changes without test coverage, but this is effectively an NFC change as far as Clang is concerned so I'm okay with the changes. That said, the patch title seems wrong (there's no crash being fixed by this within Clang, otherwise we could test the changes), and a summary should be added justifying what's changing and why. Erich's nit should be addressed as well.

CaprYang updated this revision to Diff 540780.Jul 16 2023, 4:01 AM
CaprYang updated this revision to Diff 540782.Jul 16 2023, 4:09 AM

Presumably this is with a custom downstream 'target' here? I don't see how we'd do that either. However, I think I've seen basically this same patch up for review about a month and a half ago that I think we did a few round of reviews on? Or am I misremembering this?

This needs to be submitted for review with 'context' as well (-U999999 when generating the patch).

I think this ends up being a 'fine' change, I don't have a problem with it, and it seems more 'accurate' to make it the size type. So 1 nit, but else I think this is going to be fine.

It has been updated with diff -U999999, thanks

clang/lib/Sema/SemaExprCXX.cpp
2646

Yes, corrected it, thanks

CaprYang retitled this revision from [clang] Fix crach in the new operation, when the PointerWidth and the SizeType width are not same to [clang][NFC] Use a more accurate size type in the new operation, prevent issues when PointerWidth and the SizeType width are not same..Jul 16 2023, 4:22 AM

@aaron.ballman you have an opinion on that?

I'm not usually in favor of changes without test coverage, but this is effectively an NFC change as far as Clang is concerned so I'm okay with the changes. That said, the patch title seems wrong (there's no crash being fixed by this within Clang, otherwise we could test the changes), and a summary should be added justifying what's changing and why. Erich's nit should be addressed as well.

You're right, I have changed the title and marked NFC. Do you think this is okay?

aaron.ballman accepted this revision.Jul 17 2023, 10:52 AM

LGTM! Do you need someone to commit this on your behalf? If so, what name and email address would you like used for patch attribution?

This revision is now accepted and ready to land.Jul 17 2023, 10:52 AM

LGTM! Do you need someone to commit this on your behalf? If so, what name and email address would you like used for patch attribution?

Yes, please commit this for me, thx!
author: CaprYang <capryang@gmail.com>

Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2023, 11:55 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript