Use LLVMDIBuilderCreateTypedef

This commit is contained in:
Zalathar
2025-09-17 21:36:59 +10:00
parent 002771ab5c
commit 6b51f7c076
3 changed files with 17 additions and 25 deletions

View File

@@ -821,14 +821,15 @@ fn build_basic_type_di_node<'ll, 'tcx>(
}; };
let typedef_di_node = unsafe { let typedef_di_node = unsafe {
llvm::LLVMRustDIBuilderCreateTypedef( llvm::LLVMDIBuilderCreateTypedef(
DIB(cx), DIB(cx),
ty_di_node, ty_di_node,
typedef_name.as_c_char_ptr(), typedef_name.as_ptr(),
typedef_name.len(), typedef_name.len(),
unknown_file_metadata(cx), unknown_file_metadata(cx),
0, 0, // (no line number)
None, None, // (no scope)
0u32, // (no alignment specified)
) )
}; };

View File

@@ -24,7 +24,7 @@ use rustc_target::spec::SymbolVisibility;
use super::RustString; use super::RustString;
use super::debuginfo::{ use super::debuginfo::{
DIArray, DIBasicType, DIBuilder, DIDerivedType, DIDescriptor, DIEnumerator, DIFile, DIFlags, DIArray, DIBuilder, DIDerivedType, DIDescriptor, DIEnumerator, DIFile, DIFlags,
DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram, DISubrange, DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram, DISubrange,
DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind, DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind,
}; };
@@ -1978,6 +1978,17 @@ unsafe extern "C" {
Tag: c_uint, // (DWARF tag, e.g. `DW_TAG_const_type`) Tag: c_uint, // (DWARF tag, e.g. `DW_TAG_const_type`)
Type: &'ll Metadata, Type: &'ll Metadata,
) -> &'ll Metadata; ) -> &'ll Metadata;
pub(crate) fn LLVMDIBuilderCreateTypedef<'ll>(
Builder: &DIBuilder<'ll>,
Type: &'ll Metadata,
Name: *const c_uchar, // See "PTR_LEN_STR".
NameLen: size_t,
File: &'ll Metadata,
LineNo: c_uint,
Scope: Option<&'ll Metadata>,
AlignInBits: u32, // (optional; default is 0)
) -> &'ll Metadata;
} }
#[link(name = "llvm-wrapper", kind = "static")] #[link(name = "llvm-wrapper", kind = "static")]
@@ -2313,16 +2324,6 @@ unsafe extern "C" {
TParam: &'a DIArray, TParam: &'a DIArray,
) -> &'a DISubprogram; ) -> &'a DISubprogram;
pub(crate) fn LLVMRustDIBuilderCreateTypedef<'a>(
Builder: &DIBuilder<'a>,
Type: &'a DIBasicType,
Name: *const c_char,
NameLen: size_t,
File: &'a DIFile,
LineNo: c_uint,
Scope: Option<&'a DIScope>,
) -> &'a DIDerivedType;
pub(crate) fn LLVMRustDIBuilderCreateVariantMemberType<'a>( pub(crate) fn LLVMRustDIBuilderCreateVariantMemberType<'a>(
Builder: &DIBuilder<'a>, Builder: &DIBuilder<'a>,
Scope: &'a DIScope, Scope: &'a DIScope,

View File

@@ -1064,16 +1064,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateMethod(
return wrap(Sub); return wrap(Sub);
} }
extern "C" LLVMMetadataRef
LLVMRustDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type,
const char *Name, size_t NameLen,
LLVMMetadataRef File, unsigned LineNo,
LLVMMetadataRef Scope) {
return wrap(unwrap(Builder)->createTypedef(
unwrap<DIType>(Type), StringRef(Name, NameLen), unwrap<DIFile>(File),
LineNo, unwrapDIPtr<DIScope>(Scope)));
}
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantPart( extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantPart(
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,