File tree Expand file tree Collapse file tree 5 files changed +34
-7
lines changed Expand file tree Collapse file tree 5 files changed +34
-7
lines changed Original file line number Diff line number Diff line change
1
+ // bindgen-flags: --allowlist-var "val[0-9]+"
2
+
3
+ typedef __UINT32_TYPE__ uint32_t ;
4
+ typedef __UINT64_TYPE__ uint64_t ;
5
+
6
+ static const uint32_t val1 = 0x7fffffff ;
7
+ static const uint32_t val2 = 0x80000000 ;
8
+ static const uint32_t val3 = 0xffffffff ;
9
+ static const uint64_t val4 = 0x7fffffffffffffff ;
10
+ static const uint64_t val5 = 0x8000000000000000 ;
11
+ static const uint64_t val6 = 0xffffffffffffffff ;
12
+
13
+ static const uint32_t val7 = (0x7fffffff );
14
+ static const uint32_t val8 = (0x80000000 );
15
+ static const uint32_t val9 = (0xffffffff );
16
+ static const uint64_t val10 = (0x7fffffffffffffff );
17
+ static const uint64_t val11 = (0x8000000000000000 );
18
+ static const uint64_t val12 = (0xffffffffffffffff );
Original file line number Diff line number Diff line change @@ -2351,10 +2351,11 @@ impl EvalResult {
2351
2351
2352
2352
if unsafe { clang_EvalResult_isUnsignedInt ( self . x ) } != 0 {
2353
2353
let value = unsafe { clang_EvalResult_getAsUnsigned ( self . x ) } ;
2354
- if value > i64 :: MAX as c_ulonglong {
2354
+ if value > u64 :: MAX as c_ulonglong {
2355
2355
return None ;
2356
2356
}
2357
2357
2358
+ // Do a wrapping cast to i64. This will be losslessly cast back to u64 later.
2358
2359
return Some ( value as i64 ) ;
2359
2360
}
2360
2361
Original file line number Diff line number Diff line change @@ -120,9 +120,4 @@ impl IntKind {
120
120
_ => return None ,
121
121
} )
122
122
}
123
-
124
- /// Whether this type's signedness matches the value.
125
- pub ( crate ) fn signedness_matches ( & self , val : i64 ) -> bool {
126
- val >= 0 || self . is_signed ( )
127
- }
128
123
}
Original file line number Diff line number Diff line change @@ -341,7 +341,7 @@ impl ClangSubItemParser for Var {
341
341
} ;
342
342
343
343
let mut val = cursor. evaluate ( ) . and_then ( |v| v. as_int ( ) ) ;
344
- if val. is_none ( ) || !kind . signedness_matches ( val . unwrap ( ) ) {
344
+ if val. is_none ( ) {
345
345
val = get_integer_literal_from_cursor ( & cursor) ;
346
346
}
347
347
You can’t perform that action at this time.
0 commit comments