debuginfo: Use is unsigned flag when emitting enumerators
This commit is contained in:
parent
ebd941b890
commit
30650f867b
@ -1780,6 +1780,11 @@ fn prepare_enum_metadata(
|
||||
.zip(&def.variants)
|
||||
.map(|((_, discr), v)| {
|
||||
let name = v.ident.as_str();
|
||||
let is_unsigned = match discr.ty.kind {
|
||||
ty::Int(_) => false,
|
||||
ty::Uint(_) => true,
|
||||
_ => bug!("non integer discriminant"),
|
||||
};
|
||||
unsafe {
|
||||
Some(llvm::LLVMRustDIBuilderCreateEnumerator(
|
||||
DIB(cx),
|
||||
@ -1787,7 +1792,7 @@ fn prepare_enum_metadata(
|
||||
name.len(),
|
||||
// FIXME: what if enumeration has i128 discriminant?
|
||||
discr.val as i64,
|
||||
false, // FIXME: IsUnsigned.
|
||||
is_unsigned,
|
||||
))
|
||||
}
|
||||
})
|
||||
|
27
src/test/codegen/enum-discriminant-value.rs
Normal file
27
src/test/codegen/enum-discriminant-value.rs
Normal file
@ -0,0 +1,27 @@
|
||||
// Verify that DIEnumerator uses isUnsigned flag when appropriate.
|
||||
//
|
||||
// compile-flags: -g -C no-prepopulate-passes
|
||||
|
||||
#[repr(i64)]
|
||||
pub enum I64 {
|
||||
I64Min = std::i64::MIN,
|
||||
I64Max = std::i64::MAX,
|
||||
}
|
||||
|
||||
#[repr(u64)]
|
||||
pub enum U64 {
|
||||
U64Min = std::u64::MIN,
|
||||
U64Max = std::u64::MAX,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _a = I64::I64Min;
|
||||
let _b = I64::I64Max;
|
||||
let _c = U64::U64Min;
|
||||
let _d = U64::U64Max;
|
||||
}
|
||||
|
||||
// CHECK: !DIEnumerator(name: "I64Min", value: -9223372036854775808)
|
||||
// CHECK: !DIEnumerator(name: "I64Max", value: 9223372036854775807)
|
||||
// CHECK: !DIEnumerator(name: "U64Min", value: 0, isUnsigned: true)
|
||||
// CHECK: !DIEnumerator(name: "U64Max", value: 18446744073709551615, isUnsigned: true)
|
Loading…
Reference in New Issue
Block a user