Skip to content

Use precise types in DWARF BestForm methods #126309

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

Merged
merged 2 commits into from
Feb 21, 2025
Merged

Conversation

tromey
Copy link
Contributor

@tromey tromey commented Feb 7, 2025

I noticed that DIEInteger::BestForm used a cast to char:

  if ((char)Int == SignedInt)

If 'char' happens to be unsigned, this will not behave correctly. Then I also noticed that this code assumes the size of 'short' and 'int'.

This patch changes this code to use more precise types. No functional change should be visible on ordinary hosts.

I noticed that DIEInteger::BestForm used a cast to char:

      if ((char)Int == SignedInt)

If 'char' happens to be unsigned, this will not behave correctly.
Then I also noticed that this code assumes the size of 'short' and
'int'.

This patch changes this code to use more precise types.  No functional
change should be visible on ordinary hosts.
@tromey
Copy link
Contributor Author

tromey commented Feb 19, 2025

@dwblaikie this is another DWARF-related patch that didn't get properly labelled by the bot.

@dwblaikie dwblaikie merged commit c0a6f7a into llvm:main Feb 21, 2025
8 checks passed
@tromey tromey deleted the die-cast-types branch February 21, 2025 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants