rust-lang / rust-lang/rust-bindgen
C++: Inconsistent whitelisting / blacklisting paths for stuff nested inside a class / struct.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
class Foo {
public:
static const int SomeStatic;
};
Bindgen Invocation
bindgen::Builder::default()
.clang_args(&["-x", "c++"])
.header("wrapper.h")
.whitelist_type("Foo")
.blacklist_item("Foo::SomeStatic")
.generate()
.expect("Unable to generate bindings");
Actual Results
extern "C" {
#[link_name = "\u{1}_ZN3Foo10SomeStaticE"]
pub static Foo_SomeStatic: ::std::os::raw::c_int;
}
Expected Results
Bindings for Foo::SomeStatic shouldn't be generated. They are not used internally by the generated bindings, nor do I intend to use them in my wrapper.
The dead_code lint triggers for it, and I don't want to allow(dead_code) for the entire generated bindings, as I think it's useful to know what items I haven't used yet in my wrapper library.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal C++ header and bindgen::Builder invocation shown in the issue, then inspect how nested C++ names are matched by whitelist_type and blacklist_item. Reproduce the generated Foo_SomeStatic binding and trace the filtering path; done means Foo::SomeStatic is omitted while Foo remains available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100