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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions llvm/include/llvm/CodeGen/DIE.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,18 @@ class DIEInteger {
static dwarf::Form BestForm(bool IsSigned, uint64_t Int) {
if (IsSigned) {
const int64_t SignedInt = Int;
if ((char)Int == SignedInt)
if ((int8_t)Int == SignedInt)
return dwarf::DW_FORM_data1;
if ((short)Int == SignedInt)
if ((int16_t)Int == SignedInt)
return dwarf::DW_FORM_data2;
if ((int)Int == SignedInt)
if ((int32_t)Int == SignedInt)
return dwarf::DW_FORM_data4;
} else {
if ((unsigned char)Int == Int)
if ((uint8_t)Int == Int)
return dwarf::DW_FORM_data1;
if ((unsigned short)Int == Int)
if ((uint16_t)Int == Int)
return dwarf::DW_FORM_data2;
if ((unsigned int)Int == Int)
if ((uint32_t)Int == Int)
return dwarf::DW_FORM_data4;
}
return dwarf::DW_FORM_data8;
Expand Down Expand Up @@ -1025,11 +1025,11 @@ class DIELoc : public DIEValueList {
if (DwarfVersion > 3)
return dwarf::DW_FORM_exprloc;
// Pre-DWARF4 location expressions were blocks and not exprloc.
if ((unsigned char)Size == Size)
if ((uint8_t)Size == Size)
return dwarf::DW_FORM_block1;
if ((unsigned short)Size == Size)
if ((uint16_t)Size == Size)
return dwarf::DW_FORM_block2;
if ((unsigned int)Size == Size)
if ((uint32_t)Size == Size)
return dwarf::DW_FORM_block4;
return dwarf::DW_FORM_block;
}
Expand Down Expand Up @@ -1058,11 +1058,11 @@ class DIEBlock : public DIEValueList {
/// BestForm - Choose the best form for data.
///
dwarf::Form BestForm() const {
if ((unsigned char)Size == Size)
if ((uint8_t)Size == Size)
return dwarf::DW_FORM_block1;
if ((unsigned short)Size == Size)
if ((uint16_t)Size == Size)
return dwarf::DW_FORM_block2;
if ((unsigned int)Size == Size)
if ((uint32_t)Size == Size)
return dwarf::DW_FORM_block4;
return dwarf::DW_FORM_block;
}
Expand Down