Skip to content

Commit 02a3d12

Browse files
committed
Use LLVMDIBuilderCreateNameSpace
1 parent d6b2567 commit 02a3d12

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
/// In the LLVM-C API, boolean values are passed as `typedef int LLVMBool`,
2122
/// which has a different ABI from Rust or C++ `bool`.
@@ -1623,6 +1624,14 @@ unsafe extern "C" {
16231624
pub(crate) fn LLVMDisposeDIBuilder<'ll>(Builder: ptr::NonNull<DIBuilder<'ll>>);
16241625

16251626
pub(crate) fn LLVMDIBuilderFinalize<'ll>(Builder: &DIBuilder<'ll>);
1627+
1628+
pub(crate) fn LLVMDIBuilderCreateNameSpace<'ll>(
1629+
Builder: &DIBuilder<'ll>,
1630+
ParentScope: Option<&'ll Metadata>,
1631+
Name: *const c_uchar,
1632+
NameLen: size_t,
1633+
ExportSymbols: llvm::Bool,
1634+
) -> &'ll Metadata;
16261635
}
16271636

16281637
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2186,14 +2195,6 @@ unsafe extern "C" {
21862195
Ty: &'a DIType,
21872196
) -> &'a DITemplateTypeParameter;
21882197

2189-
pub fn LLVMRustDIBuilderCreateNameSpace<'a>(
2190-
Builder: &DIBuilder<'a>,
2191-
Scope: Option<&'a DIScope>,
2192-
Name: *const c_char,
2193-
NameLen: size_t,
2194-
ExportSymbols: bool,
2195-
) -> &'a DINameSpace;
2196-
21972198
pub fn LLVMRustDICompositeTypeReplaceArrays<'a>(
21982199
Builder: &DIBuilder<'a>,
21992200
CompositeType: &'a DIType,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

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

1297-
extern "C" LLVMMetadataRef
1298-
LLVMRustDIBuilderCreateNameSpace(LLVMRustDIBuilderRef Builder,
1299-
LLVMMetadataRef Scope, const char *Name,
1300-
size_t NameLen, bool ExportSymbols) {
1301-
return wrap(Builder->createNameSpace(
1302-
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), ExportSymbols));
1303-
}
1304-
13051297
extern "C" void LLVMRustDICompositeTypeReplaceArrays(
13061298
LLVMRustDIBuilderRef Builder, LLVMMetadataRef CompositeTy,
13071299
LLVMMetadataRef Elements, LLVMMetadataRef Params) {

0 commit comments

Comments
 (0)