Skip to content

Commit

Permalink
Do not pass generated_name_override name to generated_link_name_override
Browse files Browse the repository at this point in the history
  • Loading branch information
Molot2032 committed Feb 2, 2025
1 parent 03d49b6 commit 979b581
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions bindgen-tests/tests/headers/generated_link_name_override.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// bindgen-parse-callbacks: prefix-link-name-
// bindgen-parse-callbacks: remove-function-prefix-prefix_kept_in_link_name_only_
// prefix-link-name- with no value just ensures that the items are always given the link_name attribute.

extern const int prefix_kept_in_link_name_only_var_coolConstVariable_name;

extern int prefix_kept_in_link_name_only_var_coolVariable_name;

void prefix_kept_in_link_name_only_function_coolFunction_name(const int x);

15 changes: 8 additions & 7 deletions bindgen/ir/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,14 @@ impl ClangSubItemParser for Function {
// but seems easy enough to handle it here.
name.push_str("_destructor");
}

let link_name = context.options().last_callback(|callbacks| {
callbacks.generated_link_name_override(ItemInfo {
name: name.as_str(),
kind: ItemKind::Function,
})
});

if let Some(nm) = context.options().last_callback(|callbacks| {
callbacks.generated_name_override(ItemInfo {
name: name.as_str(),
Expand All @@ -796,13 +804,6 @@ impl ClangSubItemParser for Function {

let mangled_name = cursor_mangling(context, &cursor);

let link_name = context.options().last_callback(|callbacks| {
callbacks.generated_link_name_override(ItemInfo {
name: name.as_str(),
kind: ItemKind::Function,
})
});

let function = Self::new(
name.clone(),
mangled_name,
Expand Down
15 changes: 8 additions & 7 deletions bindgen/ir/var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ impl ClangSubItemParser for Var {
}
CXCursor_VarDecl => {
let mut name = cursor.spelling();

let link_name = ctx.options().last_callback(|callbacks| {
callbacks.generated_link_name_override(ItemInfo {
name: name.as_str(),
kind: ItemKind::Var,
})
});

if cursor.linkage() == CXLinkage_External {
if let Some(nm) = ctx.options().last_callback(|callbacks| {
callbacks.generated_name_override(ItemInfo {
Expand All @@ -289,13 +297,6 @@ impl ClangSubItemParser for Var {
return Err(ParseError::Continue);
}

let link_name = ctx.options().last_callback(|callbacks| {
callbacks.generated_link_name_override(ItemInfo {
name: name.as_str(),
kind: ItemKind::Var,
})
});

let ty = cursor.cur_type();

// TODO(emilio): do we have to special-case constant arrays in
Expand Down

0 comments on commit 979b581

Please sign in to comment.