Skip to content

Commit bd9aa07

Browse files
committed
Use LLVMDIBuilderCreateNameSpace
1 parent a907bc5 commit bd9aa07

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/namespace.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir::def_id::DefId;
55
use rustc_middle::ty::{self, Instance};
66

77
use super::utils::{DIB, debug_context};
8-
use crate::common::{AsCCharPtr, CodegenCx};
8+
use crate::common::CodegenCx;
99
use crate::llvm;
1010
use crate::llvm::debuginfo::DIScope;
1111

@@ -33,12 +33,12 @@ pub(crate) fn item_namespace<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'l
3333
};
3434

3535
let scope = unsafe {
36-
llvm::LLVMRustDIBuilderCreateNameSpace(
36+
llvm::LLVMDIBuilderCreateNameSpace(
3737
DIB(cx),
3838
parent_scope,
39-
namespace_name_string.as_c_char_ptr(),
39+
namespace_name_string.as_ptr(),
4040
namespace_name_string.len(),
41-
false, // ExportSymbols (only relevant for C++ anonymous namespaces)
41+
llvm::False, // ExportSymbols (only relevant for C++ anonymous namespaces)
4242
)
4343
};
4444

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ use std::fmt::Debug;
55
use std::marker::PhantomData;
66
use std::ptr;
77

8-
use libc::{c_char, c_int, c_uint, c_ulonglong, c_void, size_t};
8+
use libc::{c_char, c_int, c_uchar, c_uint, c_ulonglong, c_void, size_t};
99
use rustc_macros::TryFromU32;
1010
use rustc_target::spec::SymbolVisibility;
1111

1212
use super::RustString;
1313
use super::debuginfo::{
1414
DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
15-
DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DINameSpace,
16-
DISPFlags, DIScope, DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable,
17-
DebugEmissionKind, DebugNameTableKind,
15+
DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DISPFlags, DIScope,
16+
DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind,
17+
DebugNameTableKind,
1818
};
19+
use crate::llvm;
1920

2021
pub type Bool = c_uint;
2122

@@ -1629,6 +1630,14 @@ unsafe extern "C" {
16291630
pub(crate) fn LLVMDisposeDIBuilder<'ll>(Builder: ptr::NonNull<DIBuilder<'ll>>);
16301631

16311632
pub(crate) fn LLVMDIBuilderFinalize<'ll>(Builder: &DIBuilder<'ll>);
1633+
1634+
pub(crate) fn LLVMDIBuilderCreateNameSpace<'ll>(
1635+
Builder: &DIBuilder<'ll>,
1636+
ParentScope: Option<&'ll Metadata>,
1637+
Name: *const c_uchar,
1638+
NameLen: size_t,
1639+
ExportSymbols: llvm::Bool,
1640+
) -> &'ll Metadata;
16321641
}
16331642

16341643
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2192,14 +2201,6 @@ unsafe extern "C" {
21922201
Ty: &'a DIType,
21932202
) -> &'a DITemplateTypeParameter;
21942203

2195-
pub fn LLVMRustDIBuilderCreateNameSpace<'a>(
2196-
Builder: &DIBuilder<'a>,
2197-
Scope: Option<&'a DIScope>,
2198-
Name: *const c_char,
2199-
NameLen: size_t,
2200-
ExportSymbols: bool,
2201-
) -> &'a DINameSpace;
2202-
22032204
pub fn LLVMRustDICompositeTypeReplaceArrays<'a>(
22042205
Builder: &DIBuilder<'a>,
22052206
CompositeType: &'a DIType,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,14 +1204,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateTemplateTypeParameter(
12041204
unwrapDI<DIType>(Ty), IsDefault));
12051205
}
12061206

1207-
extern "C" LLVMMetadataRef
1208-
LLVMRustDIBuilderCreateNameSpace(LLVMRustDIBuilderRef Builder,
1209-
LLVMMetadataRef Scope, const char *Name,
1210-
size_t NameLen, bool ExportSymbols) {
1211-
return wrap(Builder->createNameSpace(
1212-
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), ExportSymbols));
1213-
}
1214-
12151207
extern "C" void LLVMRustDICompositeTypeReplaceArrays(
12161208
LLVMRustDIBuilderRef Builder, LLVMMetadataRef CompositeTy,
12171209
LLVMMetadataRef Elements, LLVMMetadataRef Params) {

0 commit comments

Comments
 (0)