Skip to content

Commit ef14e02

Browse files
committed
Rename whitelist -> allowlist and blacklist -> blocklist
For the commandline arguments I added undocumented aliases to old flags, to stay backwards compatible.
1 parent e59aa92 commit ef14e02

File tree

128 files changed

+867
-778
lines changed

Some content is hidden

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

128 files changed

+867
-778
lines changed

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,42 @@
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+
148+
* `bindgen::Builder::blacklist_type` is deprecated in favor of
149+
`bindgen::Builder::blocklist_type`. [#1812][]
150+
151+
* `bindgen::Builder::blacklist_function` is deprecated in favor of
152+
`bindgen::Builder::blocklist_function`. [#1812][]
153+
154+
* `bindgen::Builder::blacklist_item` is deprecated in favor of
155+
`bindgen::Builder::blocklist_item`. [#1812][]
156+
157+
* `--blacklist-type` is deprecated in favor of
158+
`--blocklist-type`. [#1812][]
159+
160+
* `--blacklist-function` is deprecated in favor of
161+
`--blocklist-function`. [#1812][]
162+
163+
* `--blacklist-item` is deprecated in favor of
164+
`--blocklist-item`. [#1812][]
165+
130166
## Removed
131167

132168
## Fixed

bindgen-integration/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn main() {
160160
seen_hellos: Mutex::new(0),
161161
seen_funcs: Mutex::new(0),
162162
}))
163-
.blacklist_function("my_prefixed_function_to_remove")
163+
.blocklist_function("my_prefixed_function_to_remove")
164164
.constified_enum("my_prefixed_enum_to_be_constified")
165165
.opaque_type("my_prefixed_templated_foo<my_prefixed_baz>")
166166
.generate()

book/src/SUMMARY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
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)
16-
- [Blacklisting](./blacklisting.md)
15+
- [Allowlisting](./allowlisting.md)
16+
- [Blocklisting](./blocklisting.md)
1717
- [Treating a Type as an Opaque Blob of Bytes](./opaque.md)
1818
- [Replacing One Type with Another](./replacing-types.md)
1919
- [Preventing the Derivation of `Copy` and `Clone`](./nocopy.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/blacklisting.md renamed to book/src/blocklisting.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
# Blacklisting
1+
# Blocklisting
22

33
If you need to provide your own custom translation of some type (for example,
44
because you need to wrap one of its fields in an `UnsafeCell`), you can
5-
explicitly blacklist generation of its definition. Uses of the blacklisted type
5+
explicitly blocklist
6+
generation of its definition. Uses of the blocklisted type
67
will still appear in other types' definitions. (If you don't want the type to
78
appear in the bindings at
89
all, [make it opaque](./opaque.md) instead of
9-
blacklisting it.)
10+
blocklisting it.)
1011

11-
Blacklisted types are pessimistically assumed not to be able to `derive` any
12+
Blocklisted types are pessimistically assumed not to be able to `derive` any
1213
traits, which can transitively affect other types' ability to `derive` traits or
1314
not.
1415

1516
### Library
1617

17-
* [`bindgen::Builder::blacklist_type`](https://docs.rs/bindgen/0.31.3/bindgen/struct.Builder.html#method.blacklist_type)
18+
* [`bindgen::Builder::blocklist_type`](https://docs.rs/bindgen/0.31.3/bindgen/struct.Builder.html#method.blocklist_type)
1819

1920
### Command Line
2021

21-
* `--blacklist-type <type>`
22+
* `--blocklist-type <type>`
2223

2324
### Annotations
2425

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/objc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generating Bindings to Objective-C
22

33
`bindgen` does not (yet) have full objective-c support but it can generate bindings
4-
for a lot of the apple frameworks without too much blacklisting.
4+
for a lot of the apple frameworks without too much blocklisting.
55

66
In order to generate bindings, you will need `-x objective-c` as the clang
77
args. If you'd like to use [block](https://crates.io/crates/block) you will need
@@ -49,7 +49,7 @@ name and `id` is a pointer to the objective-c Object.
4949
`--target=arm64-apple-ios` as mentioned
5050
[here](https://github.com/rust-lang/rust-bindgen/issues/1211#issuecomment-569804287).
5151
* The generated bindings will almost certainly have some conflicts so you will
52-
have to blacklist a few things. There are a few cases of the parameters being
52+
have to blocklist a few things. There are a few cases of the parameters being
5353
poorly named in the objective-c headers. But if you're using anything with
5454
Core Foundation, you'll find that `time.h` as has a variable called timezone that
5555
conflicts with some of the things in `NSCalendar.h`.

book/src/replacing-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ That way, after code generation, the bindings for the `nsTArray` type are
2424
the ones that would be generated for `nsTArray_Simple`.
2525
2626
Replacing is only available as an annotation. To replace a C or C++ definition
27-
with a Rust definition, use [blacklisting](./blacklisting.md).
27+
with a Rust definition, use [blocklisting](./blocklisting.md).

book/src/whitelisting.md

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

src/codegen/impl_debug.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ impl<'a> ImplDebug<'a> for Item {
120120
) -> Option<(String, Vec<proc_macro2::TokenStream>)> {
121121
let name_ident = ctx.rust_ident(name);
122122

123-
// We don't know if blacklisted items `impl Debug` or not, so we can't
123+
// We don't know if blocklisted 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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ impl CodeGenerator for Item {
443443
return;
444444
}
445445

446-
if self.is_blacklisted(ctx) || result.seen(self.id()) {
446+
if self.is_blocklisted(ctx) || result.seen(self.id()) {
447447
debug!(
448448
"<Item as CodeGenerator>::codegen: Ignoring hidden or seen: \
449449
self = {:?}",
@@ -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) => {
@@ -2261,8 +2261,8 @@ impl MethodCodegen for Method {
22612261

22622262
// First of all, output the actual function.
22632263
let function_item = ctx.resolve_item(self.signature());
2264-
if function_item.is_blacklisted(ctx) {
2265-
// We shouldn't emit a method declaration if the function is blacklisted
2264+
if function_item.is_blocklisted(ctx) {
2265+
// We shouldn't emit a method declaration if the function is blocklisted
22662266
return;
22672267
}
22682268
function_item.codegen(ctx, result, &());

src/ir/analysis/derive.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ 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!(
143-
" cannot derive {} for blacklisted type",
143+
" cannot derive {} for blocklisted type",
144144
self.derive_trait
145145
);
146146
return CanDerive::No;
@@ -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
644-
// blacklisted items.
643+
// The transitive closure of all allowlisted items, including explicitly
644+
// blocklisted 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 {

src/ir/analysis/has_float.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<'ctx> MonotoneFramework for HasFloat<'ctx> {
9494
}
9595

9696
fn initial_worklist(&self) -> Vec<ItemId> {
97-
self.ctx.whitelisted_items().iter().cloned().collect()
97+
self.ctx.allowlisted_items().iter().cloned().collect()
9898
}
9999

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

src/ir/analysis/has_type_param_in_array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'ctx> MonotoneFramework for HasTypeParameterInArray<'ctx> {
100100
}
101101

102102
fn initial_worklist(&self) -> Vec<ItemId> {
103-
self.ctx.whitelisted_items().iter().cloned().collect()
103+
self.ctx.allowlisted_items().iter().cloned().collect()
104104
}
105105

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

src/ir/analysis/has_vtable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'ctx> MonotoneFramework for HasVtableAnalysis<'ctx> {
147147
}
148148

149149
fn initial_worklist(&self) -> Vec<ItemId> {
150-
self.ctx.whitelisted_items().iter().cloned().collect()
150+
self.ctx.allowlisted_items().iter().cloned().collect()
151151
}
152152

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

src/ir/analysis/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ where
183183
{
184184
let mut dependencies = HashMap::default();
185185

186-
for &item in ctx.whitelisted_items() {
186+
for &item in ctx.allowlisted_items() {
187187
dependencies.entry(item).or_insert(vec![]);
188188

189189
{
@@ -192,7 +192,7 @@ where
192192
item.trace(
193193
ctx,
194194
&mut |sub_item: ItemId, edge_kind| {
195-
if ctx.whitelisted_items().contains(&sub_item) &&
195+
if ctx.allowlisted_items().contains(&sub_item) &&
196196
consider_edge(edge_kind)
197197
{
198198
dependencies

src/ir/analysis/sizedness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl<'ctx> MonotoneFramework for SizednessAnalysis<'ctx> {
194194

195195
fn initial_worklist(&self) -> Vec<TypeId> {
196196
self.ctx
197-
.whitelisted_items()
197+
.allowlisted_items()
198198
.iter()
199199
.cloned()
200200
.filter_map(|id| id.as_type_id(self.ctx))

0 commit comments

Comments
 (0)