Skip to content

Commit 62d91c5

Browse files
authored
Also de-duplicate functions with wrapped static functions feature (#2416)
1 parent 52a8cde commit 62d91c5

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

bindgen-tests/tests/headers/wrap-static-fns.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
static inline int foo() {
44
return 11;
55
}
6+
static int bar();
67
static int bar() {
78
return 1;
89
}

bindgen/codegen/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4029,14 +4029,10 @@ impl CodeGenerator for Function {
40294029

40304030
let is_internal = matches!(self.linkage(), Linkage::Internal);
40314031

4032-
if is_internal {
4033-
if ctx.options().wrap_static_fns {
4034-
result.items_to_serialize.push(item.id());
4035-
} else {
4036-
// We can't do anything with Internal functions if we are not wrapping them so just
4037-
// avoid generating anything for them.
4038-
return None;
4039-
}
4032+
if is_internal && !ctx.options().wrap_static_fns {
4033+
// We can't do anything with Internal functions if we are not wrapping them so just
4034+
// avoid generating anything for them.
4035+
return None;
40404036
}
40414037

40424038
// Pure virtual methods have no actual symbol, so we can't generate
@@ -4139,6 +4135,10 @@ impl CodeGenerator for Function {
41394135
abi => abi,
41404136
};
41414137

4138+
if is_internal && ctx.options().wrap_static_fns {
4139+
result.items_to_serialize.push(item.id());
4140+
}
4141+
41424142
// Handle overloaded functions by giving each overload its own unique
41434143
// suffix.
41444144
let times_seen = result.overload_number(&canonical_name);

0 commit comments

Comments
 (0)