debuginfo: Better support for univariant tuple-style enums.
This commit is contained in:
parent
f389bd8f2a
commit
7cf0aac6cf
2 changed files with 26 additions and 7 deletions
|
@ -606,13 +606,22 @@ fn create_enum_md(cx: &mut CrateContext,
|
||||||
return discriminant_type_md;
|
return discriminant_type_md;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let is_univariant = variants.len() == 1;
|
||||||
|
|
||||||
let variants_md = do variants.map |&vi| {
|
let variants_md = do variants.map |&vi| {
|
||||||
|
|
||||||
let raw_types : &[ty::t] = vi.args;
|
let raw_types : &[ty::t] = vi.args;
|
||||||
let arg_types = do raw_types.map |&raw_type| { ty::subst(cx.tcx, substs, raw_type) };
|
let arg_types = do raw_types.map |&raw_type| { ty::subst(cx.tcx, substs, raw_type) };
|
||||||
let arg_llvm_types = ~[discriminant_llvm_type] + do arg_types.map |&ty| { type_of::type_of(cx, ty) };
|
|
||||||
let arg_names = ~[~""] + arg_types.map(|_| ~"");
|
let mut arg_llvm_types = do arg_types.map |&ty| { type_of::type_of(cx, ty) };
|
||||||
let arg_md = ~[discriminant_type_md] + do arg_types.map |&ty| { get_or_create_type(cx, ty, span) };
|
let mut arg_names = arg_types.map(|_| ~"");
|
||||||
|
let mut arg_md = do arg_types.map |&ty| { get_or_create_type(cx, ty, span) };
|
||||||
|
|
||||||
|
if !is_univariant {
|
||||||
|
arg_llvm_types.insert(0, discriminant_llvm_type);
|
||||||
|
arg_names.insert(0, ~"");
|
||||||
|
arg_md.insert(0, discriminant_type_md);
|
||||||
|
}
|
||||||
|
|
||||||
let variant_llvm_type = Type::struct_(arg_llvm_types, false);
|
let variant_llvm_type = Type::struct_(arg_llvm_types, false);
|
||||||
let variant_type_size = machine::llsize_of_alloc(cx, variant_llvm_type);
|
let variant_type_size = machine::llsize_of_alloc(cx, variant_llvm_type);
|
||||||
|
@ -646,7 +655,7 @@ fn create_enum_md(cx: &mut CrateContext,
|
||||||
let enum_type_size = machine::llsize_of_alloc(cx, enum_llvm_type);
|
let enum_type_size = machine::llsize_of_alloc(cx, enum_llvm_type);
|
||||||
let enum_type_align = machine::llalign_of_min(cx, enum_llvm_type);
|
let enum_type_align = machine::llalign_of_min(cx, enum_llvm_type);
|
||||||
|
|
||||||
return do "".as_c_str |enum_name| { unsafe { llvm::LLVMDIBuilderCreateUnionType(
|
return do enum_name.as_c_str |enum_name| { unsafe { llvm::LLVMDIBuilderCreateUnionType(
|
||||||
DIB(cx),
|
DIB(cx),
|
||||||
file_metadata,
|
file_metadata,
|
||||||
enum_name,
|
enum_name,
|
||||||
|
|
|
@ -14,19 +14,29 @@
|
||||||
// debugger:run
|
// debugger:run
|
||||||
// debugger:finish
|
// debugger:finish
|
||||||
|
|
||||||
// debugger:print case2
|
// d ebugger:print case2
|
||||||
// check:$1 = {Case1, 0, 1}
|
// c heck:$1 = {Case1, 0, 1}
|
||||||
|
|
||||||
enum Test {
|
// debugger:print univariant
|
||||||
|
// check:$1 = {{-1}}
|
||||||
|
|
||||||
|
|
||||||
|
enum Regular {
|
||||||
Case1(i32, i64),
|
Case1(i32, i64),
|
||||||
Case2(bool, i16, i32)
|
Case2(bool, i16, i32)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum Univariant {
|
||||||
|
TheOnlyCase(i64)
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
let case1 = Case1(110, 220);
|
let case1 = Case1(110, 220);
|
||||||
let case2 = Case2(false, 2, 3);
|
let case2 = Case2(false, 2, 3);
|
||||||
|
|
||||||
|
let univariant = TheOnlyCase(-1);
|
||||||
|
|
||||||
zzz();
|
zzz();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue