Skip to content

Commit 878ab12

Browse files
committed
Use LLVMDIBuilderCreateNameSpace
1 parent cd2af2d commit 878ab12

File tree

3 files changed

+18
-25
lines changed

3 files changed

+18
-25
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: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ 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 bitflags::bitflags;
9+
use libc::{c_char, c_int, c_uchar, c_uint, c_ulonglong, c_void, size_t};
910
use rustc_macros::TryFromU32;
1011
use rustc_target::spec::SymbolVisibility;
1112

1213
use super::RustString;
1314
use super::debuginfo::{
1415
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,
16+
DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DISPFlags, DIScope,
17+
DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind,
18+
DebugNameTableKind,
1819
};
20+
use crate::llvm;
1921

2022
/// In the LLVM-C API, boolean values are passed as `typedef int LLVMBool`,
2123
/// which has a different ABI from Rust or C++ `bool`.
@@ -952,7 +954,6 @@ pub mod debuginfo {
952954
}
953955
}
954956

955-
use bitflags::bitflags;
956957
// These values **must** match with LLVMRustAllocKindFlags
957958
bitflags! {
958959
#[repr(transparent)]
@@ -1717,6 +1718,14 @@ unsafe extern "C" {
17171718
pub(crate) fn LLVMDisposeDIBuilder<'ll>(Builder: ptr::NonNull<DIBuilder<'ll>>);
17181719

17191720
pub(crate) fn LLVMDIBuilderFinalize<'ll>(Builder: &DIBuilder<'ll>);
1721+
1722+
pub(crate) fn LLVMDIBuilderCreateNameSpace<'ll>(
1723+
Builder: &DIBuilder<'ll>,
1724+
ParentScope: Option<&'ll Metadata>,
1725+
Name: *const c_uchar,
1726+
NameLen: size_t,
1727+
ExportSymbols: llvm::Bool,
1728+
) -> &'ll Metadata;
17201729
}
17211730

17221731
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2286,14 +2295,6 @@ unsafe extern "C" {
22862295
Ty: &'a DIType,
22872296
) -> &'a DITemplateTypeParameter;
22882297

2289-
pub fn LLVMRustDIBuilderCreateNameSpace<'a>(
2290-
Builder: &DIBuilder<'a>,
2291-
Scope: Option<&'a DIScope>,
2292-
Name: *const c_char,
2293-
NameLen: size_t,
2294-
ExportSymbols: bool,
2295-
) -> &'a DINameSpace;
2296-
22972298
pub fn LLVMRustDICompositeTypeReplaceArrays<'a>(
22982299
Builder: &DIBuilder<'a>,
22992300
CompositeType: &'a DIType,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

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

1324-
extern "C" LLVMMetadataRef
1325-
LLVMRustDIBuilderCreateNameSpace(LLVMDIBuilderRef Builder,
1326-
LLVMMetadataRef Scope, const char *Name,
1327-
size_t NameLen, bool ExportSymbols) {
1328-
return wrap(unwrap(Builder)->createNameSpace(
1329-
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), ExportSymbols));
1330-
}
1331-
13321324
extern "C" void LLVMRustDICompositeTypeReplaceArrays(
13331325
LLVMDIBuilderRef Builder, LLVMMetadataRef CompositeTy,
13341326
LLVMMetadataRef Elements, LLVMMetadataRef Params) {

0 commit comments

Comments
 (0)