Fixed compile warnings.

Fixed whitespace "errors".
This commit is contained in:
Vadim Chugunov 2013-06-11 12:41:09 -07:00
parent 00bb15bf72
commit 62e86e044d
3 changed files with 96 additions and 95 deletions

View File

@ -966,10 +966,10 @@ pub unsafe fn LLVMInsertBasicBlockInContext(C: ContextRef,
-> BasicBlockRef;
#[fast_ffi]
pub unsafe fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
#[fast_ffi]
pub unsafe fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef, MoveAfter: BasicBlockRef);
#[fast_ffi]
pub unsafe fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef, MoveBefore: BasicBlockRef);
@ -2072,13 +2072,13 @@ pub unsafe fn LLVMDIBuilderInsertDeclareAtEnd(
Val: ValueRef,
VarInfo: DIVariable,
InsertAtEnd: BasicBlockRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMDIBuilderInsertDeclareBefore(
Builder: DIBuilderRef,
Val: ValueRef,
VarInfo: DIVariable,
InsertBefore: ValueRef) -> ValueRef;
InsertBefore: ValueRef) -> ValueRef;
}
}

View File

@ -1907,7 +1907,7 @@ pub fn trans_closure(ccx: @mut CrateContext,
finish(bcx);
cleanup_and_Br(bcx, bcx_top, fcx.llreturn);
unsafe { llvm::LLVMMoveBasicBlockAfter(fcx.llreturn, bcx.llbb); }
// Insert the mandatory first few basic blocks before lltop.

View File

@ -25,12 +25,10 @@
use core::libc;
use core::libc::c_uint;
use core::ptr;
use core::str;
use core::str::as_c_str;
use core::sys;
use core::vec;
use syntax::codemap::span;
use syntax::parse::token::ident_interner;
use syntax::{ast, codemap, ast_util, ast_map};
static LLVMDebugVersion: int = (12 << 16);
@ -98,8 +96,8 @@ fn dbg_cx(cx: &CrateContext) -> DebugContext
}
fn create_DIArray(builder: DIBuilderRef, arr: &[DIDescriptor]) -> DIArray {
return unsafe {
llvm::LLVMDIBuilderGetOrCreateArray(builder, vec::raw::to_ptr(arr), arr.len() as u32)
return unsafe {
llvm::LLVMDIBuilderGetOrCreateArray(builder, vec::raw::to_ptr(arr), arr.len() as u32)
};
}
@ -108,7 +106,7 @@ pub fn finalize(cx: @CrateContext) {
debug!("finalize");
create_compile_unit(cx);
let dcx = dbg_cx(cx);
unsafe {
unsafe {
llvm::LLVMDIBuilderFinalize(dcx.builder);
llvm::LLVMDIBuilderDispose(dcx.builder);
};
@ -118,14 +116,14 @@ fn create_compile_unit(cx: @CrateContext) {
let crate_name: &str = dbg_cx(cx).crate_file;
let work_dir = cx.sess.working_dir.to_str();
let producer = fmt!("rustc version %s", env!("CFG_VERSION"));
do as_c_str(crate_name) |crate_name| {
do as_c_str(work_dir) |work_dir| {
do as_c_str(producer) |producer| {
do as_c_str("") |flags| {
do as_c_str("") |split_name| { unsafe {
llvm::LLVMDIBuilderCreateCompileUnit(dbg_cx(cx).builder,
DW_LANG_RUST as c_uint, crate_name, work_dir, producer,
DW_LANG_RUST as c_uint, crate_name, work_dir, producer,
cx.sess.opts.optimize != session::No,
flags, 0, split_name);
}}}}}};
@ -133,28 +131,28 @@ fn create_compile_unit(cx: @CrateContext) {
fn create_file(cx: @CrateContext, full_path: &str) -> DIFile {
let dcx = dbg_cx(cx);
match dcx.created_files.find_equiv(&full_path) {
Some(file_md) => return *file_md,
None => ()
}
debug!("create_file: %s", full_path);
let work_dir = cx.sess.working_dir.to_str();
let file_name =
let file_name =
if full_path.starts_with(work_dir) {
full_path.slice(work_dir.len() + 1u, full_path.len())
} else {
full_path
};
let file_md =
let file_md =
do as_c_str(file_name) |file_name| {
do as_c_str(work_dir) |work_dir| { unsafe {
llvm::LLVMDIBuilderCreateFile(dcx.builder, file_name, work_dir)
}}};
dcx.created_files.insert(full_path.to_owned(), file_md);
return file_md;
}
@ -166,8 +164,8 @@ fn span_start(cx: @CrateContext, span: span) -> codemap::Loc {
fn create_block(bcx: block) -> DILexicalBlock {
let mut bcx = bcx;
let cx = bcx.ccx();
let mut dcx = dbg_cx(cx);
let dcx = dbg_cx(cx);
while bcx.node_info.is_none() {
match bcx.parent {
Some(b) => bcx = b,
@ -176,14 +174,14 @@ fn create_block(bcx: block) -> DILexicalBlock {
}
let span = bcx.node_info.get().span;
let id = bcx.node_info.get().id;
match dcx.created_blocks.find(&id) {
Some(block) => return *block,
None => ()
}
debug!("create_block: %s", bcx.sess().codemap.span_to_str(span));
let parent = match bcx.parent {
None => create_function(bcx.fcx),
Some(b) => create_block(b)
@ -191,16 +189,16 @@ fn create_block(bcx: block) -> DILexicalBlock {
let cx = bcx.ccx();
let loc = span_start(cx, span);
let file_md = create_file(cx, loc.file.name);
let block_md = unsafe {
let block_md = unsafe {
llvm::LLVMDIBuilderCreateLexicalBlock(
dcx.builder,
parent, file_md,
loc.line as c_uint, loc.col.to_uint() as c_uint)
dcx.builder,
parent, file_md,
loc.line as c_uint, loc.col.to_uint() as c_uint)
};
dcx.created_blocks.insert(id, block_md);
return block_md;
}
@ -211,14 +209,14 @@ fn size_and_align_of(cx: @CrateContext, t: ty::t) -> (uint, uint) {
}
fn create_basic_type(cx: @CrateContext, t: ty::t, span: span) -> DIType{
let mut dcx = dbg_cx(cx);
let dcx = dbg_cx(cx);
let ty_id = ty::type_id(t);
match dcx.created_types.find(&ty_id) {
Some(ty_md) => return *ty_md,
None => ()
}
debug!("create_basic_type: %?", ty::get(t));
debug!("create_basic_type: %?", ty::get(t));
let (name, encoding) = match ty::get(t).sty {
ty::ty_nil | ty::ty_bot => (~"uint", DW_ATE_unsigned),
@ -249,10 +247,10 @@ fn create_basic_type(cx: @CrateContext, t: ty::t, span: span) -> DIType{
let (size, align) = size_and_align_of(cx, t);
let ty_md = do as_c_str(name) |name| { unsafe {
llvm::LLVMDIBuilderCreateBasicType(
dcx.builder, name,
dcx.builder, name,
size * 8 as u64, align * 8 as u64, encoding as c_uint)
}};
dcx.created_types.insert(ty_id, ty_md);
return ty_md;
}
@ -261,7 +259,7 @@ fn create_pointer_type(cx: @CrateContext, t: ty::t, span: span, pointee: DIType)
let (size, align) = size_and_align_of(cx, t);
let name = ty_to_str(cx.tcx, t);
let ptr_md = do as_c_str(name) |name| { unsafe {
llvm::LLVMDIBuilderCreatePointerType(dbg_cx(cx).builder,
llvm::LLVMDIBuilderCreatePointerType(dbg_cx(cx).builder,
pointee, size * 8 as u64, align * 8 as u64, name)
}};
return ptr_md;
@ -290,27 +288,27 @@ fn create(cx: @CrateContext, file: DIFile, name: ~str, line: uint) -> ~StructCon
};
return scx;
}
fn add_member(&mut self, name: &str, line: uint, size: uint, align: uint, ty: DIType) {
let mem_t = do as_c_str(name) |name| { unsafe {
llvm::LLVMDIBuilderCreateMemberType(dbg_cx(self.cx).builder,
ptr::null(), name, self.file, line as c_uint,
size * 8 as u64, align * 8 as u64, self.total_size as u64,
llvm::LLVMDIBuilderCreateMemberType(dbg_cx(self.cx).builder,
ptr::null(), name, self.file, line as c_uint,
size * 8 as u64, align * 8 as u64, self.total_size as u64,
0, ty)
}};
// XXX What about member alignment???
self.members.push(mem_t);
self.total_size += size * 8;
}
fn finalize(&self) -> DICompositeType {
let dcx = dbg_cx(self.cx);
let members_md = create_DIArray(dcx.builder, self.members);
let struct_md =
let struct_md =
do as_c_str(self.name) |name| { unsafe {
llvm::LLVMDIBuilderCreateStructType(
dcx.builder, ptr::null(), name,
dcx.builder, ptr::null(), name,
self.file, self.line as c_uint,
self.total_size as u64, self.align as u64, 0, ptr::null(),
members_md, 0, ptr::null())
@ -322,7 +320,7 @@ fn finalize(&self) -> DICompositeType {
fn create_struct(cx: @CrateContext, t: ty::t, fields: ~[ty::field], span: span) -> DICompositeType {
let loc = span_start(cx, span);
let file_md = create_file(cx, loc.file.name);
let mut scx = StructContext::create(cx, file_md, ty_to_str(cx.tcx, t), loc.line);
for fields.each |field| {
let field_t = field.mt.ty;
@ -339,7 +337,7 @@ fn voidptr(cx: @CrateContext) -> (DIDerivedType, uint, uint) {
let size = sys::size_of::<ValueRef>();
let align = sys::min_align_of::<ValueRef>();
let vp = do as_c_str("*void") |name| { unsafe {
llvm::LLVMDIBuilderCreatePointerType(dbg_cx(cx).builder, ptr::null(),
llvm::LLVMDIBuilderCreatePointerType(dbg_cx(cx).builder, ptr::null(),
size*8 as u64, align*8 as u64, name)
}};
return (vp, size, align);
@ -352,7 +350,7 @@ fn create_tuple(cx: @CrateContext, t: ty::t, elements: &[ty::t], span: span) ->
let name = (cx.sess.str_of((dcx.names)("tuple"))).to_owned();
let mut scx = StructContext::create(cx, file_md, name, loc.line);
for elements.each |element| {
let ty_md = create_ty(cx, *element, span);
let (size, align) = size_and_align_of(cx, *element);
@ -368,7 +366,7 @@ fn create_boxed_type(cx: @CrateContext, contents: ty::t,
let int_t = ty::mk_int();
let refcount_type = create_basic_type(cx, int_t, span);
let name = ty_to_str(cx.tcx, contents);
let mut scx = StructContext::create(cx, file_md, fmt!("box<%s>", name), 0);
scx.add_member("refcnt", 0, sys::size_of::<uint>(),
sys::min_align_of::<uint>(), refcount_type);
@ -391,13 +389,13 @@ fn create_fixed_vec(cx: @CrateContext, vec_t: ty::t, elem_t: ty::t,
let file_md = create_file(cx, loc.file.name);
let (size, align) = size_and_align_of(cx, elem_t);
let subrange = unsafe {
let subrange = unsafe {
llvm::LLVMDIBuilderGetOrCreateSubrange(dcx.builder, 0_i64, (len-1) as i64) };
let subscripts = create_DIArray(dcx.builder, [subrange]);
return unsafe {
llvm::LLVMDIBuilderCreateVectorType(dcx.builder,
size * len as u64, align as u64, elem_ty_md, subscripts)
return unsafe {
llvm::LLVMDIBuilderCreateVectorType(dcx.builder,
size * len as u64, align as u64, elem_ty_md, subscripts)
};
}
@ -407,9 +405,9 @@ fn create_boxed_vec(cx: @CrateContext, vec_t: ty::t, elem_t: ty::t,
let loc = span_start(cx, vec_ty_span);
let file_md = create_file(cx, loc.file.name);
let elem_ty_md = create_ty(cx, elem_t, vec_ty_span);
let mut vec_scx = StructContext::create(cx, file_md, ty_to_str(cx.tcx, vec_t), 0);
let size_t_type = create_basic_type(cx, ty::mk_uint(), vec_ty_span);
vec_scx.add_member("fill", 0, sys::size_of::<libc::size_t>(),
sys::min_align_of::<libc::size_t>(), size_t_type);
@ -418,9 +416,9 @@ fn create_boxed_vec(cx: @CrateContext, vec_t: ty::t, elem_t: ty::t,
let subrange = unsafe { llvm::LLVMDIBuilderGetOrCreateSubrange(dcx.builder, 0_i64, 0_i64) };
let (arr_size, arr_align) = size_and_align_of(cx, elem_t);
let name = fmt!("[%s]", ty_to_str(cx.tcx, elem_t));
let subscripts = create_DIArray(dcx.builder, [subrange]);
let data_ptr = unsafe { llvm::LLVMDIBuilderCreateVectorType(dcx.builder,
let data_ptr = unsafe { llvm::LLVMDIBuilderCreateVectorType(dcx.builder,
arr_size as u64, arr_align as u64, elem_ty_md, subscripts) };
vec_scx.add_member("data", 0, 0, // clang says the size should be 0
sys::min_align_of::<u8>(), data_ptr);
@ -448,7 +446,7 @@ fn create_vec_slice(cx: @CrateContext, vec_t: ty::t, elem_t: ty::t, span: span)
let elem_ty_md = create_ty(cx, elem_t, span);
let uint_type = create_basic_type(cx, ty::mk_uint(), span);
let elem_ptr = create_pointer_type(cx, elem_t, span, elem_ty_md);
let mut scx = StructContext::create(cx, file_md, ty_to_str(cx.tcx, vec_t), 0);
let (_, ptr_size, ptr_align) = voidptr(cx);
scx.add_member("vec", 0, ptr_size, ptr_align, elem_ptr);
@ -467,15 +465,15 @@ fn create_fn_ty(cx: @CrateContext, fn_ty: ty::t, inputs: ~[ty::t], output: ty::t
let output_ptr_md = create_pointer_type(cx, output, span, output_md);
let inputs_vals = do inputs.map |arg| { create_ty(cx, *arg, span) };
let members = ~[output_ptr_md, vp] + inputs_vals;
return unsafe {
llvm::LLVMDIBuilderCreateSubroutineType(dcx.builder, file_md,
create_DIArray(dcx.builder, members))
return unsafe {
llvm::LLVMDIBuilderCreateSubroutineType(dcx.builder, file_md,
create_DIArray(dcx.builder, members))
};
}
fn create_ty(cx: @CrateContext, t: ty::t, span: span) -> DIType {
let mut dcx = dbg_cx(cx);
let dcx = dbg_cx(cx);
let ty_id = ty::type_id(t);
match dcx.created_types.find(&ty_id) {
Some(ty_md) => return *ty_md,
@ -552,7 +550,7 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span) -> DIType {
},
_ => cx.sess.bug(~"debuginfo: unexpected type in create_ty")
};
dcx.created_types.insert(ty_id, ty_md);
return ty_md;
}
@ -568,7 +566,7 @@ pub fn create_local_var(bcx: block, local: @ast::local) -> DIVariable {
};
let name: &str = cx.sess.str_of(ident);
debug!("create_local_var: %s", name);
let loc = span_start(cx, local.span);
let ty = node_id_type(bcx, local.node.id);
let tymd = create_ty(cx, ty, local.node.ty.span);
@ -577,14 +575,14 @@ pub fn create_local_var(bcx: block, local: @ast::local) -> DIVariable {
None => create_function(bcx.fcx),
Some(_) => create_block(bcx)
};
let var_md = do as_c_str(name) |name| { unsafe {
llvm::LLVMDIBuilderCreateLocalVariable(
dcx.builder, AutoVariableTag as u32,
context, name, filemd,
context, name, filemd,
loc.line as c_uint, tymd, false, 0, 0)
}};
// FIXME(#6814) Should use `pat_util::pat_bindings` for pats like (a, b) etc
let llptr = match bcx.fcx.lllocals.find_copy(&local.node.pat.id) {
Some(v) => v,
@ -594,30 +592,33 @@ pub fn create_local_var(bcx: block, local: @ast::local) -> DIVariable {
fmt!("No entry in lllocals table for %?", local.node.id));
}
};
set_debug_location(bcx, loc.line, loc.col.to_uint());
unsafe {
let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd(dcx.builder, llptr, var_md, bcx.llbb);
llvm::LLVMSetInstDebugLocation(trans::build::B(bcx), instr);
}
return var_md;
}
pub fn create_arg(bcx: block, arg: ast::arg, span: span) -> Option<DIVariable> {
debug!("create_arg");
let fcx = bcx.fcx, cx = *fcx.ccx;
if true {
// FIXME(5848) create_arg disabled for now because "node_id_type(bcx, arg.id)" below blows
// up: "error: internal compiler error: node_id_to_type: no type for node `arg (id=10)`"
return None;
}
let fcx = bcx.fcx;
let cx = *fcx.ccx;
let dcx = dbg_cx(cx);
let loc = span_start(cx, span);
if "<intrinsic>" == loc.file.name {
return None;
}
// FIXME: Disabled for now because "node_id_type(bcx, arg.id)" below blows up:
// "error: internal compiler error: node_id_to_type: no type for node `arg (id=10)`"
// (same as https://github.com/mozilla/rust/issues/5848)
return None;
let ty = node_id_type(bcx, arg.id);
let tymd = create_ty(cx, ty, arg.ty.span);
let filemd = create_file(cx, loc.file.name);
@ -629,12 +630,12 @@ pub fn create_arg(bcx: block, arg: ast::arg, span: span) -> Option<DIVariable> {
let ident = path.idents.last();
let name: &str = cx.sess.str_of(*ident);
let mdnode = do as_c_str(name) |name| { unsafe {
llvm::LLVMDIBuilderCreateLocalVariable(dcx.builder,
ArgVariableTag as u32, context, name,
llvm::LLVMDIBuilderCreateLocalVariable(dcx.builder,
ArgVariableTag as u32, context, name,
filemd, loc.line as c_uint, tymd, false, 0, 0)
// FIXME need to pass a real argument number
}};
let llptr = fcx.llargs.get_copy(&arg.id);
unsafe {
llvm::LLVMDIBuilderInsertDeclareAtEnd(dcx.builder, llptr, mdnode, bcx.llbb);
@ -652,7 +653,7 @@ fn set_debug_location(bcx: block, line: uint, col: uint) {
let elems = ~[C_i32(line as i32), C_i32(col as i32), blockmd, ptr::null()];
unsafe {
let dbg_loc = llvm::LLVMMDNode(vec::raw::to_ptr(elems), elems.len() as libc::c_uint);
llvm::LLVMSetCurrentDebugLocation(trans::build::B(bcx), dbg_loc);
llvm::LLVMSetCurrentDebugLocation(trans::build::B(bcx), dbg_loc);
}
}
@ -660,13 +661,13 @@ pub fn update_source_pos(bcx: block, span: span) {
if !bcx.sess().opts.debuginfo || (*span.lo == 0 && *span.hi == 0) {
return;
}
debug!("update_source_pos: %s", bcx.sess().codemap.span_to_str(span));
let cx = bcx.ccx();
let loc = span_start(cx, span);
let mut dcx = dbg_cx(cx);
let dcx = dbg_cx(cx);
let loc = (loc.line, loc.col.to_uint());
if loc == dcx.curr_loc {
return;
@ -678,7 +679,7 @@ pub fn update_source_pos(bcx: block, span: span) {
pub fn create_function(fcx: fn_ctxt) -> DISubprogram {
let cx = *fcx.ccx;
let mut dcx = dbg_cx(cx);
let dcx = dbg_cx(cx);
let fcx = &mut *fcx;
let span = fcx.span.get();
@ -705,7 +706,7 @@ pub fn create_function(fcx: fn_ctxt) -> DISubprogram {
}
_ => fcx.ccx.sess.bug("create_function: unexpected sort of node")
};
match dcx.created_functions.find(&id) {
Some(fn_md) => return *fn_md,
None => ()
@ -725,27 +726,27 @@ pub fn create_function(fcx: fn_ctxt) -> DISubprogram {
} else {
ptr::null()
};
let fn_ty = unsafe {
llvm::LLVMDIBuilderCreateSubroutineType(dcx.builder,
file_md, create_DIArray(dcx.builder, [ret_ty_md]))
};
let fn_md =
let fn_md =
do as_c_str(cx.sess.str_of(ident)) |name| {
do as_c_str(cx.sess.str_of(ident)) |linkage| { unsafe {
llvm::LLVMDIBuilderCreateFunction(
dcx.builder,
file_md,
name, linkage,
file_md, loc.line as c_uint,
fn_ty, false, true,
loc.line as c_uint,
dcx.builder,
file_md,
name, linkage,
file_md, loc.line as c_uint,
fn_ty, false, true,
loc.line as c_uint,
FlagPrototyped as c_uint,
cx.sess.opts.optimize != session::No,
cx.sess.opts.optimize != session::No,
fcx.llfn, ptr::null(), ptr::null())
}}};
dcx.created_functions.insert(id, fn_md);
return fn_md;
}