mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
Rollup merge of #69779 - tmiasko:di-cstr, r=nagisa
librustc_codegen_llvm: Use slices in preference to 0-terminated strings Additionally whenever possible match C API provided by the LLVM.
This commit is contained in:
commit
2409e70bdb
@ -37,7 +37,6 @@ use rustc_codegen_ssa::traits::*;
|
||||
use rustc_data_structures::const_cstr;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_fs_util::path_to_c_string;
|
||||
use rustc_hir::def::CtorKind;
|
||||
@ -49,7 +48,6 @@ use rustc_target::abi::HasDataLayout;
|
||||
|
||||
use libc::{c_longlong, c_uint};
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::ffi::CString;
|
||||
use std::fmt::{self, Write};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::iter;
|
||||
@ -227,11 +225,11 @@ impl TypeMap<'ll, 'tcx> {
|
||||
/// Gets the unique type ID string for an enum variant part.
|
||||
/// Variant parts are not types and shouldn't really have their own ID,
|
||||
/// but it makes `set_members_of_composite_type()` simpler.
|
||||
fn get_unique_type_id_str_of_enum_variant_part(&mut self, enum_type_id: UniqueTypeId) -> &str {
|
||||
let variant_part_type_id =
|
||||
format!("{}_variant_part", self.get_unique_type_id_as_string(enum_type_id));
|
||||
let interner_key = self.unique_id_interner.intern(&variant_part_type_id);
|
||||
self.unique_id_interner.get(interner_key)
|
||||
fn get_unique_type_id_str_of_enum_variant_part(
|
||||
&mut self,
|
||||
enum_type_id: UniqueTypeId,
|
||||
) -> String {
|
||||
format!("{}_variant_part", self.get_unique_type_id_as_string(enum_type_id))
|
||||
}
|
||||
}
|
||||
|
||||
@ -640,9 +638,11 @@ pub fn type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>, usage_site_span: Sp
|
||||
// type is going to see *something* weird - the only
|
||||
// question is what exactly it will see.
|
||||
let (size, align) = cx.size_and_align_of(t);
|
||||
let name = "<recur_type>";
|
||||
llvm::LLVMRustDIBuilderCreateBasicType(
|
||||
DIB(cx),
|
||||
SmallCStr::new("<recur_type>").as_ptr(),
|
||||
name.as_ptr().cast(),
|
||||
name.len(),
|
||||
size.bits(),
|
||||
align.bits() as u32,
|
||||
DW_ATE_unsigned,
|
||||
@ -786,16 +786,17 @@ fn file_metadata_raw(
|
||||
let (file_name, directory) = v.key();
|
||||
debug!("file_metadata: file_name: {:?}, directory: {:?}", file_name, directory);
|
||||
|
||||
let file_name = SmallCStr::new(if let Some(file_name) = file_name {
|
||||
&file_name
|
||||
} else {
|
||||
"<unknown>"
|
||||
});
|
||||
let directory =
|
||||
SmallCStr::new(if let Some(directory) = directory { &directory } else { "" });
|
||||
let file_name = file_name.as_deref().unwrap_or("<unknown>");
|
||||
let directory = directory.as_deref().unwrap_or("");
|
||||
|
||||
let file_metadata = unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateFile(DIB(cx), file_name.as_ptr(), directory.as_ptr())
|
||||
llvm::LLVMRustDIBuilderCreateFile(
|
||||
DIB(cx),
|
||||
file_name.as_ptr().cast(),
|
||||
file_name.len(),
|
||||
directory.as_ptr().cast(),
|
||||
directory.len(),
|
||||
)
|
||||
};
|
||||
|
||||
v.insert(file_metadata);
|
||||
@ -819,11 +820,11 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
|
||||
};
|
||||
|
||||
let (size, align) = cx.size_and_align_of(t);
|
||||
let name = SmallCStr::new(name);
|
||||
let ty_metadata = unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateBasicType(
|
||||
DIB(cx),
|
||||
name.as_ptr(),
|
||||
name.as_ptr().cast(),
|
||||
name.len(),
|
||||
size.bits(),
|
||||
align.bits() as u32,
|
||||
encoding,
|
||||
@ -851,14 +852,15 @@ fn pointer_type_metadata(
|
||||
) -> &'ll DIType {
|
||||
let (pointer_size, pointer_align) = cx.size_and_align_of(pointer_type);
|
||||
let name = compute_debuginfo_type_name(cx.tcx, pointer_type, false);
|
||||
let name = SmallCStr::new(&name);
|
||||
unsafe {
|
||||
llvm::LLVMRustDIBuilderCreatePointerType(
|
||||
DIB(cx),
|
||||
pointee_type_metadata,
|
||||
pointer_size.bits(),
|
||||
pointer_align.bits() as u32,
|
||||
name.as_ptr(),
|
||||
0, // Ignore DWARF address space.
|
||||
name.as_ptr().cast(),
|
||||
name.len(),
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -889,11 +891,9 @@ pub fn compile_unit_metadata(
|
||||
let producer = format!("clang LLVM ({})", rustc_producer);
|
||||
|
||||
let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
|
||||
let name_in_debuginfo = SmallCStr::new(&name_in_debuginfo);
|
||||
let work_dir = SmallCStr::new(&tcx.sess.working_dir.0.to_string_lossy());
|
||||
let producer = CString::new(producer).unwrap();
|
||||
let work_dir = tcx.sess.working_dir.0.to_string_lossy();
|
||||
let flags = "\0";
|
||||
let split_name = "\0";
|
||||
let split_name = "";
|
||||
|
||||
// FIXME(#60020):
|
||||
//
|
||||
@ -916,19 +916,23 @@ pub fn compile_unit_metadata(
|
||||
unsafe {
|
||||
let file_metadata = llvm::LLVMRustDIBuilderCreateFile(
|
||||
debug_context.builder,
|
||||
name_in_debuginfo.as_ptr(),
|
||||
work_dir.as_ptr(),
|
||||
name_in_debuginfo.as_ptr().cast(),
|
||||
name_in_debuginfo.len(),
|
||||
work_dir.as_ptr().cast(),
|
||||
work_dir.len(),
|
||||
);
|
||||
|
||||
let unit_metadata = llvm::LLVMRustDIBuilderCreateCompileUnit(
|
||||
debug_context.builder,
|
||||
DW_LANG_RUST,
|
||||
file_metadata,
|
||||
producer.as_ptr(),
|
||||
producer.as_ptr().cast(),
|
||||
producer.len(),
|
||||
tcx.sess.opts.optimize != config::OptLevel::No,
|
||||
flags.as_ptr().cast(),
|
||||
0,
|
||||
split_name.as_ptr().cast(),
|
||||
split_name.len(),
|
||||
kind,
|
||||
);
|
||||
|
||||
@ -1021,12 +1025,12 @@ impl<'ll> MemberDescription<'ll> {
|
||||
cx: &CodegenCx<'ll, '_>,
|
||||
composite_type_metadata: &'ll DIScope,
|
||||
) -> &'ll DIType {
|
||||
let member_name = CString::new(self.name).unwrap();
|
||||
unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateVariantMemberType(
|
||||
DIB(cx),
|
||||
composite_type_metadata,
|
||||
member_name.as_ptr(),
|
||||
self.name.as_ptr().cast(),
|
||||
self.name.len(),
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
self.size.bits(),
|
||||
@ -1827,9 +1831,13 @@ fn prepare_enum_metadata(
|
||||
let discriminant_base_type_metadata =
|
||||
type_metadata(cx, discr.to_ty(cx.tcx), rustc_span::DUMMY_SP);
|
||||
|
||||
let item_name;
|
||||
let discriminant_name = match enum_type.kind {
|
||||
ty::Adt(..) => SmallCStr::new(&cx.tcx.item_name(enum_def_id).as_str()),
|
||||
ty::Generator(..) => SmallCStr::new(&enum_name),
|
||||
ty::Adt(..) => {
|
||||
item_name = cx.tcx.item_name(enum_def_id).as_str();
|
||||
&*item_name
|
||||
}
|
||||
ty::Generator(..) => enum_name.as_str(),
|
||||
_ => bug!(),
|
||||
};
|
||||
|
||||
@ -1837,7 +1845,8 @@ fn prepare_enum_metadata(
|
||||
llvm::LLVMRustDIBuilderCreateEnumerationType(
|
||||
DIB(cx),
|
||||
containing_scope,
|
||||
discriminant_name.as_ptr(),
|
||||
discriminant_name.as_ptr().cast(),
|
||||
discriminant_name.len(),
|
||||
file_metadata,
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
discriminant_size.bits(),
|
||||
@ -1872,11 +1881,6 @@ fn prepare_enum_metadata(
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let enum_name = SmallCStr::new(&enum_name);
|
||||
let unique_type_id_str = SmallCStr::new(
|
||||
debug_context(cx).type_map.borrow().get_unique_type_id_as_string(unique_type_id),
|
||||
);
|
||||
|
||||
if use_enum_fallback(cx) {
|
||||
let discriminant_type_metadata = match layout.variants {
|
||||
layout::Variants::Single { .. }
|
||||
@ -1891,20 +1895,27 @@ fn prepare_enum_metadata(
|
||||
} => Some(discriminant_type_metadata(discr.value)),
|
||||
};
|
||||
|
||||
let enum_metadata = unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateUnionType(
|
||||
DIB(cx),
|
||||
containing_scope,
|
||||
enum_name.as_ptr(),
|
||||
file_metadata,
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
layout.size.bits(),
|
||||
layout.align.abi.bits() as u32,
|
||||
DIFlags::FlagZero,
|
||||
None,
|
||||
0, // RuntimeLang
|
||||
unique_type_id_str.as_ptr(),
|
||||
)
|
||||
let enum_metadata = {
|
||||
let type_map = debug_context(cx).type_map.borrow();
|
||||
let unique_type_id_str = type_map.get_unique_type_id_as_string(unique_type_id);
|
||||
|
||||
unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateUnionType(
|
||||
DIB(cx),
|
||||
containing_scope,
|
||||
enum_name.as_ptr().cast(),
|
||||
enum_name.len(),
|
||||
file_metadata,
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
layout.size.bits(),
|
||||
layout.align.abi.bits() as u32,
|
||||
DIFlags::FlagZero,
|
||||
None,
|
||||
0, // RuntimeLang
|
||||
unique_type_id_str.as_ptr().cast(),
|
||||
unique_type_id_str.len(),
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
return create_and_register_recursive_type_forward_declaration(
|
||||
@ -1924,10 +1935,9 @@ fn prepare_enum_metadata(
|
||||
}
|
||||
|
||||
let discriminator_name = match &enum_type.kind {
|
||||
ty::Generator(..) => Some(SmallCStr::new(&"__state")),
|
||||
_ => None,
|
||||
ty::Generator(..) => "__state",
|
||||
_ => "",
|
||||
};
|
||||
let discriminator_name = discriminator_name.map(|n| n.as_ptr()).unwrap_or(ptr::null_mut());
|
||||
let discriminator_metadata = match layout.variants {
|
||||
// A single-variant enum has no discriminant.
|
||||
layout::Variants::Single { .. } => None,
|
||||
@ -1955,7 +1965,8 @@ fn prepare_enum_metadata(
|
||||
Some(llvm::LLVMRustDIBuilderCreateMemberType(
|
||||
DIB(cx),
|
||||
containing_scope,
|
||||
discriminator_name,
|
||||
discriminator_name.as_ptr().cast(),
|
||||
discriminator_name.len(),
|
||||
file_metadata,
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
size.bits(),
|
||||
@ -1981,7 +1992,8 @@ fn prepare_enum_metadata(
|
||||
Some(llvm::LLVMRustDIBuilderCreateMemberType(
|
||||
DIB(cx),
|
||||
containing_scope,
|
||||
discriminator_name,
|
||||
discriminator_name.as_ptr().cast(),
|
||||
discriminator_name.len(),
|
||||
file_metadata,
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
size.bits(),
|
||||
@ -2010,18 +2022,18 @@ fn prepare_enum_metadata(
|
||||
}
|
||||
};
|
||||
|
||||
let variant_part_unique_type_id_str = SmallCStr::new(
|
||||
debug_context(cx)
|
||||
.type_map
|
||||
.borrow_mut()
|
||||
.get_unique_type_id_str_of_enum_variant_part(unique_type_id),
|
||||
);
|
||||
let variant_part_unique_type_id_str = debug_context(cx)
|
||||
.type_map
|
||||
.borrow_mut()
|
||||
.get_unique_type_id_str_of_enum_variant_part(unique_type_id);
|
||||
let empty_array = create_DIArray(DIB(cx), &[]);
|
||||
let name = "";
|
||||
let variant_part = unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateVariantPart(
|
||||
DIB(cx),
|
||||
containing_scope,
|
||||
ptr::null_mut(),
|
||||
name.as_ptr().cast(),
|
||||
name.len(),
|
||||
file_metadata,
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
layout.size.bits(),
|
||||
@ -2029,29 +2041,38 @@ fn prepare_enum_metadata(
|
||||
DIFlags::FlagZero,
|
||||
discriminator_metadata,
|
||||
empty_array,
|
||||
variant_part_unique_type_id_str.as_ptr(),
|
||||
variant_part_unique_type_id_str.as_ptr().cast(),
|
||||
variant_part_unique_type_id_str.len(),
|
||||
)
|
||||
};
|
||||
outer_fields.push(Some(variant_part));
|
||||
|
||||
// The variant part must be wrapped in a struct according to DWARF.
|
||||
let type_array = create_DIArray(DIB(cx), &outer_fields);
|
||||
let struct_wrapper = unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateStructType(
|
||||
DIB(cx),
|
||||
Some(containing_scope),
|
||||
enum_name.as_ptr(),
|
||||
file_metadata,
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
layout.size.bits(),
|
||||
layout.align.abi.bits() as u32,
|
||||
DIFlags::FlagZero,
|
||||
None,
|
||||
type_array,
|
||||
0,
|
||||
None,
|
||||
unique_type_id_str.as_ptr(),
|
||||
)
|
||||
let struct_wrapper = {
|
||||
// The variant part must be wrapped in a struct according to DWARF.
|
||||
let type_array = create_DIArray(DIB(cx), &outer_fields);
|
||||
|
||||
let type_map = debug_context(cx).type_map.borrow();
|
||||
let unique_type_id_str = type_map.get_unique_type_id_as_string(unique_type_id);
|
||||
|
||||
unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateStructType(
|
||||
DIB(cx),
|
||||
Some(containing_scope),
|
||||
enum_name.as_ptr().cast(),
|
||||
enum_name.len(),
|
||||
file_metadata,
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
layout.size.bits(),
|
||||
layout.align.abi.bits() as u32,
|
||||
DIFlags::FlagZero,
|
||||
None,
|
||||
type_array,
|
||||
0,
|
||||
None,
|
||||
unique_type_id_str.as_ptr().cast(),
|
||||
unique_type_id_str.len(),
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
return create_and_register_recursive_type_forward_declaration(
|
||||
@ -2156,12 +2177,13 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&'
|
||||
cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), ty);
|
||||
let actual_type_metadata =
|
||||
type_metadata(cx, actual_type, rustc_span::DUMMY_SP);
|
||||
let name = SmallCStr::new(&name.as_str());
|
||||
let name = &name.as_str();
|
||||
Some(unsafe {
|
||||
Some(llvm::LLVMRustDIBuilderCreateTemplateTypeParameter(
|
||||
DIB(cx),
|
||||
None,
|
||||
name.as_ptr(),
|
||||
name.as_ptr().cast(),
|
||||
name.len(),
|
||||
actual_type_metadata,
|
||||
unknown_file_metadata(cx),
|
||||
0,
|
||||
@ -2200,10 +2222,9 @@ fn create_struct_stub(
|
||||
) -> &'ll DICompositeType {
|
||||
let (struct_size, struct_align) = cx.size_and_align_of(struct_type);
|
||||
|
||||
let name = SmallCStr::new(struct_type_name);
|
||||
let unique_type_id = SmallCStr::new(
|
||||
debug_context(cx).type_map.borrow().get_unique_type_id_as_string(unique_type_id),
|
||||
);
|
||||
let type_map = debug_context(cx).type_map.borrow();
|
||||
let unique_type_id = type_map.get_unique_type_id_as_string(unique_type_id);
|
||||
|
||||
let metadata_stub = unsafe {
|
||||
// `LLVMRustDIBuilderCreateStructType()` wants an empty array. A null
|
||||
// pointer will lead to hard to trace and debug LLVM assertions
|
||||
@ -2213,7 +2234,8 @@ fn create_struct_stub(
|
||||
llvm::LLVMRustDIBuilderCreateStructType(
|
||||
DIB(cx),
|
||||
containing_scope,
|
||||
name.as_ptr(),
|
||||
struct_type_name.as_ptr().cast(),
|
||||
struct_type_name.len(),
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
struct_size.bits(),
|
||||
@ -2223,7 +2245,8 @@ fn create_struct_stub(
|
||||
empty_array,
|
||||
0,
|
||||
None,
|
||||
unique_type_id.as_ptr(),
|
||||
unique_type_id.as_ptr().cast(),
|
||||
unique_type_id.len(),
|
||||
)
|
||||
};
|
||||
|
||||
@ -2239,10 +2262,9 @@ fn create_union_stub(
|
||||
) -> &'ll DICompositeType {
|
||||
let (union_size, union_align) = cx.size_and_align_of(union_type);
|
||||
|
||||
let name = SmallCStr::new(union_type_name);
|
||||
let unique_type_id = SmallCStr::new(
|
||||
debug_context(cx).type_map.borrow().get_unique_type_id_as_string(unique_type_id),
|
||||
);
|
||||
let type_map = debug_context(cx).type_map.borrow();
|
||||
let unique_type_id = type_map.get_unique_type_id_as_string(unique_type_id);
|
||||
|
||||
let metadata_stub = unsafe {
|
||||
// `LLVMRustDIBuilderCreateUnionType()` wants an empty array. A null
|
||||
// pointer will lead to hard to trace and debug LLVM assertions
|
||||
@ -2252,7 +2274,8 @@ fn create_union_stub(
|
||||
llvm::LLVMRustDIBuilderCreateUnionType(
|
||||
DIB(cx),
|
||||
containing_scope,
|
||||
name.as_ptr(),
|
||||
union_type_name.as_ptr().cast(),
|
||||
union_type_name.len(),
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
union_size.bits(),
|
||||
@ -2260,7 +2283,8 @@ fn create_union_stub(
|
||||
DIFlags::FlagZero,
|
||||
Some(empty_array),
|
||||
0, // RuntimeLang
|
||||
unique_type_id.as_ptr(),
|
||||
unique_type_id.as_ptr().cast(),
|
||||
unique_type_id.len(),
|
||||
)
|
||||
};
|
||||
|
||||
@ -2294,13 +2318,15 @@ pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global
|
||||
let is_local_to_unit = is_node_local_to_unit(cx, def_id);
|
||||
let variable_type = Instance::mono(cx.tcx, def_id).monomorphic_ty(cx.tcx);
|
||||
let type_metadata = type_metadata(cx, variable_type, span);
|
||||
let var_name = SmallCStr::new(&tcx.item_name(def_id).as_str());
|
||||
let var_name = tcx.item_name(def_id).as_str();
|
||||
let linkage_name = if no_mangle {
|
||||
None
|
||||
} else {
|
||||
let linkage_name = mangled_name_of_instance(cx, Instance::mono(tcx, def_id));
|
||||
Some(SmallCStr::new(&linkage_name.name.as_str()))
|
||||
Some(mangled_name_of_instance(cx, Instance::mono(tcx, def_id)).name.as_str())
|
||||
};
|
||||
// When empty, linkage_name field is omitted,
|
||||
// which is what we want for no_mangle statics
|
||||
let linkage_name = linkage_name.as_deref().unwrap_or("");
|
||||
|
||||
let global_align = cx.align_of(variable_type);
|
||||
|
||||
@ -2308,10 +2334,10 @@ pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global
|
||||
llvm::LLVMRustDIBuilderCreateStaticVariable(
|
||||
DIB(cx),
|
||||
Some(var_scope),
|
||||
var_name.as_ptr(),
|
||||
// If null, linkage_name field is omitted,
|
||||
// which is what we want for no_mangle statics
|
||||
linkage_name.as_ref().map_or(ptr::null(), |name| name.as_ptr()),
|
||||
var_name.as_ptr().cast(),
|
||||
var_name.len(),
|
||||
linkage_name.as_ptr().cast(),
|
||||
linkage_name.len(),
|
||||
file_metadata,
|
||||
line_number,
|
||||
type_metadata,
|
||||
@ -2339,8 +2365,7 @@ pub fn create_vtable_metadata(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>, vtable: &
|
||||
// pointer will lead to hard to trace and debug LLVM assertions
|
||||
// later on in `llvm/lib/IR/Value.cpp`.
|
||||
let empty_array = create_DIArray(DIB(cx), &[]);
|
||||
|
||||
let name = const_cstr!("vtable");
|
||||
let name = "vtable";
|
||||
|
||||
// Create a new one each time. We don't want metadata caching
|
||||
// here, because each vtable will refer to a unique containing
|
||||
@ -2348,7 +2373,8 @@ pub fn create_vtable_metadata(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>, vtable: &
|
||||
let vtable_type = llvm::LLVMRustDIBuilderCreateStructType(
|
||||
DIB(cx),
|
||||
NO_SCOPE_METADATA,
|
||||
name.as_ptr(),
|
||||
name.as_ptr().cast(),
|
||||
name.len(),
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
Size::ZERO.bits(),
|
||||
@ -2358,14 +2384,18 @@ pub fn create_vtable_metadata(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>, vtable: &
|
||||
empty_array,
|
||||
0,
|
||||
Some(type_metadata),
|
||||
name.as_ptr(),
|
||||
name.as_ptr().cast(),
|
||||
name.len(),
|
||||
);
|
||||
|
||||
let linkage_name = "";
|
||||
llvm::LLVMRustDIBuilderCreateStaticVariable(
|
||||
DIB(cx),
|
||||
NO_SCOPE_METADATA,
|
||||
name.as_ptr(),
|
||||
ptr::null(),
|
||||
name.as_ptr().cast(),
|
||||
name.len(),
|
||||
linkage_name.as_ptr().cast(),
|
||||
linkage_name.len(),
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
vtable_type,
|
||||
|
@ -25,13 +25,11 @@ use rustc::ty::{self, Instance, ParamEnv, Ty};
|
||||
use rustc_codegen_ssa::debuginfo::type_names;
|
||||
use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_index::vec::IndexVec;
|
||||
|
||||
use libc::c_uint;
|
||||
use log::debug;
|
||||
use std::cell::RefCell;
|
||||
use std::ffi::CString;
|
||||
|
||||
use rustc::ty::layout::{self, HasTyCtxt, LayoutOf, Size};
|
||||
use rustc_ast::ast;
|
||||
@ -273,13 +271,11 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
|
||||
// Get the linkage_name, which is just the symbol name
|
||||
let linkage_name = mangled_name_of_instance(self, instance);
|
||||
let linkage_name = linkage_name.name.as_str();
|
||||
|
||||
// FIXME(eddyb) does this need to be separate from `loc.line` for some reason?
|
||||
let scope_line = loc.line;
|
||||
|
||||
let function_name = CString::new(name).unwrap();
|
||||
let linkage_name = SmallCStr::new(&linkage_name.name.as_str());
|
||||
|
||||
let mut flags = DIFlags::FlagPrototyped;
|
||||
|
||||
if fn_abi.ret.layout.abi.is_uninhabited() {
|
||||
@ -303,8 +299,10 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
llvm::LLVMRustDIBuilderCreateFunction(
|
||||
DIB(self),
|
||||
containing_scope,
|
||||
function_name.as_ptr(),
|
||||
linkage_name.as_ptr(),
|
||||
name.as_ptr().cast(),
|
||||
name.len(),
|
||||
linkage_name.as_ptr().cast(),
|
||||
linkage_name.len(),
|
||||
file_metadata,
|
||||
loc.line as c_uint,
|
||||
function_type_metadata,
|
||||
@ -424,12 +422,13 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), ty);
|
||||
let actual_type_metadata =
|
||||
type_metadata(cx, actual_type, rustc_span::DUMMY_SP);
|
||||
let name = SmallCStr::new(&name.as_str());
|
||||
let name = name.as_str();
|
||||
Some(unsafe {
|
||||
Some(llvm::LLVMRustDIBuilderCreateTemplateTypeParameter(
|
||||
DIB(cx),
|
||||
None,
|
||||
name.as_ptr(),
|
||||
name.as_ptr().cast(),
|
||||
name.len(),
|
||||
actual_type_metadata,
|
||||
file_metadata,
|
||||
0,
|
||||
@ -542,13 +541,14 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
};
|
||||
let align = self.align_of(variable_type);
|
||||
|
||||
let name = SmallCStr::new(&variable_name.as_str());
|
||||
let name = variable_name.as_str();
|
||||
unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateVariable(
|
||||
DIB(self),
|
||||
dwarf_tag,
|
||||
scope_metadata,
|
||||
name.as_ptr(),
|
||||
name.as_ptr().cast(),
|
||||
name.len(),
|
||||
file_metadata,
|
||||
loc.line as c_uint,
|
||||
type_metadata,
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Namespace Handling.
|
||||
|
||||
use super::metadata::{unknown_file_metadata, UNKNOWN_LINE_NUMBER};
|
||||
use super::utils::{debug_context, DIB};
|
||||
use rustc::ty::{self, Instance};
|
||||
|
||||
@ -10,8 +9,6 @@ use crate::llvm::debuginfo::DIScope;
|
||||
use rustc::hir::map::DefPathData;
|
||||
use rustc_hir::def_id::DefId;
|
||||
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
|
||||
pub fn mangled_name_of_instance<'a, 'tcx>(
|
||||
cx: &CodegenCx<'a, 'tcx>,
|
||||
instance: Instance<'tcx>,
|
||||
@ -34,16 +31,15 @@ pub fn item_namespace(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope {
|
||||
DefPathData::CrateRoot => cx.tcx.crate_name(def_id.krate),
|
||||
data => data.as_symbol(),
|
||||
};
|
||||
|
||||
let namespace_name = SmallCStr::new(&namespace_name.as_str());
|
||||
let namespace_name = namespace_name.as_str();
|
||||
|
||||
let scope = unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateNameSpace(
|
||||
DIB(cx),
|
||||
parent_scope,
|
||||
namespace_name.as_ptr(),
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
namespace_name.as_ptr().cast(),
|
||||
namespace_name.len(),
|
||||
false, // ExportSymbols (only relevant for C++ anonymous namespaces)
|
||||
)
|
||||
};
|
||||
|
||||
|
@ -1607,17 +1607,21 @@ extern "C" {
|
||||
Lang: c_uint,
|
||||
File: &'a DIFile,
|
||||
Producer: *const c_char,
|
||||
ProducerLen: size_t,
|
||||
isOptimized: bool,
|
||||
Flags: *const c_char,
|
||||
RuntimeVer: c_uint,
|
||||
SplitName: *const c_char,
|
||||
SplitNameLen: size_t,
|
||||
kind: DebugEmissionKind,
|
||||
) -> &'a DIDescriptor;
|
||||
|
||||
pub fn LLVMRustDIBuilderCreateFile(
|
||||
Builder: &DIBuilder<'a>,
|
||||
Filename: *const c_char,
|
||||
FilenameLen: size_t,
|
||||
Directory: *const c_char,
|
||||
DirectoryLen: size_t,
|
||||
) -> &'a DIFile;
|
||||
|
||||
pub fn LLVMRustDIBuilderCreateSubroutineType(
|
||||
@ -1630,7 +1634,9 @@ extern "C" {
|
||||
Builder: &DIBuilder<'a>,
|
||||
Scope: &'a DIDescriptor,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
LinkageName: *const c_char,
|
||||
LinkageNameLen: size_t,
|
||||
File: &'a DIFile,
|
||||
LineNo: c_uint,
|
||||
Ty: &'a DIType,
|
||||
@ -1645,6 +1651,7 @@ extern "C" {
|
||||
pub fn LLVMRustDIBuilderCreateBasicType(
|
||||
Builder: &DIBuilder<'a>,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
SizeInBits: u64,
|
||||
AlignInBits: u32,
|
||||
Encoding: c_uint,
|
||||
@ -1655,13 +1662,16 @@ extern "C" {
|
||||
PointeeTy: &'a DIType,
|
||||
SizeInBits: u64,
|
||||
AlignInBits: u32,
|
||||
AddressSpace: c_uint,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
) -> &'a DIDerivedType;
|
||||
|
||||
pub fn LLVMRustDIBuilderCreateStructType(
|
||||
Builder: &DIBuilder<'a>,
|
||||
Scope: Option<&'a DIDescriptor>,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
File: &'a DIFile,
|
||||
LineNumber: c_uint,
|
||||
SizeInBits: u64,
|
||||
@ -1672,12 +1682,14 @@ extern "C" {
|
||||
RunTimeLang: c_uint,
|
||||
VTableHolder: Option<&'a DIType>,
|
||||
UniqueId: *const c_char,
|
||||
UniqueIdLen: size_t,
|
||||
) -> &'a DICompositeType;
|
||||
|
||||
pub fn LLVMRustDIBuilderCreateMemberType(
|
||||
Builder: &DIBuilder<'a>,
|
||||
Scope: &'a DIDescriptor,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
File: &'a DIFile,
|
||||
LineNo: c_uint,
|
||||
SizeInBits: u64,
|
||||
@ -1691,6 +1703,7 @@ extern "C" {
|
||||
Builder: &DIBuilder<'a>,
|
||||
Scope: &'a DIScope,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
File: &'a DIFile,
|
||||
LineNumber: c_uint,
|
||||
SizeInBits: u64,
|
||||
@ -1719,7 +1732,9 @@ extern "C" {
|
||||
Builder: &DIBuilder<'a>,
|
||||
Context: Option<&'a DIScope>,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
LinkageName: *const c_char,
|
||||
LinkageNameLen: size_t,
|
||||
File: &'a DIFile,
|
||||
LineNo: c_uint,
|
||||
Ty: &'a DIType,
|
||||
@ -1734,6 +1749,7 @@ extern "C" {
|
||||
Tag: c_uint,
|
||||
Scope: &'a DIDescriptor,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
File: &'a DIFile,
|
||||
LineNo: c_uint,
|
||||
Ty: &'a DIType,
|
||||
@ -1785,6 +1801,7 @@ extern "C" {
|
||||
Builder: &DIBuilder<'a>,
|
||||
Scope: &'a DIScope,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
File: &'a DIFile,
|
||||
LineNumber: c_uint,
|
||||
SizeInBits: u64,
|
||||
@ -1798,6 +1815,7 @@ extern "C" {
|
||||
Builder: &DIBuilder<'a>,
|
||||
Scope: &'a DIScope,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
File: &'a DIFile,
|
||||
LineNumber: c_uint,
|
||||
SizeInBits: u64,
|
||||
@ -1806,12 +1824,14 @@ extern "C" {
|
||||
Elements: Option<&'a DIArray>,
|
||||
RunTimeLang: c_uint,
|
||||
UniqueId: *const c_char,
|
||||
UniqueIdLen: size_t,
|
||||
) -> &'a DIType;
|
||||
|
||||
pub fn LLVMRustDIBuilderCreateVariantPart(
|
||||
Builder: &DIBuilder<'a>,
|
||||
Scope: &'a DIScope,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
File: &'a DIFile,
|
||||
LineNo: c_uint,
|
||||
SizeInBits: u64,
|
||||
@ -1820,6 +1840,7 @@ extern "C" {
|
||||
Discriminator: Option<&'a DIDerivedType>,
|
||||
Elements: &'a DIArray,
|
||||
UniqueId: *const c_char,
|
||||
UniqueIdLen: size_t,
|
||||
) -> &'a DIDerivedType;
|
||||
|
||||
pub fn LLVMSetUnnamedAddr(GlobalVar: &Value, UnnamedAddr: Bool);
|
||||
@ -1828,6 +1849,7 @@ extern "C" {
|
||||
Builder: &DIBuilder<'a>,
|
||||
Scope: Option<&'a DIScope>,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
Ty: &'a DIType,
|
||||
File: &'a DIFile,
|
||||
LineNo: c_uint,
|
||||
@ -1838,8 +1860,8 @@ extern "C" {
|
||||
Builder: &DIBuilder<'a>,
|
||||
Scope: Option<&'a DIScope>,
|
||||
Name: *const c_char,
|
||||
File: &'a DIFile,
|
||||
LineNo: c_uint,
|
||||
NameLen: size_t,
|
||||
ExportSymbols: bool,
|
||||
) -> &'a DINameSpace;
|
||||
|
||||
pub fn LLVMRustDICompositeTypeReplaceArrays(
|
||||
|
@ -665,20 +665,24 @@ extern "C" void LLVMRustDIBuilderFinalize(LLVMRustDIBuilderRef Builder) {
|
||||
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateCompileUnit(
|
||||
LLVMRustDIBuilderRef Builder, unsigned Lang, LLVMMetadataRef FileRef,
|
||||
const char *Producer, bool isOptimized, const char *Flags,
|
||||
unsigned RuntimeVer, const char *SplitName,
|
||||
const char *Producer, size_t ProducerLen, bool isOptimized,
|
||||
const char *Flags, unsigned RuntimeVer,
|
||||
const char *SplitName, size_t SplitNameLen,
|
||||
LLVMRustDebugEmissionKind Kind) {
|
||||
auto *File = unwrapDI<DIFile>(FileRef);
|
||||
|
||||
return wrap(Builder->createCompileUnit(Lang, File, Producer, isOptimized,
|
||||
Flags, RuntimeVer, SplitName,
|
||||
return wrap(Builder->createCompileUnit(Lang, File, StringRef(Producer, ProducerLen),
|
||||
isOptimized, Flags, RuntimeVer,
|
||||
StringRef(SplitName, SplitNameLen),
|
||||
fromRust(Kind)));
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef
|
||||
LLVMRustDIBuilderCreateFile(LLVMRustDIBuilderRef Builder, const char *Filename,
|
||||
const char *Directory) {
|
||||
return wrap(Builder->createFile(Filename, Directory));
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFile(
|
||||
LLVMRustDIBuilderRef Builder,
|
||||
const char *Filename, size_t FilenameLen,
|
||||
const char *Directory, size_t DirectoryLen) {
|
||||
return wrap(Builder->createFile(StringRef(Filename, FilenameLen),
|
||||
StringRef(Directory, DirectoryLen)));
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef
|
||||
@ -690,8 +694,10 @@ LLVMRustDIBuilderCreateSubroutineType(LLVMRustDIBuilderRef Builder,
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
|
||||
const char *LinkageName, LLVMMetadataRef File, unsigned LineNo,
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
|
||||
const char *Name, size_t NameLen,
|
||||
const char *LinkageName, size_t LinkageNameLen,
|
||||
LLVMMetadataRef File, unsigned LineNo,
|
||||
LLVMMetadataRef Ty, unsigned ScopeLine, LLVMRustDIFlags Flags,
|
||||
LLVMRustDISPFlags SPFlags, LLVMValueRef Fn, LLVMMetadataRef TParam,
|
||||
LLVMMetadataRef Decl) {
|
||||
@ -705,8 +711,11 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
|
||||
llvmFlags |= DINode::DIFlags::FlagMainSubprogram;
|
||||
#endif
|
||||
DISubprogram *Sub = Builder->createFunction(
|
||||
unwrapDI<DIScope>(Scope), Name, LinkageName, unwrapDI<DIFile>(File),
|
||||
LineNo, unwrapDI<DISubroutineType>(Ty), ScopeLine, llvmFlags,
|
||||
unwrapDI<DIScope>(Scope),
|
||||
StringRef(Name, NameLen),
|
||||
StringRef(LinkageName, LinkageNameLen),
|
||||
unwrapDI<DIFile>(File), LineNo,
|
||||
unwrapDI<DISubroutineType>(Ty), ScopeLine, llvmFlags,
|
||||
llvmSPFlags, TParams, unwrapDIPtr<DISubprogram>(Decl));
|
||||
#else
|
||||
bool IsLocalToUnit = isSet(SPFlags & LLVMRustDISPFlags::SPFlagLocalToUnit);
|
||||
@ -716,8 +725,11 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
|
||||
if (isSet(SPFlags & LLVMRustDISPFlags::SPFlagMainSubprogram))
|
||||
llvmFlags |= DINode::DIFlags::FlagMainSubprogram;
|
||||
DISubprogram *Sub = Builder->createFunction(
|
||||
unwrapDI<DIScope>(Scope), Name, LinkageName, unwrapDI<DIFile>(File),
|
||||
LineNo, unwrapDI<DISubroutineType>(Ty), IsLocalToUnit, IsDefinition,
|
||||
unwrapDI<DIScope>(Scope),
|
||||
StringRef(Name, NameLen),
|
||||
StringRef(LinkageName, LinkageNameLen),
|
||||
unwrapDI<DIFile>(File), LineNo,
|
||||
unwrapDI<DISubroutineType>(Ty), IsLocalToUnit, IsDefinition,
|
||||
ScopeLine, llvmFlags, IsOptimized, TParams,
|
||||
unwrapDIPtr<DISubprogram>(Decl));
|
||||
#endif
|
||||
@ -725,53 +737,59 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
|
||||
return wrap(Sub);
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef
|
||||
LLVMRustDIBuilderCreateBasicType(LLVMRustDIBuilderRef Builder, const char *Name,
|
||||
uint64_t SizeInBits, uint32_t AlignInBits,
|
||||
unsigned Encoding) {
|
||||
return wrap(Builder->createBasicType(Name, SizeInBits, Encoding));
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateBasicType(
|
||||
LLVMRustDIBuilderRef Builder, const char *Name, size_t NameLen,
|
||||
uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding) {
|
||||
return wrap(Builder->createBasicType(StringRef(Name, NameLen), SizeInBits, Encoding));
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreatePointerType(
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef PointeeTy,
|
||||
uint64_t SizeInBits, uint32_t AlignInBits, const char *Name) {
|
||||
uint64_t SizeInBits, uint32_t AlignInBits, unsigned AddressSpace,
|
||||
const char *Name, size_t NameLen) {
|
||||
return wrap(Builder->createPointerType(unwrapDI<DIType>(PointeeTy),
|
||||
SizeInBits, AlignInBits,
|
||||
/* DWARFAddressSpace */ None,
|
||||
Name));
|
||||
AddressSpace,
|
||||
StringRef(Name, NameLen)));
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStructType(
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
|
||||
const char *Name, size_t NameLen,
|
||||
LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
|
||||
uint32_t AlignInBits, LLVMRustDIFlags Flags,
|
||||
LLVMMetadataRef DerivedFrom, LLVMMetadataRef Elements,
|
||||
unsigned RunTimeLang, LLVMMetadataRef VTableHolder,
|
||||
const char *UniqueId) {
|
||||
const char *UniqueId, size_t UniqueIdLen) {
|
||||
return wrap(Builder->createStructType(
|
||||
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
|
||||
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
|
||||
unwrapDI<DIFile>(File), LineNumber,
|
||||
SizeInBits, AlignInBits, fromRust(Flags), unwrapDI<DIType>(DerivedFrom),
|
||||
DINodeArray(unwrapDI<MDTuple>(Elements)), RunTimeLang,
|
||||
unwrapDI<DIType>(VTableHolder), UniqueId));
|
||||
unwrapDI<DIType>(VTableHolder), StringRef(UniqueId, UniqueIdLen)));
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantPart(
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
|
||||
const char *Name, size_t NameLen,
|
||||
LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
|
||||
uint32_t AlignInBits, LLVMRustDIFlags Flags, LLVMMetadataRef Discriminator,
|
||||
LLVMMetadataRef Elements, const char *UniqueId) {
|
||||
LLVMMetadataRef Elements, const char *UniqueId, size_t UniqueIdLen) {
|
||||
return wrap(Builder->createVariantPart(
|
||||
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
|
||||
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
|
||||
unwrapDI<DIFile>(File), LineNumber,
|
||||
SizeInBits, AlignInBits, fromRust(Flags), unwrapDI<DIDerivedType>(Discriminator),
|
||||
DINodeArray(unwrapDI<MDTuple>(Elements)), UniqueId));
|
||||
DINodeArray(unwrapDI<MDTuple>(Elements)), StringRef(UniqueId, UniqueIdLen)));
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateMemberType(
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
|
||||
const char *Name, size_t NameLen,
|
||||
LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits,
|
||||
uint32_t AlignInBits, uint64_t OffsetInBits, LLVMRustDIFlags Flags,
|
||||
LLVMMetadataRef Ty) {
|
||||
return wrap(Builder->createMemberType(unwrapDI<DIDescriptor>(Scope), Name,
|
||||
return wrap(Builder->createMemberType(unwrapDI<DIDescriptor>(Scope),
|
||||
StringRef(Name, NameLen),
|
||||
unwrapDI<DIFile>(File), LineNo,
|
||||
SizeInBits, AlignInBits, OffsetInBits,
|
||||
fromRust(Flags), unwrapDI<DIType>(Ty)));
|
||||
@ -779,14 +797,15 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateMemberType(
|
||||
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantMemberType(
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
|
||||
const char *Name, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits,
|
||||
uint32_t AlignInBits, uint64_t OffsetInBits, LLVMValueRef Discriminant,
|
||||
const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo,
|
||||
uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, LLVMValueRef Discriminant,
|
||||
LLVMRustDIFlags Flags, LLVMMetadataRef Ty) {
|
||||
llvm::ConstantInt* D = nullptr;
|
||||
if (Discriminant) {
|
||||
D = unwrap<llvm::ConstantInt>(Discriminant);
|
||||
}
|
||||
return wrap(Builder->createVariantMemberType(unwrapDI<DIDescriptor>(Scope), Name,
|
||||
return wrap(Builder->createVariantMemberType(unwrapDI<DIDescriptor>(Scope),
|
||||
StringRef(Name, NameLen),
|
||||
unwrapDI<DIFile>(File), LineNo,
|
||||
SizeInBits, AlignInBits, OffsetInBits, D,
|
||||
fromRust(Flags), unwrapDI<DIType>(Ty)));
|
||||
@ -808,8 +827,10 @@ LLVMRustDIBuilderCreateLexicalBlockFile(LLVMRustDIBuilderRef Builder,
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticVariable(
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Context, const char *Name,
|
||||
const char *LinkageName, LLVMMetadataRef File, unsigned LineNo,
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Context,
|
||||
const char *Name, size_t NameLen,
|
||||
const char *LinkageName, size_t LinkageNameLen,
|
||||
LLVMMetadataRef File, unsigned LineNo,
|
||||
LLVMMetadataRef Ty, bool IsLocalToUnit, LLVMValueRef V,
|
||||
LLVMMetadataRef Decl = nullptr, uint32_t AlignInBits = 0) {
|
||||
llvm::GlobalVariable *InitVal = cast<llvm::GlobalVariable>(unwrap(V));
|
||||
@ -825,7 +846,8 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticVariable(
|
||||
}
|
||||
|
||||
llvm::DIGlobalVariableExpression *VarExpr = Builder->createGlobalVariableExpression(
|
||||
unwrapDI<DIDescriptor>(Context), Name, LinkageName,
|
||||
unwrapDI<DIDescriptor>(Context), StringRef(Name, NameLen),
|
||||
StringRef(LinkageName, LinkageNameLen),
|
||||
unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), IsLocalToUnit,
|
||||
#if LLVM_VERSION_GE(10, 0)
|
||||
/* isDefined */ true,
|
||||
@ -843,17 +865,20 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticVariable(
|
||||
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariable(
|
||||
LLVMRustDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Scope,
|
||||
const char *Name, LLVMMetadataRef File, unsigned LineNo,
|
||||
const char *Name, size_t NameLen,
|
||||
LLVMMetadataRef File, unsigned LineNo,
|
||||
LLVMMetadataRef Ty, bool AlwaysPreserve, LLVMRustDIFlags Flags,
|
||||
unsigned ArgNo, uint32_t AlignInBits) {
|
||||
if (Tag == 0x100) { // DW_TAG_auto_variable
|
||||
return wrap(Builder->createAutoVariable(
|
||||
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNo,
|
||||
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
|
||||
unwrapDI<DIFile>(File), LineNo,
|
||||
unwrapDI<DIType>(Ty), AlwaysPreserve, fromRust(Flags), AlignInBits));
|
||||
} else {
|
||||
return wrap(Builder->createParameterVariable(
|
||||
unwrapDI<DIDescriptor>(Scope), Name, ArgNo, unwrapDI<DIFile>(File),
|
||||
LineNo, unwrapDI<DIType>(Ty), AlwaysPreserve, fromRust(Flags)));
|
||||
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), ArgNo,
|
||||
unwrapDI<DIFile>(File), LineNo,
|
||||
unwrapDI<DIType>(Ty), AlwaysPreserve, fromRust(Flags)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -894,47 +919,50 @@ extern "C" LLVMValueRef LLVMRustDIBuilderInsertDeclareAtEnd(
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerator(
|
||||
LLVMRustDIBuilderRef Builder, const char *Name, size_t NameLen,
|
||||
int64_t Value, bool IsUnsigned) {
|
||||
return wrap(Builder->createEnumerator({Name, NameLen}, Value, IsUnsigned));
|
||||
return wrap(Builder->createEnumerator(StringRef(Name, NameLen), Value, IsUnsigned));
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerationType(
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
|
||||
const char *Name, size_t NameLen,
|
||||
LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
|
||||
uint32_t AlignInBits, LLVMMetadataRef Elements,
|
||||
LLVMMetadataRef ClassTy, bool IsScoped) {
|
||||
return wrap(Builder->createEnumerationType(
|
||||
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
|
||||
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
|
||||
unwrapDI<DIFile>(File), LineNumber,
|
||||
SizeInBits, AlignInBits, DINodeArray(unwrapDI<MDTuple>(Elements)),
|
||||
unwrapDI<DIType>(ClassTy), "", IsScoped));
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateUnionType(
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
|
||||
const char *Name, size_t NameLen,
|
||||
LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
|
||||
uint32_t AlignInBits, LLVMRustDIFlags Flags, LLVMMetadataRef Elements,
|
||||
unsigned RunTimeLang, const char *UniqueId) {
|
||||
unsigned RunTimeLang, const char *UniqueId, size_t UniqueIdLen) {
|
||||
return wrap(Builder->createUnionType(
|
||||
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
|
||||
SizeInBits, AlignInBits, fromRust(Flags),
|
||||
DINodeArray(unwrapDI<MDTuple>(Elements)), RunTimeLang, UniqueId));
|
||||
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), unwrapDI<DIFile>(File),
|
||||
LineNumber, SizeInBits, AlignInBits, fromRust(Flags),
|
||||
DINodeArray(unwrapDI<MDTuple>(Elements)), RunTimeLang,
|
||||
StringRef(UniqueId, UniqueIdLen)));
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateTemplateTypeParameter(
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
|
||||
const char *Name, size_t NameLen,
|
||||
LLVMMetadataRef Ty, LLVMMetadataRef File, unsigned LineNo,
|
||||
unsigned ColumnNo) {
|
||||
return wrap(Builder->createTemplateTypeParameter(
|
||||
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIType>(Ty)));
|
||||
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), unwrapDI<DIType>(Ty)));
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef
|
||||
LLVMRustDIBuilderCreateNameSpace(LLVMRustDIBuilderRef Builder,
|
||||
LLVMMetadataRef Scope, const char *Name,
|
||||
LLVMMetadataRef File, unsigned LineNo) {
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateNameSpace(
|
||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
|
||||
const char *Name, size_t NameLen, bool ExportSymbols) {
|
||||
return wrap(Builder->createNameSpace(
|
||||
unwrapDI<DIDescriptor>(Scope), Name,
|
||||
false // ExportSymbols (only relevant for C++ anonymous namespaces)
|
||||
));
|
||||
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), ExportSymbols
|
||||
));
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
|
Loading…
Reference in New Issue
Block a user