Skip to content

Commit

Permalink
Remove legacy integer methods
Browse files Browse the repository at this point in the history
  • Loading branch information
GKFX authored and emilio committed Apr 27, 2024
1 parent 12215f5 commit 2013b8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
6 changes: 3 additions & 3 deletions bindgen/clang.rs
Expand Up @@ -2356,18 +2356,18 @@ impl EvalResult {

if unsafe { clang_EvalResult_isUnsignedInt(self.x) } != 0 {
let value = unsafe { clang_EvalResult_getAsUnsigned(self.x) };
if value > i64::max_value() as c_ulonglong {
if value > i64::MAX as c_ulonglong {
return None;
}

return Some(value as i64);
}

let value = unsafe { clang_EvalResult_getAsLongLong(self.x) };
if value > i64::max_value() as c_longlong {
if value > i64::MAX as c_longlong {
return None;
}
if value < i64::min_value() as c_longlong {
if value < i64::MIN as c_longlong {
return None;
}
#[allow(clippy::unnecessary_cast)]
Expand Down
20 changes: 8 additions & 12 deletions bindgen/ir/var.rs
Expand Up @@ -129,27 +129,23 @@ fn default_macro_constant_type(ctx: &BindgenContext, value: i64) -> IntKind {
ctx.options().default_macro_constant_type ==
MacroTypeVariation::Signed
{
if value < i32::min_value() as i64 || value > i32::max_value() as i64 {
if value < i32::MIN as i64 || value > i32::MAX as i64 {
IntKind::I64
} else if !ctx.options().fit_macro_constants ||
value < i16::min_value() as i64 ||
value > i16::max_value() as i64
value < i16::MIN as i64 ||
value > i16::MAX as i64
{
IntKind::I32
} else if value < i8::min_value() as i64 ||
value > i8::max_value() as i64
{
} else if value < i8::MIN as i64 || value > i8::MAX as i64 {
IntKind::I16
} else {
IntKind::I8
}
} else if value > u32::max_value() as i64 {
} else if value > u32::MAX as i64 {
IntKind::U64
} else if !ctx.options().fit_macro_constants ||
value > u16::max_value() as i64
{
} else if !ctx.options().fit_macro_constants || value > u16::MAX as i64 {
IntKind::U32
} else if value > u8::max_value() as i64 {
} else if value > u8::MAX as i64 {
IntKind::U16
} else {
IntKind::U8
Expand Down Expand Up @@ -243,7 +239,7 @@ impl ClangSubItemParser for Var {
c as u8
}
CChar::Raw(c) => {
assert!(c <= ::std::u8::MAX as u64);
assert!(c <= u8::MAX as u64);
c as u8
}
};
Expand Down

0 comments on commit 2013b8c

Please sign in to comment.