Skip to content

Commit 002771a

Browse files
committed
Use LLVMDIBuilderCreateQualifiedType
1 parent bb21dbe commit 002771a

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
567567
let build_assoc_const = |name: &str,
568568
type_di_node_: &'ll DIType,
569569
value: u64,
570-
align: Align| unsafe {
570+
align: Align|
571+
-> &'ll llvm::Metadata {
571572
// FIXME: Currently we force all DISCR_* values to be u64's as LLDB seems to have
572573
// problems inspecting other value types. Since DISCR_* is typically only going to be
573574
// directly inspected via the debugger visualizer - which compares it to the `tag` value
@@ -580,8 +581,9 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
580581
};
581582

582583
// must wrap type in a `const` modifier for LLDB to be able to inspect the value of the member
583-
let field_type =
584-
llvm::LLVMRustDIBuilderCreateQualifiedType(DIB(cx), DW_TAG_const_type, t_di);
584+
let field_type = unsafe {
585+
llvm::LLVMDIBuilderCreateQualifiedType(DIB(cx), DW_TAG_const_type, t_di)
586+
};
585587

586588
create_static_member_type(
587589
cx,

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,6 +1970,14 @@ unsafe extern "C" {
19701970
ConstantVal: Option<&'ll Value>,
19711971
AlignInBits: u32,
19721972
) -> &'ll Metadata;
1973+
1974+
/// Creates a "qualified type" in the C/C++ sense, by adding modifiers
1975+
/// like `const` or `volatile`.
1976+
pub(crate) fn LLVMDIBuilderCreateQualifiedType<'ll>(
1977+
Builder: &DIBuilder<'ll>,
1978+
Tag: c_uint, // (DWARF tag, e.g. `DW_TAG_const_type`)
1979+
Type: &'ll Metadata,
1980+
) -> &'ll Metadata;
19731981
}
19741982

19751983
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2330,12 +2338,6 @@ unsafe extern "C" {
23302338
Ty: &'a DIType,
23312339
) -> &'a DIType;
23322340

2333-
pub(crate) fn LLVMRustDIBuilderCreateQualifiedType<'a>(
2334-
Builder: &DIBuilder<'a>,
2335-
Tag: c_uint,
2336-
Type: &'a DIType,
2337-
) -> &'a DIDerivedType;
2338-
23392341
pub(crate) fn LLVMRustDIBuilderCreateStaticVariable<'a>(
23402342
Builder: &DIBuilder<'a>,
23412343
Context: Option<&'a DIScope>,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,13 +1103,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantMemberType(
11031103
fromRust(Flags), unwrapDI<DIType>(Ty)));
11041104
}
11051105

1106-
extern "C" LLVMMetadataRef
1107-
LLVMRustDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder, unsigned Tag,
1108-
LLVMMetadataRef Type) {
1109-
return wrap(
1110-
unwrap(Builder)->createQualifiedType(Tag, unwrapDI<DIType>(Type)));
1111-
}
1112-
11131106
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticVariable(
11141107
LLVMDIBuilderRef Builder, LLVMMetadataRef Context, const char *Name,
11151108
size_t NameLen, const char *LinkageName, size_t LinkageNameLen,

0 commit comments

Comments
 (0)