Skip to content

Commit 8764ecd

Browse files
committed
Add a searchable tag PTR_LEN_STR to explain *const c_uchar bindings
This module comment describes why it's OK for LLVM bindings to declare a parameter type of `*const c_uchar` for pointer/length strings, even though the corresponding parameter on the C/C++ side uses `const char *`. Adding a searchable term to each such parameter should make it easier for future maintainers to understand why `*const c_uchar` is being used instead of `*const c_char`.
1 parent 7b84c9e commit 8764ecd

File tree

1 file changed

+2
-2
lines changed
  • compiler/rustc_codegen_llvm/src/llvm

1 file changed

+2
-2
lines changed

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Bindings to the LLVM-C API (`LLVM*`), and to our own `extern "C"` wrapper
22
//! functions around the unstable LLVM C++ API (`LLVMRust*`).
33
//!
4-
//! ## Passing pointer/length strings as `*const c_uchar`
4+
//! ## Passing pointer/length strings as `*const c_uchar` (PTR_LEN_STR)
55
//!
66
//! Normally it's a good idea for Rust-side bindings to match the corresponding
77
//! C-side function declarations as closely as possible. But when passing `&str`
@@ -1766,7 +1766,7 @@ unsafe extern "C" {
17661766
pub(crate) fn LLVMDIBuilderCreateNameSpace<'ll>(
17671767
Builder: &DIBuilder<'ll>,
17681768
ParentScope: Option<&'ll Metadata>,
1769-
Name: *const c_uchar,
1769+
Name: *const c_uchar, // See "PTR_LEN_STR".
17701770
NameLen: size_t,
17711771
ExportSymbols: llvm::Bool,
17721772
) -> &'ll Metadata;

0 commit comments

Comments
 (0)