Skip to content

Commit 35ccab7

Browse files
committed
Rename whitelist -> allowlist
For the commandline arguments I added undocumented aliases to old flags, to stay backwards compatible.
1 parent b1c4178 commit 35ccab7

File tree

71 files changed

+449
-357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+449
-357
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,24 @@
127127

128128
## Deprecated
129129

130+
* `bindgen::Builder::whitelist_type` is deprecated in favor of
131+
`bindgen::Builder::allowlist_type`. [#1812][]
132+
133+
* `bindgen::Builder::whitelist_function` is deprecated in favor of
134+
`bindgen::Builder::allowlist_function`. [#1812][]
135+
136+
* `bindgen::Builder::whitelist_var` is deprecated in favor of
137+
`bindgen::Builder::allowlist_var`. [#1812][]
138+
139+
* `--whitelist_type` is deprecated in favor of
140+
`--allowlist_type`. [#1812][]
141+
142+
* `--whitelist_function` is deprecated in favor of
143+
`--allowlist_function`. [#1812][]
144+
145+
* `--whitelist_var` is deprecated in favor of
146+
`--allowlist_var`. [#1812][]
147+
130148
## Removed
131149

132150
## Fixed

book/src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
- [Publish Your Crate!](./tutorial-6.md)
1313
- [Command Line Usage](./command-line-usage.md)
1414
- [Customizing the Generated Bindings](./customizing-generated-bindings.md)
15-
- [Whitelisting](./whitelisting.md)
15+
- [Allowlisting](./allowlisting.md)
1616
- [Blacklisting](./blacklisting.md)
1717
- [Treating a Type as an Opaque Blob of Bytes](./opaque.md)
1818
- [Replacing One Type with Another](./replacing-types.md)

book/src/allowlisting.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Allowlisting
2+
3+
Allowlisting allows us to be precise about which type, function, and global
4+
variable definitions `bindgen` generates bindings for. By default, if we don't
5+
specify any allowlisting rules, everything is considered allowlisted. This may
6+
not be desirable because of either
7+
8+
* the generated bindings contain a lot of extra definitions we don't plan on using, or
9+
* the header file contains C++ features for which Rust does not have a
10+
corresponding form (such as partial template specialization), and we would
11+
like to avoid these definitions
12+
13+
If we specify allowlisting rules, then `bindgen` will only generate bindings to
14+
types, functions, and global variables that match the allowlisting rules, or are
15+
transitively used by a definition that matches them.
16+
17+
### Library
18+
19+
* [`bindgen::Builder::allowlist_type`](https://docs.rs/bindgen/0.23.1/bindgen/struct.Builder.html#method.allowlist_type)
20+
* [`bindgen::Builder::allowlist_function`](https://docs.rs/bindgen/0.23.1/bindgen/struct.Builder.html#method.allowlist_function)
21+
* [`bindgen::Builder::allowlist_var`](https://docs.rs/bindgen/0.23.1/bindgen/struct.Builder.html#method.allowlist_var)
22+
23+
### Command Line
24+
25+
* `--allowlist-type <type>`
26+
* `--allowlist-function <function>`
27+
* `--allowlist-var <var>`
28+
29+
### Annotations
30+
31+
None.

book/src/cpp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ it ends in `.hpp`. If it doesn't, adding `-x c++` clang args can be used to
1111
force C++ mode. You probably also want to use `-std=c++14` or similar clang args
1212
as well.
1313

14-
You pretty much **must** use [whitelisting](./whitelisting.md) when working
14+
You pretty much **must** use [allowlisting](./allowlisting.md) when working
1515
with C++ to avoid pulling in all of the `std::.*` types, many of which `bindgen`
1616
cannot handle. Additionally, you may want to mark other types as
1717
[opaque](./opaque.md) that `bindgen` stumbles on. It is recommended to mark
18-
all of `std::.*` opaque, and to whitelist only precisely the functions and types
18+
all of `std::.*` opaque, and to allowlist only precisely the functions and types
1919
you intend to use.
2020

2121
You should read up on the [FAQs](./faq.md) as well.

book/src/faq.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
55

66

7-
- [Why isn't `bindgen` generating methods for this whitelisted class?](#why-isnt-bindgen-generating-methods-for-this-whitelisted-class)
7+
- [Why isn't `bindgen` generating methods for this allowlisted class?](#why-isnt-bindgen-generating-methods-for-this-allowlisted-class)
88
- [Why isn't `bindgen` generating bindings to inline functions?](#why-isnt-bindgen-generating-bindings-to-inline-functions)
99
- [Does `bindgen` support the C++ Standard Template Library (STL)?](#does-bindgen-support-the-c-standard-template-library-stl)
1010

1111
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
1212

13-
### Why isn't `bindgen` generating methods for this whitelisted class?
13+
### Why isn't `bindgen` generating methods for this allowlisted class?
1414

1515
Are the methods `inline` methods, or defined inline in the class? For example:
1616

@@ -62,7 +62,7 @@ STL. That ties our hands when it comes to linking: ["Why isn't `bindgen` generat
6262
As far as generating opaque blobs of bytes with the correct size and alignment,
6363
`bindgen` can do pretty well. This is typically enough to let you use types that
6464
transitively contain STL things. We generally recommend marking `std::.*` as
65-
opaque, and then whitelisting only the specific things you need from the library
65+
opaque, and then allowlisting only the specific things you need from the library
6666
you're binding to that is pulling in STL headers.
6767
6868
### How to deal with bindgen generated padding fields?

book/src/whitelisting.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/codegen/impl_debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'a> ImplDebug<'a> for Item {
122122

123123
// We don't know if blacklisted items `impl Debug` or not, so we can't
124124
// add them to the format string we're building up.
125-
if !ctx.whitelisted_items().contains(&self.id()) {
125+
if !ctx.allowlisted_items().contains(&self.id()) {
126126
return None;
127127
}
128128

src/codegen/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ impl CodeGenerator for Item {
457457
// TODO(emilio, #453): Figure out what to do when this happens
458458
// legitimately, we could track the opaque stuff and disable the
459459
// assertion there I guess.
460-
warn!("Found non-whitelisted item in code generation: {:?}", self);
460+
warn!("Found non-allowlisted item in code generation: {:?}", self);
461461
}
462462

463463
result.set_seen(self.id());
@@ -725,7 +725,7 @@ impl CodeGenerator for Type {
725725
// These items don't need code generation, they only need to be
726726
// converted to rust types in fields, arguments, and such.
727727
// NOTE(emilio): If you add to this list, make sure to also add
728-
// it to BindgenContext::compute_whitelisted_and_codegen_items.
728+
// it to BindgenContext::compute_allowlisted_and_codegen_items.
729729
return;
730730
}
731731
TypeKind::TemplateInstantiation(ref inst) => {

src/ir/analysis/derive.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<'ctx> CannotDerive<'ctx> {
138138
}
139139

140140
fn constrain_type(&mut self, item: &Item, ty: &Type) -> CanDerive {
141-
if !self.ctx.whitelisted_items().contains(&item.id()) {
141+
if !self.ctx.allowlisted_items().contains(&item.id()) {
142142
trace!(
143143
" cannot derive {} for blacklisted type",
144144
self.derive_trait
@@ -640,10 +640,10 @@ impl<'ctx> MonotoneFramework for CannotDerive<'ctx> {
640640
}
641641

642642
fn initial_worklist(&self) -> Vec<ItemId> {
643-
// The transitive closure of all whitelisted items, including explicitly
643+
// The transitive closure of all allowlisted items, including explicitly
644644
// blacklisted items.
645645
self.ctx
646-
.whitelisted_items()
646+
.allowlisted_items()
647647
.iter()
648648
.cloned()
649649
.flat_map(|i| {

src/ir/analysis/has_destructor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<'ctx> MonotoneFramework for HasDestructorAnalysis<'ctx> {
8383
}
8484

8585
fn initial_worklist(&self) -> Vec<ItemId> {
86-
self.ctx.whitelisted_items().iter().cloned().collect()
86+
self.ctx.allowlisted_items().iter().cloned().collect()
8787
}
8888

8989
fn constrain(&mut self, id: ItemId) -> ConstrainResult {

0 commit comments

Comments
 (0)