summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcel Hlopko <hlopko@google.com>2021-02-11 08:58:46 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2021-02-18 17:25:13 +0100
commit0e25962c4e69aef647e7275fa7bc7545dbb8cd0b (patch)
treef51e49624d79a707069bbfdeb0f15b78219cec94 /src
parente59aa9218b0e862cbaed319582bf0b692dfacde2 (diff)
Rename whitelist -> allowlist and blacklist -> blocklist
For the commandline arguments I added undocumented aliases to old flags, to stay backwards compatible.
Diffstat (limited to 'src')
-rw-r--r--src/codegen/impl_debug.rs4
-rw-r--r--src/codegen/mod.rs10
-rw-r--r--src/ir/analysis/derive.rs10
-rw-r--r--src/ir/analysis/has_destructor.rs2
-rw-r--r--src/ir/analysis/has_float.rs2
-rw-r--r--src/ir/analysis/has_type_param_in_array.rs2
-rw-r--r--src/ir/analysis/has_vtable.rs2
-rw-r--r--src/ir/analysis/mod.rs4
-rw-r--r--src/ir/analysis/sizedness.rs2
-rw-r--r--src/ir/analysis/template_params.rs60
-rw-r--r--src/ir/context.rs136
-rw-r--r--src/ir/dot.rs6
-rw-r--r--src/ir/enum_ty.rs2
-rw-r--r--src/ir/item.rs44
-rw-r--r--src/ir/template.rs4
-rw-r--r--src/ir/traversal.rs4
-rw-r--r--src/lib.rs213
-rw-r--r--src/options.rs83
18 files changed, 321 insertions, 269 deletions
diff --git a/src/codegen/impl_debug.rs b/src/codegen/impl_debug.rs
index ed1a5e25..b8fdd0d4 100644
--- a/src/codegen/impl_debug.rs
+++ b/src/codegen/impl_debug.rs
@@ -120,9 +120,9 @@ impl<'a> ImplDebug<'a> for Item {
) -> Option<(String, Vec<proc_macro2::TokenStream>)> {
let name_ident = ctx.rust_ident(name);
- // We don't know if blacklisted items `impl Debug` or not, so we can't
+ // We don't know if blocklisted items `impl Debug` or not, so we can't
// add them to the format string we're building up.
- if !ctx.whitelisted_items().contains(&self.id()) {
+ if !ctx.allowlisted_items().contains(&self.id()) {
return None;
}
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 6a7660f6..62271acf 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -443,7 +443,7 @@ impl CodeGenerator for Item {
return;
}
- if self.is_blacklisted(ctx) || result.seen(self.id()) {
+ if self.is_blocklisted(ctx) || result.seen(self.id()) {
debug!(
"<Item as CodeGenerator>::codegen: Ignoring hidden or seen: \
self = {:?}",
@@ -457,7 +457,7 @@ impl CodeGenerator for Item {
// TODO(emilio, #453): Figure out what to do when this happens
// legitimately, we could track the opaque stuff and disable the
// assertion there I guess.
- warn!("Found non-whitelisted item in code generation: {:?}", self);
+ warn!("Found non-allowlisted item in code generation: {:?}", self);
}
result.set_seen(self.id());
@@ -725,7 +725,7 @@ impl CodeGenerator for Type {
// These items don't need code generation, they only need to be
// converted to rust types in fields, arguments, and such.
// NOTE(emilio): If you add to this list, make sure to also add
- // it to BindgenContext::compute_whitelisted_and_codegen_items.
+ // it to BindgenContext::compute_allowlisted_and_codegen_items.
return;
}
TypeKind::TemplateInstantiation(ref inst) => {
@@ -2261,8 +2261,8 @@ impl MethodCodegen for Method {
// First of all, output the actual function.
let function_item = ctx.resolve_item(self.signature());
- if function_item.is_blacklisted(ctx) {
- // We shouldn't emit a method declaration if the function is blacklisted
+ if function_item.is_blocklisted(ctx) {
+ // We shouldn't emit a method declaration if the function is blocklisted
return;
}
function_item.codegen(ctx, result, &());
diff --git a/src/ir/analysis/derive.rs b/src/ir/analysis/derive.rs
index 6c50fa6c..fa4ce795 100644
--- a/src/ir/analysis/derive.rs
+++ b/src/ir/analysis/derive.rs
@@ -138,9 +138,9 @@ impl<'ctx> CannotDerive<'ctx> {
}
fn constrain_type(&mut self, item: &Item, ty: &Type) -> CanDerive {
- if !self.ctx.whitelisted_items().contains(&item.id()) {
+ if !self.ctx.allowlisted_items().contains(&item.id()) {
trace!(
- " cannot derive {} for blacklisted type",
+ " cannot derive {} for blocklisted type",
self.derive_trait
);
return CanDerive::No;
@@ -640,10 +640,10 @@ impl<'ctx> MonotoneFramework for CannotDerive<'ctx> {
}
fn initial_worklist(&self) -> Vec<ItemId> {
- // The transitive closure of all whitelisted items, including explicitly
- // blacklisted items.
+ // The transitive closure of all allowlisted items, including explicitly
+ // blocklisted items.
self.ctx
- .whitelisted_items()
+ .allowlisted_items()
.iter()
.cloned()
.flat_map(|i| {
diff --git a/src/ir/analysis/has_destructor.rs b/src/ir/analysis/has_destructor.rs
index ca4f2532..5fa22e3f 100644
--- a/src/ir/analysis/has_destructor.rs
+++ b/src/ir/analysis/has_destructor.rs
@@ -83,7 +83,7 @@ impl<'ctx> MonotoneFramework for HasDestructorAnalysis<'ctx> {
}
fn initial_worklist(&self) -> Vec<ItemId> {
- self.ctx.whitelisted_items().iter().cloned().collect()
+ self.ctx.allowlisted_items().iter().cloned().collect()
}
fn constrain(&mut self, id: ItemId) -> ConstrainResult {
diff --git a/src/ir/analysis/has_float.rs b/src/ir/analysis/has_float.rs
index d21e651d..bbf2126f 100644
--- a/src/ir/analysis/has_float.rs
+++ b/src/ir/analysis/has_float.rs
@@ -94,7 +94,7 @@ impl<'ctx> MonotoneFramework for HasFloat<'ctx> {
}
fn initial_worklist(&self) -> Vec<ItemId> {
- self.ctx.whitelisted_items().iter().cloned().collect()
+ self.ctx.allowlisted_items().iter().cloned().collect()
}
fn constrain(&mut self, id: ItemId) -> ConstrainResult {
diff --git a/src/ir/analysis/has_type_param_in_array.rs b/src/ir/analysis/has_type_param_in_array.rs
index ebdb7e34..aa523047 100644
--- a/src/ir/analysis/has_type_param_in_array.rs
+++ b/src/ir/analysis/has_type_param_in_array.rs
@@ -100,7 +100,7 @@ impl<'ctx> MonotoneFramework for HasTypeParameterInArray<'ctx> {
}
fn initial_worklist(&self) -> Vec<ItemId> {
- self.ctx.whitelisted_items().iter().cloned().collect()
+ self.ctx.allowlisted_items().iter().cloned().collect()
}
fn constrain(&mut self, id: ItemId) -> ConstrainResult {
diff --git a/src/ir/analysis/has_vtable.rs b/src/ir/analysis/has_vtable.rs
index d2a57d5a..7f5f9117 100644
--- a/src/ir/analysis/has_vtable.rs
+++ b/src/ir/analysis/has_vtable.rs
@@ -147,7 +147,7 @@ impl<'ctx> MonotoneFramework for HasVtableAnalysis<'ctx> {
}
fn initial_worklist(&self) -> Vec<ItemId> {
- self.ctx.whitelisted_items().iter().cloned().collect()
+ self.ctx.allowlisted_items().iter().cloned().collect()
}
fn constrain(&mut self, id: ItemId) -> ConstrainResult {
diff --git a/src/ir/analysis/mod.rs b/src/ir/analysis/mod.rs
index 2cb021f0..ec4d20f9 100644
--- a/src/ir/analysis/mod.rs
+++ b/src/ir/analysis/mod.rs
@@ -183,7 +183,7 @@ where
{
let mut dependencies = HashMap::default();
- for &item in ctx.whitelisted_items() {
+ for &item in ctx.allowlisted_items() {
dependencies.entry(item).or_insert(vec![]);
{
@@ -192,7 +192,7 @@ where
item.trace(
ctx,
&mut |sub_item: ItemId, edge_kind| {
- if ctx.whitelisted_items().contains(&sub_item) &&
+ if ctx.allowlisted_items().contains(&sub_item) &&
consider_edge(edge_kind)
{
dependencies
diff --git a/src/ir/analysis/sizedness.rs b/src/ir/analysis/sizedness.rs
index d8bced72..a3ef7531 100644
--- a/src/ir/analysis/sizedness.rs
+++ b/src/ir/analysis/sizedness.rs
@@ -194,7 +194,7 @@ impl<'ctx> MonotoneFramework for SizednessAnalysis<'ctx> {
fn initial_worklist(&self) -> Vec<TypeId> {
self.ctx
- .whitelisted_items()
+ .allowlisted_items()
.iter()
.cloned()
.filter_map(|id| id.as_type_id(self.ctx))
diff --git a/src/ir/analysis/template_params.rs b/src/ir/analysis/template_params.rs
index f0d9b5e8..c2f18b1f 100644
--- a/src/ir/analysis/template_params.rs
+++ b/src/ir/analysis/template_params.rs
@@ -137,13 +137,13 @@ use crate::{HashMap, HashSet};
/// analysis. If we didn't, then we would mistakenly determine that ever
/// template parameter is always used.
///
-/// The final wrinkle is handling of blacklisted types. Normally, we say that
-/// the set of whitelisted items is the transitive closure of items explicitly
-/// called out for whitelisting, *without* any items explicitly called out as
-/// blacklisted. However, for the purposes of this analysis's correctness, we
+/// The final wrinkle is handling of blocklisted types. Normally, we say that
+/// the set of allowlisted items is the transitive closure of items explicitly
+/// called out for allowlisting, *without* any items explicitly called out as
+/// blocklisted. However, for the purposes of this analysis's correctness, we
/// simplify and consider run the analysis on the full transitive closure of
-/// whitelisted items. We do, however, treat instantiations of blacklisted items
-/// specially; see `constrain_instantiation_of_blacklisted_template` and its
+/// allowlisted items. We do, however, treat instantiations of blocklisted items
+/// specially; see `constrain_instantiation_of_blocklisted_template` and its
/// documentation for details.
#[derive(Debug, Clone)]
pub struct UsedTemplateParameters<'ctx> {
@@ -155,10 +155,10 @@ pub struct UsedTemplateParameters<'ctx> {
dependencies: HashMap<ItemId, Vec<ItemId>>,
- // The set of whitelisted items, without any blacklisted items reachable
- // from the whitelisted items which would otherwise be considered
- // whitelisted as well.
- whitelisted_items: HashSet<ItemId>,
+ // The set of allowlisted items, without any blocklisted items reachable
+ // from the allowlisted items which would otherwise be considered
+ // allowlisted as well.
+ allowlisted_items: HashSet<ItemId>,
}
impl<'ctx> UsedTemplateParameters<'ctx> {
@@ -221,19 +221,19 @@ impl<'ctx> UsedTemplateParameters<'ctx> {
)
}
- /// We say that blacklisted items use all of their template parameters. The
- /// blacklisted type is most likely implemented explicitly by the user,
+ /// We say that blocklisted items use all of their template parameters. The
+ /// blocklisted type is most likely implemented explicitly by the user,
/// since it won't be in the generated bindings, and we don't know exactly
/// what they'll to with template parameters, but we can push the issue down
/// the line to them.
- fn constrain_instantiation_of_blacklisted_template(
+ fn constrain_instantiation_of_blocklisted_template(
&self,
this_id: ItemId,
used_by_this_id: &mut ItemSet,
instantiation: &TemplateInstantiation,
) {
trace!(
- " instantiation of blacklisted template, uses all template \
+ " instantiation of blocklisted template, uses all template \
arguments"
);
@@ -379,10 +379,10 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> {
fn new(ctx: &'ctx BindgenContext) -> UsedTemplateParameters<'ctx> {
let mut used = HashMap::default();
let mut dependencies = HashMap::default();
- let whitelisted_items: HashSet<_> =
- ctx.whitelisted_items().iter().cloned().collect();
+ let allowlisted_items: HashSet<_> =
+ ctx.allowlisted_items().iter().cloned().collect();
- let whitelisted_and_blacklisted_items: ItemSet = whitelisted_items
+ let allowlisted_and_blocklisted_items: ItemSet = allowlisted_items
.iter()
.cloned()
.flat_map(|i| {
@@ -398,7 +398,7 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> {
})
.collect();
- for item in whitelisted_and_blacklisted_items {
+ for item in allowlisted_and_blocklisted_items {
dependencies.entry(item).or_insert(vec![]);
used.entry(item).or_insert(Some(ItemSet::new()));
@@ -457,17 +457,17 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> {
}
if cfg!(feature = "testing_only_extra_assertions") {
- // Invariant: The `used` map has an entry for every whitelisted
- // item, as well as all explicitly blacklisted items that are
- // reachable from whitelisted items.
+ // Invariant: The `used` map has an entry for every allowlisted
+ // item, as well as all explicitly blocklisted items that are
+ // reachable from allowlisted items.
//
// Invariant: the `dependencies` map has an entry for every
- // whitelisted item.
+ // allowlisted item.
//
// (This is so that every item we call `constrain` on is guaranteed
// to have a set of template parameters, and we can allow
- // blacklisted templates to use all of their parameters).
- for item in whitelisted_items.iter() {
+ // blocklisted templates to use all of their parameters).
+ for item in allowlisted_items.iter() {
extra_assert!(used.contains_key(item));
extra_assert!(dependencies.contains_key(item));
item.trace(
@@ -485,15 +485,15 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> {
ctx: ctx,
used: used,
dependencies: dependencies,
- whitelisted_items: whitelisted_items,
+ allowlisted_items: allowlisted_items,
}
}
fn initial_worklist(&self) -> Vec<ItemId> {
- // The transitive closure of all whitelisted items, including explicitly
- // blacklisted items.
+ // The transitive closure of all allowlisted items, including explicitly
+ // blocklisted items.
self.ctx
- .whitelisted_items()
+ .allowlisted_items()
.iter()
.cloned()
.flat_map(|i| {
@@ -538,7 +538,7 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> {
// template definition uses the corresponding template parameter.
Some(&TypeKind::TemplateInstantiation(ref inst)) => {
if self
- .whitelisted_items
+ .allowlisted_items
.contains(&inst.template_definition().into())
{
self.constrain_instantiation(
@@ -547,7 +547,7 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> {
inst,
);
} else {
- self.constrain_instantiation_of_blacklisted_template(
+ self.constrain_instantiation_of_blocklisted_template(
id,
&mut used_by_this_id,
inst,
diff --git a/src/ir/context.rs b/src/ir/context.rs
index 0207547a..6a0f07d9 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -376,14 +376,14 @@ pub struct BindgenContext {
/// Whether a bindgen complex was generated
generated_bindgen_complex: Cell<bool>,
- /// The set of `ItemId`s that are whitelisted. This the very first thing
+ /// The set of `ItemId`s that are allowlisted. This the very first thing
/// computed after parsing our IR, and before running any of our analyses.
- whitelisted: Option<ItemSet>,
+ allowlisted: Option<ItemSet>,
- /// The set of `ItemId`s that are whitelisted for code generation _and_ that
+ /// The set of `ItemId`s that are allowlisted for code generation _and_ that
/// we should generate accounting for the codegen options.
///
- /// It's computed right after computing the whitelisted items.
+ /// It's computed right after computing the allowlisted items.
codegen_items: Option<ItemSet>,
/// Map from an item's id to the set of template parameter items that it
@@ -463,8 +463,8 @@ pub struct BindgenContext {
has_float: Option<HashSet<ItemId>>,
}
-/// A traversal of whitelisted items.
-struct WhitelistedItemsTraversal<'ctx> {
+/// A traversal of allowlisted items.
+struct AllowlistedItemsTraversal<'ctx> {
ctx: &'ctx BindgenContext,
traversal: ItemTraversal<
'ctx,
@@ -474,14 +474,14 @@ struct WhitelistedItemsTraversal<'ctx> {
>,
}
-impl<'ctx> Iterator for WhitelistedItemsTraversal<'ctx> {
+impl<'ctx> Iterator for AllowlistedItemsTraversal<'ctx> {
type Item = ItemId;
fn next(&mut self) -> Option<ItemId> {
loop {
let id = self.traversal.next()?;
- if self.ctx.resolve_item(id).is_blacklisted(self.ctx) {
+ if self.ctx.resolve_item(id).is_blocklisted(self.ctx) {
continue;
}
@@ -490,8 +490,8 @@ impl<'ctx> Iterator for WhitelistedItemsTraversal<'ctx> {
}
}
-impl<'ctx> WhitelistedItemsTraversal<'ctx> {
- /// Construct a new whitelisted items traversal.
+impl<'ctx> AllowlistedItemsTraversal<'ctx> {
+ /// Construct a new allowlisted items traversal.
pub fn new<R>(
ctx: &'ctx BindgenContext,
roots: R,
@@ -500,7 +500,7 @@ impl<'ctx> WhitelistedItemsTraversal<'ctx> {
where
R: IntoIterator<Item = ItemId>,
{
- WhitelistedItemsTraversal {
+ AllowlistedItemsTraversal {
ctx,
traversal: ItemTraversal::new(ctx, roots, predicate),
}
@@ -559,7 +559,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
target_info,
options,
generated_bindgen_complex: Cell::new(false),
- whitelisted: None,
+ allowlisted: None,
codegen_items: None,
used_template_parameters: None,
need_bitfield_allocation: Default::default(),
@@ -718,8 +718,8 @@ If you encounter an error missing from this list, please file an issue or a PR!"
}
/// Ensure that every item (other than the root module) is in a module's
- /// children list. This is to make sure that every whitelisted item get's
- /// codegen'd, even if its parent is not whitelisted. See issue #769 for
+ /// children list. This is to make sure that every allowlisted item get's
+ /// codegen'd, even if its parent is not allowlisted. See issue #769 for
/// details.
fn add_item_to_module(&mut self, item: &Item) {
assert!(item.id() != self.root_module);
@@ -1024,7 +1024,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
_ => continue,
}
- let path = item.path_for_whitelisting(self);
+ let path = item.path_for_allowlisting(self);
let replacement = self.replacements.get(&path[1..]);
if let Some(replacement) = replacement {
@@ -1134,10 +1134,10 @@ If you encounter an error missing from this list, please file an issue or a PR!"
self.assert_no_dangling_references();
- // Compute the whitelisted set after processing replacements and
+ // Compute the allowlisted set after processing replacements and
// resolving type refs, as those are the final mutations of the IR
// graph, and their completion means that the IR graph is now frozen.
- self.compute_whitelisted_and_codegen_items();
+ self.compute_allowlisted_and_codegen_items();
// Make sure to do this after processing replacements, since that messes
// with the parentage and module children, and we want to assert that it
@@ -1293,14 +1293,14 @@ If you encounter an error missing from this list, please file an issue or a PR!"
fn find_used_template_parameters(&mut self) {
let _t = self.timer("find_used_template_parameters");
- if self.options.whitelist_recursively {
+ if self.options.allowlist_recursively {
let used_params = analyze::<UsedTemplateParameters>(self);
self.used_template_parameters = Some(used_params);
} else {
- // If you aren't recursively whitelisting, then we can't really make
+ // If you aren't recursively allowlisting, then we can't really make
// any sense of template parameter usage, and you're on your own.
let mut used_params = HashMap::default();
- for &id in self.whitelisted_items() {
+ for &id in self.allowlisted_items() {
used_params.entry(id).or_insert(
id.self_template_params(self)
.into_iter()
@@ -1319,9 +1319,9 @@ If you encounter an error missing from this list, please file an issue or a PR!"
/// template usage information is only computed as we enter the codegen
/// phase.
///
- /// If the item is blacklisted, then we say that it always uses the template
+ /// If the item is blocklisted, then we say that it always uses the template
/// parameter. This is a little subtle. The template parameter usage
- /// analysis only considers whitelisted items, and if any blacklisted item
+ /// analysis only considers allowlisted items, and if any blocklisted item
/// shows up in the generated bindings, it is the user's responsibility to
/// manually provide a definition for them. To give them the most
/// flexibility when doing that, we assume that they use every template
@@ -1336,7 +1336,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
"We only compute template parameter usage as we enter codegen"
);
- if self.resolve_item(item).is_blacklisted(self) {
+ if self.resolve_item(item).is_blocklisted(self) {
return true;
}
@@ -2194,15 +2194,15 @@ If you encounter an error missing from this list, please file an issue or a PR!"
self.current_module = previous_id;
}
- /// Iterate over all (explicitly or transitively) whitelisted items.
+ /// Iterate over all (explicitly or transitively) allowlisted items.
///
- /// If no items are explicitly whitelisted, then all items are considered
- /// whitelisted.
- pub fn whitelisted_items(&self) -> &ItemSet {
+ /// If no items are explicitly allowlisted, then all items are considered
+ /// allowlisted.
+ pub fn allowlisted_items(&self) -> &ItemSet {
assert!(self.in_codegen_phase());
assert!(self.current_module == self.root_module);
- self.whitelisted.as_ref().unwrap()
+ self.allowlisted.as_ref().unwrap()
}
/// Get a reference to the set of items we should generate.
@@ -2212,12 +2212,12 @@ If you encounter an error missing from this list, please file an issue or a PR!"
self.codegen_items.as_ref().unwrap()
}
- /// Compute the whitelisted items set and populate `self.whitelisted`.
- fn compute_whitelisted_and_codegen_items(&mut self) {
+ /// Compute the allowlisted items set and populate `self.allowlisted`.
+ fn compute_allowlisted_and_codegen_items(&mut self) {
assert!(self.in_codegen_phase());
assert!(self.current_module == self.root_module);
- assert!(self.whitelisted.is_none());
- let _t = self.timer("compute_whitelisted_and_codegen_items");
+ assert!(self.allowlisted.is_none());
+ let _t = self.timer("compute_allowlisted_and_codegen_items");
let roots = {
let mut roots = self
@@ -2225,11 +2225,11 @@ If you encounter an error missing from this list, please file an issue or a PR!"
// Only consider roots that are enabled for codegen.
.filter(|&(_, item)| item.is_enabled_for_codegen(self))
.filter(|&(_, item)| {
- // If nothing is explicitly whitelisted, then everything is fair
+ // If nothing is explicitly allowlisted, then everything is fair
// game.
- if self.options().whitelisted_types.is_empty() &&
- self.options().whitelisted_functions.is_empty() &&
- self.options().whitelisted_vars.is_empty()
+ if self.options().allowlisted_types.is_empty() &&
+ self.options().allowlisted_functions.is_empty() &&
+ self.options().allowlisted_vars.is_empty()
{
return true;
}
@@ -2240,25 +2240,25 @@ If you encounter an error missing from this list, please file an issue or a PR!"
return true;
}
- let name = item.path_for_whitelisting(self)[1..].join("::");
- debug!("whitelisted_items: testing {:?}", name);
+ let name = item.path_for_allowlisting(self)[1..].join("::");
+ debug!("allowlisted_items: testing {:?}", name);
match *item.kind() {
ItemKind::Module(..) => true,
ItemKind::Function(_) => {
- self.options().whitelisted_functions.matches(&name)
+ self.options().allowlisted_functions.matches(&name)
}
ItemKind::Var(_) => {
- self.options().whitelisted_vars.matches(&name)
+ self.options().allowlisted_vars.matches(&name)
}
ItemKind::Type(ref ty) => {
- if self.options().whitelisted_types.matches(&name) {
+ if self.options().allowlisted_types.matches(&name) {
return true;
}
- // Auto-whitelist types that don't need code
- // generation if not whitelisting recursively, to
+ // Auto-allowlist types that don't need code
+ // generation if not allowlisting recursively, to
// make the #[derive] analysis not be lame.
- if !self.options().whitelist_recursively {
+ if !self.options().allowlist_recursively {
match *ty.kind() {
TypeKind::Void |
TypeKind::NullPtr |
@@ -2278,7 +2278,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
}
// Unnamed top-level enums are special and we
- // whitelist them via the `whitelisted_vars` filter,
+ // allowlist them via the `allowlisted_vars` filter,
// since they're effectively top-level constants,
// and there's no way for them to be referenced
// consistently.
@@ -2297,12 +2297,12 @@ If you encounter an error missing from this list, please file an issue or a PR!"
}
let mut prefix_path =
- parent.path_for_whitelisting(self).clone();
+ parent.path_for_allowlisting(self).clone();
enum_.variants().iter().any(|variant| {
prefix_path.push(variant.name().into());
let name = prefix_path[1..].join("::");
prefix_path.pop().unwrap();
- self.options().whitelisted_vars.matches(&name)
+ self.options().allowlisted_vars.matches(&name)
})
}
}
@@ -2317,48 +2317,48 @@ If you encounter an error missing from this list, please file an issue or a PR!"
roots
};
- let whitelisted_items_predicate =
- if self.options().whitelist_recursively {
+ let allowlisted_items_predicate =
+ if self.options().allowlist_recursively {
traversal::all_edges
} else {
- // Only follow InnerType edges from the whitelisted roots.
+ // Only follow InnerType edges from the allowlisted roots.
// Such inner types (e.g. anonymous structs/unions) are
- // always emitted by codegen, and they need to be whitelisted
+ // always emitted by codegen, and they need to be allowlisted
// to make sure they are processed by e.g. the derive analysis.
traversal::only_inner_type_edges
};
- let whitelisted = WhitelistedItemsTraversal::new(
+ let allowlisted = AllowlistedItemsTraversal::new(
self,
roots.clone(),
- whitelisted_items_predicate,
+ allowlisted_items_predicate,
)
.collect::<ItemSet>();
- let codegen_items = if self.options().whitelist_recursively {
- WhitelistedItemsTraversal::new(
+ let codegen_items = if self.options().allowlist_recursively {
+ AllowlistedItemsTraversal::new(
self,
roots.clone(),
traversal::codegen_edges,
)
.collect::<ItemSet>()
} else {
- whitelisted.clone()
+ allowlisted.clone()
};
- self.whitelisted = Some(whitelisted);
+ self.allowlisted = Some(allowlisted);
self.codegen_items = Some(codegen_items);
- for item in self.options().whitelisted_functions.unmatched_items() {
- warn!("unused option: --whitelist-function {}", item);
+ for item in self.options().allowlisted_functions.unmatched_items() {
+ warn!("unused option: --allowlist-function {}", item);
}
- for item in self.options().whitelisted_vars.unmatched_items() {
- warn!("unused option: --whitelist-var {}", item);
+ for item in self.options().allowlisted_vars.unmatched_items() {
+ warn!("unused option: --allowlist-var {}", item);
}
- for item in self.options().whitelisted_types.unmatched_items() {
- warn!("unused option: --whitelist-type {}", item);
+ for item in self.options().allowlisted_types.unmatched_items() {
+ warn!("unused option: --allowlist-type {}", item);
}
}
@@ -2575,31 +2575,31 @@ If you encounter an error missing from this list, please file an issue or a PR!"
/// Check if `--no-partialeq` flag is enabled for this item.
pub fn no_partialeq_by_name(&self, item: &Item) -> bool {
- let name = item.path_for_whitelisting(self)[1..].join("::");
+ let name = item.path_for_allowlisting(self)[1..].join("::");
self.options().no_partialeq_types.matches(&name)
}
/// Check if `--no-copy` flag is enabled for this item.
pub fn no_copy_by_name(&self, item: &Item) -> bool {
- let name = item.path_for_whitelisting(self)[1..].join("::");
+ let name = item.path_for_allowlisting(self)[1..].join("::");
self.options().no_copy_types.matches(&name)
}
/// Check if `--no-debug` flag is enabled for this item.
pub fn no_debug_by_name(&self, item: &Item) -> bool {
- let name = item.path_for_whitelisting(self)[1..].join("::");
+ let name = item.path_for_allowlisting(self)[1..].join("::");
self.options().no_debug_types.matches(&name)
}
/// Check if `--no-default` flag is enabled for this item.
pub fn no_default_by_name(&self, item: &Item) -> bool {
- let name = item.path_for_whitelisting(self)[1..].join("::");
+ let name = item.path_for_allowlisting(self)[1..].join("::");
self.options().no_default_types.matches(&name)
}
/// Check if `--no-hash` flag is enabled for this item.
pub fn no_hash_by_name(&self, item: &Item) -> bool {
- let name = item.path_for_whitelisting(self)[1..].join("::");
+ let name = item.path_for_allowlisting(self)[1..].join("::");
self.options().no_hash_types.matches(&name)
}
}
diff --git a/src/ir/dot.rs b/src/ir/dot.rs
index 6bf75bfa..f7d07f19 100644
--- a/src/ir/dot.rs
+++ b/src/ir/dot.rs
@@ -32,13 +32,13 @@ where
let mut err: Option<io::Result<_>> = None;
for (id, item) in ctx.items() {
- let is_whitelisted = ctx.whitelisted_items().contains(&id);
+ let is_allowlisted = ctx.allowlisted_items().contains(&id);
writeln!(
&mut dot_file,
r#"{} [fontname="courier", color={}, label=< <table border="0" align="left">"#,
id.as_usize(),
- if is_whitelisted { "black" } else { "gray" }
+ if is_allowlisted { "black" } else { "gray" }
)?;
item.dot_attributes(ctx, &mut dot_file)?;
writeln!(&mut dot_file, r#"</table> >];"#)?;
@@ -56,7 +56,7 @@ where
id.as_usize(),
sub_id.as_usize(),
edge_kind,
- if is_whitelisted { "black" } else { "gray" }
+ if is_allowlisted { "black" } else { "gray" }
) {
Ok(_) => {}
Err(e) => err = Some(Err(e)),
diff --git a/src/ir/enum_ty.rs b/src/ir/enum_ty.rs
index dde4bb18..c6cd89ce 100644
--- a/src/ir/enum_ty.rs
+++ b/src/ir/enum_ty.rs
@@ -152,7 +152,7 @@ impl Enum {
enums: &RegexSet,
item: &Item,
) -> bool {
- let path = item.path_for_whitelisting(ctx);
+ let path = item.path_for_allowlisting(ctx);
let enum_ty = item.expect_type();
if enums.matches(&path[1..].join("::")) {
diff --git a/src/ir/item.rs b/src/ir/item.rs
index e9abed70..45415045 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -273,10 +273,10 @@ impl Trace for Item {
where
T: Tracer,
{
- // Even if this item is blacklisted/hidden, we want to trace it. It is
+ // Even if this item is blocklisted/hidden, we want to trace it. It is
// traversal iterators' consumers' responsibility to filter items as
// needed. Generally, this filtering happens in the implementation of
- // `Iterator` for `WhitelistedItems`. Fully tracing blacklisted items is
+ // `Iterator` for `allowlistedItems`. Fully tracing blocklisted items is
// necessary for things like the template parameter usage analysis to
// function correctly.
@@ -301,12 +301,12 @@ impl Trace for Item {
}
ItemKind::Module(_) => {
// Module -> children edges are "weak", and we do not want to
- // trace them. If we did, then whitelisting wouldn't work as
+ // trace them. If we did, then allowlisting wouldn't work as
// expected: everything in every module would end up
- // whitelisted.
+ // allowlisted.
//
// TODO: make a new edge kind for module -> children edges and
- // filter them during whitelisting traversals.
+ // filter them during allowlisting traversals.
}
}
}
@@ -400,9 +400,9 @@ pub struct Item {
/// considerably faster in those cases.
canonical_name: LazyCell<String>,
- /// The path to use for whitelisting and other name-based checks, as
- /// returned by `path_for_whitelisting`, lazily constructed.
- path_for_whitelisting: LazyCell<Vec<String>>,
+ /// The path to use for allowlisting and other name-based checks, as
+ /// returned by `path_for_allowlisting`, lazily constructed.
+ path_for_allowlisting: LazyCell<Vec<String>>,
/// A doc comment over the item, if any.
comment: Option<String>,
@@ -440,7 +440,7 @@ impl Item {
local_id: LazyCell::new(),
next_child_local_id: Cell::new(1),
canonical_name: LazyCell::new(),
- path_for_whitelisting: LazyCell::new(),
+ path_for_allowlisting: LazyCell::new(),
parent_id: parent_id,
comment: comment,
annotations: annotations.unwrap_or_default(),
@@ -623,10 +623,10 @@ impl Item {
&self.annotations
}
- /// Whether this item should be blacklisted.
+ /// Whether this item should be blocklisted.
///
/// This may be due to either annotations or to other kind of configuration.
- pub fn is_blacklisted(&self, ctx: &BindgenContext) -> bool {
+ pub fn is_blocklisted(&self, ctx: &BindgenContext) -> bool {
debug_assert!(
ctx.in_codegen_phase(),
"You're not supposed to call this yet"
@@ -635,18 +635,18 @@ impl Item {
return true;
}
- let path = self.path_for_whitelisting(ctx);
+ let path = self.path_for_allowlisting(ctx);
let name = path[1..].join("::");
- ctx.options().blacklisted_items.matches(&name) ||
+ ctx.options().blocklisted_items.matches(&name) ||
match self.kind {
ItemKind::Type(..) => {
- ctx.options().blacklisted_types.matches(&name) ||
+ ctx.options().blocklisted_types.matches(&name) ||
ctx.is_replaced_type(&path, self.id)
}
ItemKind::Function(..) => {
- ctx.options().blacklisted_functions.matches(&name)
+ ctx.options().blocklisted_functions.matches(&name)
}
- // TODO: Add constant / namespace blacklisting?
+ // TODO: Add constant / namespace blocklisting?
ItemKind::Var(..) | ItemKind::Module(..) => false,
}
}
@@ -1012,10 +1012,10 @@ impl Item {
}
}
- /// Returns the path we should use for whitelisting / blacklisting, which
+ /// Returns the path we should use for allowlisting / blocklisting, which
/// doesn't include user-mangling.
- pub fn path_for_whitelisting(&self, ctx: &BindgenContext) -> &Vec<String> {
- self.path_for_whitelisting
+ pub fn path_for_allowlisting(&self, ctx: &BindgenContext) -> &Vec<String> {
+ self.path_for_allowlisting
.borrow_with(|| self.compute_path(ctx, UserMangled::No))
}
@@ -1081,7 +1081,7 @@ impl IsOpaque for Item {
);
self.annotations.opaque() ||
self.as_type().map_or(false, |ty| ty.is_opaque(ctx, self)) ||
- ctx.opaque_by_name(&self.path_for_whitelisting(ctx))
+ ctx.opaque_by_name(&self.path_for_allowlisting(ctx))
}
}
@@ -1390,7 +1390,7 @@ impl ClangItemParser for Item {
if cursor.kind() == CXCursor_UnexposedDecl {
Err(ParseError::Recurse)
} else {
- // We whitelist cursors here known to be unhandled, to prevent being
+ // We allowlist cursors here known to be unhandled, to prevent being
// too noisy about this.
match cursor.kind() {
CXCursor_MacroDefinition |
@@ -1918,7 +1918,7 @@ impl ItemCanonicalPath for Item {
/// not.
///
/// Most of the callers probably want just yes, but the ones dealing with
-/// whitelisting and blacklisting don't.
+/// allowlisting and blocklisting don't.
#[derive(Copy, Clone, Debug, PartialEq)]
enum UserMangled {
No,
diff --git a/src/ir/template.rs b/src/ir/template.rs
index 8c625d1d..b519fff1 100644
--- a/src/ir/template.rs
+++ b/src/ir/template.rs
@@ -306,13 +306,13 @@ impl IsOpaque for TemplateInstantiation {
// correct fix is to make `canonical_{name,path}` include template
// arguments properly.
- let mut path = item.path_for_whitelisting(ctx).clone();
+ let mut path = item.path_for_allowlisting(ctx).clone();
let args: Vec<_> = self
.template_arguments()
.iter()
.map(|arg| {
let arg_path =
- ctx.resolve_item(*arg).path_for_whitelisting(ctx);
+ ctx.resolve_item(*arg).path_for_allowlisting(ctx);
arg_path[1..].join("::")
})
.collect();
diff --git a/src/ir/traversal.rs b/src/ir/traversal.rs
index e4a44703..430dd027 100644
--- a/src/ir/traversal.rs
+++ b/src/ir/traversal.rs
@@ -201,7 +201,7 @@ pub fn all_edges(_: &BindgenContext, _: Edge) -> bool {
/// A `TraversalPredicate` implementation that only follows
/// `EdgeKind::InnerType` edges, and therefore traversals using this predicate
/// will only visit the traversal's roots and their inner types. This is used
-/// in no-recursive-whitelist mode, where inner types such as anonymous
+/// in no-recursive-allowlist mode, where inner types such as anonymous
/// structs/unions still need to be processed.
pub fn only_inner_type_edges(_: &BindgenContext, edge: Edge) -> bool {
edge.kind == EdgeKind::InnerType
@@ -377,7 +377,7 @@ pub trait Trace {
/// An graph traversal of the transitive closure of references between items.
///
-/// See `BindgenContext::whitelisted_items` for more information.
+/// See `BindgenContext::allowlisted_items` for more information.
pub struct ItemTraversal<'ctx, Storage, Queue, Predicate>
where
Storage: TraversalStorage<'ctx>,
diff --git a/src/lib.rs b/src/lib.rs
index 06ba8e63..945d3065 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -177,8 +177,8 @@ impl Default for CodegenConfig {
///
/// // Configure and generate bindings.
/// let bindings = builder().header("path/to/input/header")
-/// .whitelist_type("SomeCoolClass")
-/// .whitelist_function("do_some_cool_thing")
+/// .allowlist_type("SomeCoolClass")
+/// .allowlist_function("do_some_cool_thing")
/// .generate()?;
///
/// // Write the generated bindings to an output file.
@@ -304,13 +304,13 @@ impl Builder {
(&self.options.type_alias, "--type-alias"),
(&self.options.new_type_alias, "--new-type-alias"),
(&self.options.new_type_alias_deref, "--new-type-alias-deref"),
- (&self.options.blacklisted_types, "--blacklist-type"),
- (&self.options.blacklisted_functions, "--blacklist-function"),
- (&self.options.blacklisted_items, "--blacklist-item"),
+ (&self.options.blocklisted_types, "--blocklist-type"),
+ (&self.options.blocklisted_functions, "--blocklist-function"),
+ (&self.options.blocklisted_items, "--blocklist-item"),
(&self.options.opaque_types, "--opaque-type"),
- (&self.options.whitelisted_functions, "--whitelist-function"),
- (&self.options.whitelisted_types, "--whitelist-type"),
- (&self.options.whitelisted_vars, "--whitelist-var"),
+ (&self.options.allowlisted_functions, "--allowlist-function"),
+ (&self.options.allowlisted_types, "--allowlist-type"),
+ (&self.options.allowlisted_vars, "--allowlist-var"),
(&self.options.no_partialeq_types, "--no-partialeq"),
(&self.options.no_copy_types, "--no-copy"),
(&self.options.no_debug_types, "--no-debug"),
@@ -379,8 +379,8 @@ impl Builder {
output_vector.push("--no-doc-comments".into());
}
- if !self.options.whitelist_recursively {
- output_vector.push("--no-recursive-whitelist".into());
+ if !self.options.allowlist_recursively {
+ output_vector.push("--no-recursive-allowlist".into());
}
if self.options.objc_extern_crate {
@@ -661,9 +661,9 @@ impl Builder {
self
}
- /// Whether to whitelist recursively or not. Defaults to true.
+ /// Whether to allowlist recursively or not. Defaults to true.
///
- /// Given that we have explicitly whitelisted the "initiate_dance_party"
+ /// Given that we have explicitly allowlisted the "initiate_dance_party"
/// function in this C header:
///
/// ```c
@@ -676,20 +676,20 @@ impl Builder {
///
/// We would normally generate bindings to both the `initiate_dance_party`
/// function and the `MoonBoots` struct that it transitively references. By
- /// configuring with `whitelist_recursively(false)`, `bindgen` will not emit
- /// bindings for anything except the explicitly whitelisted items, and there
+ /// configuring with `allowlist_recursively(false)`, `bindgen` will not emit
+ /// bindings for anything except the explicitly allowlisted items, and there
/// would be no emitted struct definition for `MoonBoots`. However, the
/// `initiate_dance_party` function would still reference `MoonBoots`!
///
/// **Disabling this feature will almost certainly cause `bindgen` to emit
/// bindings that will not compile!** If you disable this feature, then it
/// is *your* responsibility to provide definitions for every type that is
- /// referenced from an explicitly whitelisted item. One way to provide the
+ /// referenced from an explicitly allowlisted item. One way to provide the
/// definitions is by using the [`Builder::raw_line`](#method.raw_line)
/// method, another would be to define them in Rust and then `include!(...)`
/// the bindings immediately afterwards.
- pub fn whitelist_recursively(mut self, doit: bool) -> Self {
- self.options.whitelist_recursively = doit;
+ pub fn allowlist_recursively(mut self, doit: bool) -> Self {
+ self.options.allowlist_recursively = doit;
self
}
@@ -727,30 +727,53 @@ impl Builder {
/// Hide the given type from the generated bindings. Regular expressions are
/// supported.
- #[deprecated(note = "Use blacklist_type instead")]
+ #[deprecated(note = "Use blocklist_type instead")]
pub fn hide_type<T: AsRef<str>>(self, arg: T) -> Builder {
- self.blacklist_type(arg)
+ self.blocklist_type(arg)
+ }
+
+ /// Hide the given type from the generated bindings. Regular expressions are
+ /// supported.
+ #[deprecated(note = "Use blocklist_type instead")]
+ pub fn blacklist_type<T: AsRef<str>>(self, arg: T) -> Builder {
+ self.blocklist_type(arg)
}
/// Hide the given type from the generated bindings. Regular expressions are
/// supported.
///
- /// To blacklist types prefixed with "mylib" use `"mylib_.*"`.
+ /// To blocklist types prefixed with "mylib" use `"mylib_.*"`.
/// For more complicated expressions check
/// [regex](https://docs.rs/regex/*/regex/) docs
- pub fn blacklist_type<T: AsRef<str>>(mut self, arg: T) -> Builder {
- self.options.blacklisted_types.insert(arg);
+ pub fn blocklist_type<T: AsRef<str>>(mut self, arg: T) -> Builder {
+ self.options.blocklisted_types.insert(arg);
self
}
/// Hide the given function from the generated bindings. Regular expressions
/// are supported.
+ #[deprecated(note = "Use blocklist_function instead")]
+ pub fn blacklist_function<T: AsRef<str>>(self, arg: T) -> Builder {
+ self.blocklist_function(arg)
+ }
+
+ /// Hide the given function from the generated bindings. Regular expressions
+ /// are supported.
///
- /// To blacklist functions prefixed with "mylib" use `"mylib_.*"`.
+ /// To blocklist functions prefixed with "mylib" use `"mylib_.*"`.
/// For more complicated expressions check
/// [regex](https://docs.rs/regex/*/regex/) docs
- pub fn blacklist_function<T: AsRef<str>>(mut self, arg: T) -> Builder {
- self.options.blacklisted_functions.insert(arg);
+ pub fn blocklist_function<T: AsRef<str>>(mut self, arg: T) -> Builder {
+ self.options.blocklisted_functions.insert(arg);
+ self
+ }
+
+ /// Hide the given item from the generated bindings, regardless of
+ /// whether it's a type, function, module, etc. Regular
+ /// expressions are supported.
+ #[deprecated(note = "Use blocklist_item instead")]
+ pub fn blacklist_item<T: AsRef<str>>(mut self, arg: T) -> Builder {
+ self.options.blocklisted_items.insert(arg);
self
}
@@ -758,11 +781,11 @@ impl Builder {
/// whether it's a type, function, module, etc. Regular
/// expressions are supported.
///
- /// To blacklist items prefixed with "mylib" use `"mylib_.*"`.
+ /// To blocklist items prefixed with "mylib" use `"mylib_.*"`.
/// For more complicated expressions check
/// [regex](https://docs.rs/regex/*/regex/) docs
- pub fn blacklist_item<T: AsRef<str>>(mut self, arg: T) -> Builder {
- self.options.blacklisted_items.insert(arg);
+ pub fn blocklist_item<T: AsRef<str>>(mut self, arg: T) -> Builder {
+ self.options.blocklisted_items.insert(arg);
self
}
@@ -777,64 +800,86 @@ impl Builder {
self
}
- /// Whitelist the given type so that it (and all types that it transitively
+ /// Allowlist the given type so that it (and all types that it transitively
/// refers to) appears in the generated bindings. Regular expressions are
/// supported.
- #[deprecated(note = "use whitelist_type instead")]
+ #[deprecated(note = "use allowlist_type instead")]
pub fn whitelisted_type<T: AsRef<str>>(self, arg: T) -> Builder {
- self.whitelist_type(arg)
+ self.allowlist_type(arg)
+ }
+
+ /// Allowlist the given type so that it (and all types that it transitively
+ /// refers to) appears in the generated bindings. Regular expressions are
+ /// supported.
+ #[deprecated(note = "use allowlist_type instead")]
+ pub fn whitelist_type<T: AsRef<str>>(self, arg: T) -> Builder {
+ self.allowlist_type(arg)
}
- /// Whitelist the given type so that it (and all types that it transitively
+ /// Allowlist the given type so that it (and all types that it transitively
/// refers to) appears in the generated bindings. Regular expressions are
/// supported.
///
- /// To whitelist types prefixed with "mylib" use `"mylib_.*"`.
+ /// To allowlist types prefixed with "mylib" use `"mylib_.*"`.
/// For more complicated expressions check
/// [regex](https://docs.rs/regex/*/regex/) docs
- pub fn whitelist_type<T: AsRef<str>>(mut self, arg: T) -> Builder {
- self.options.whitelisted_types.insert(arg);
+ pub fn allowlist_type<T: AsRef<str>>(mut self, arg: T) -> Builder {
+ self.options.allowlisted_types.insert(arg);
self
}
- /// Whitelist the given function so that it (and all types that it
+ /// Allowlist the given function so that it (and all types that it
/// transitively refers to) appears in the generated bindings. Regular
/// expressions are supported.
///
- /// To whitelist functions prefixed with "mylib" use `"mylib_.*"`.
+ /// To allowlist functions prefixed with "mylib" use `"mylib_.*"`.
/// For more complicated expressions check
/// [regex](https://docs.rs/regex/*/regex/) docs
- pub fn whitelist_function<T: AsRef<str>>(mut self, arg: T) -> Builder {
- self.options.whitelisted_functions.insert(arg);
+ pub fn allowlist_function<T: AsRef<str>>(mut self, arg: T) -> Builder {
+ self.options.allowlisted_functions.insert(arg);
self
}
- /// Whitelist the given function.
+ /// Allowlist the given function.
+ ///
+ /// Deprecated: use allowlist_function instead.
+ #[deprecated(note = "use allowlist_function instead")]
+ pub fn whitelist_function<T: AsRef<str>>(self, arg: T) -> Builder {
+ self.allowlist_function(arg)
+ }
+
+ /// Allowlist the given function.
///
- /// Deprecated: use whitelist_function instead.
- #[deprecated(note = "use whitelist_function instead")]
+ /// Deprecated: use allowlist_function instead.
+ #[deprecated(note = "use allowlist_function instead")]
pub fn whitelisted_function<T: AsRef<str>>(self, arg: T) -> Builder {
- self.whitelist_function(arg)
+ self.allowlist_function(arg)
}
- /// Whitelist the given variable so that it (and all types that it
+ /// Allowlist the given variable so that it (and all types that it
/// transitively refers to) appears in the generated bindings. Regular
/// expressions are supported.
///
- /// To whitelist variables prefixed with "mylib" use `"mylib_.*"`.
+ /// To allowlist variables prefixed with "mylib" use `"mylib_.*"`.
/// For more complicated expressions check
/// [regex](https://docs.rs/regex/*/regex/) docs
- pub fn whitelist_var<T: AsRef<str>>(mut self, arg: T) -> Builder {
- self.options.whitelisted_vars.insert(arg);
+ pub fn allowlist_var<T: AsRef<str>>(mut self, arg: T) -> Builder {
+ self.options.allowlisted_vars.insert(arg);
self
}
- /// Whitelist the given variable.
+ /// Deprecated: use allowlist_var instead.
+ #[deprecated(note = "use allowlist_var instead")]
+ pub fn whitelist_var<T: AsRef<str>>(self, arg: T) -> Builder {
+ self.allowlist_var(arg)
+ }
+
+ /// Allowlist the given variable.
///
- /// Deprecated: use whitelist_var instead.
- #[deprecated(note = "use whitelist_var instead")]
+ /// Deprecated: use allowlist_var instead.
+ #[deprecated(note = "use allowlist_var instead")]
pub fn whitelisted_var<T: AsRef<str>>(self, arg: T) -> Builder {
- self.whitelist_var(arg)
+ self.allowlist_var(arg)
}
/// Set the default style of code to generate for enums
@@ -1163,7 +1208,7 @@ impl Builder {
/// This method disables that behavior.
///
/// Note that this intentionally does not change the names used for
- /// whitelisting and blacklisting, which should still be mangled with the
+ /// allowlisting and blocklisting, which should still be mangled with the
/// namespaces.
///
/// Note, also, that this option may cause bindgen to generate duplicate
@@ -1533,17 +1578,17 @@ impl Builder {
/// Configuration options for generated bindings.
#[derive(Debug)]
struct BindgenOptions {
- /// The set of types that have been blacklisted and should not appear
+ /// The set of types that have been blocklisted and should not appear
/// anywhere in the generated code.
- blacklisted_types: RegexSet,
+ blocklisted_types: RegexSet,
- /// The set of functions that have been blacklisted and should not appear
+ /// The set of functions that have been blocklisted and should not appear
/// in the generated code.
- blacklisted_functions: RegexSet,
+ blocklisted_functions: RegexSet,
/// The set of items, regardless of item-type, that have been
- /// blacklisted and should not appear in the generated code.
- blacklisted_items: RegexSet,
+ /// blocklisted and should not appear in the generated code.
+ blocklisted_items: RegexSet,
/// The set of types that should be treated as opaque structures in the
/// generated code.
@@ -1556,15 +1601,15 @@ struct BindgenOptions {
/// code.
///
/// This includes all types transitively reachable from any type in this
- /// set. One might think of whitelisted types/vars/functions as GC roots,
+ /// set. One might think of allowlisted types/vars/functions as GC roots,
/// and the generated Rust code as including everything that gets marked.
- whitelisted_types: RegexSet,
+ allowlisted_types: RegexSet,
- /// Whitelisted functions. See docs for `whitelisted_types` for more.
- whitelisted_functions: RegexSet,
+ /// Allowlisted functions. See docs for `allowlisted_types` for more.
+ allowlisted_functions: RegexSet,
- /// Whitelisted variables. See docs for `whitelisted_types` for more.
- whitelisted_vars: RegexSet,
+ /// Allowlisted variables. See docs for `allowlisted_types` for more.
+ allowlisted_vars: RegexSet,
/// The default style of code to generate for enums
default_enum_style: codegen::EnumVariation,
@@ -1736,8 +1781,8 @@ struct BindgenOptions {
/// Whether to generate inline functions. Defaults to false.
generate_inline_functions: bool,
- /// Whether to whitelist types recursively. Defaults to true.
- whitelist_recursively: bool,
+ /// Whether to allowlist types recursively. Defaults to true.
+ allowlist_recursively: bool,
/// Instead of emitting 'use objc;' to files generated from objective c files,
/// generate '#[macro_use] extern crate objc;'
@@ -1777,7 +1822,7 @@ struct BindgenOptions {
/// Whether we should record which items in the regex sets ever matched.
///
- /// This may be a bit slower, but will enable reporting of unused whitelist
+ /// This may be a bit slower, but will enable reporting of unused allowlist
/// items via the `error!` log.
record_matches: bool,
@@ -1829,12 +1874,12 @@ impl ::std::panic::UnwindSafe for BindgenOptions {}
impl BindgenOptions {
fn build(&mut self) {
let mut regex_sets = [
- &mut self.whitelisted_vars,
- &mut self.whitelisted_types,
- &mut self.whitelisted_functions,
- &mut self.blacklisted_types,
- &mut self.blacklisted_functions,
- &mut self.blacklisted_items,
+ &mut self.allowlisted_vars,
+ &mut self.allowlisted_types,
+ &mut self.allowlisted_functions,
+ &mut self.blocklisted_types,
+ &mut self.blocklisted_functions,
+ &mut self.blocklisted_items,
&mut self.opaque_types,
&mut self.bitfield_enums,
&mut self.constified_enums,
@@ -1878,14 +1923,14 @@ impl Default for BindgenOptions {
BindgenOptions {
rust_target,
rust_features: rust_target.into(),
- blacklisted_types: Default::default(),
- blacklisted_functions: Default::default(),
- blacklisted_items: Default::default(),
+ blocklisted_types: Default::default(),
+ blocklisted_functions: Default::default(),
+ blocklisted_items: Default::default(),
opaque_types: Default::default(),
rustfmt_path: Default::default(),
- whitelisted_types: Default::default(),
- whitelisted_functions: Default::default(),
- whitelisted_vars: Default::default(),
+ allowlisted_types: Default::default(),
+ allowlisted_functions: Default::default(),
+ allowlisted_vars: Default::default(),
default_enum_style: Default::default(),
bitfield_enums: Default::default(),
newtype_enums: Default::default(),
@@ -1934,7 +1979,7 @@ impl Default for BindgenOptions {
conservative_inline_namespaces: false,
generate_comments: true,
generate_inline_functions: false,
- whitelist_recursively: true,
+ allowlist_recursively: true,
generate_block: false,
objc_extern_crate: false,
block_extern_crate: false,
@@ -2520,8 +2565,8 @@ fn commandline_flag_unit_test_function() {
//Test 2
let bindings = crate::builder()
.header("input_header")
- .whitelist_type("Distinct_Type")
- .whitelist_function("safe_function");
+ .allowlist_type("Distinct_Type")
+ .allowlist_function("safe_function");
let command_line_flags = bindings.command_line_flags();
let test_cases = vec![
@@ -2530,9 +2575,9 @@ fn commandline_flag_unit_test_function() {
"--no-derive-default",
"--generate",
"functions,types,vars,methods,constructors,destructors",
- "--whitelist-type",
+ "--allowlist-type",
"Distinct_Type",
- "--whitelist-function",
+ "--allowlist-function",
"safe_function",
]
.iter()
diff --git a/src/options.rs b/src/options.rs
index 63e48dc8..2289ad09 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -136,22 +136,25 @@ where
.takes_value(true)
.multiple(true)
.number_of_values(1),
- Arg::with_name("blacklist-type")
- .long("blacklist-type")
+ Arg::with_name("blocklist-type")
+ .alias("blacklist-type")
+ .long("blocklist-type")
.help("Mark <type> as hidden.")
.value_name("type")
.takes_value(true)
.multiple(true)
.number_of_values(1),
- Arg::with_name("blacklist-function")
- .long("blacklist-function")
+ Arg::with_name("blocklist-function")
+ .alias("blacklist-function")
+ .long("blocklist-function")
.help("Mark <function> as hidden.")
.value_name("function")
.takes_value(true)
.multiple(true)
.number_of_values(1),
- Arg::with_name("blacklist-item")
- .long("blacklist-item")
+ Arg::with_name("blocklist-item")
+ .alias("blacklist-item")
+ .long("blocklist-item")
.help("Mark <item> as hidden.")
.value_name("item")
.takes_value(true)
@@ -210,12 +213,13 @@ where
"Avoid including doc comments in the output, see: \
https://github.com/rust-lang/rust-bindgen/issues/426",
),
- Arg::with_name("no-recursive-whitelist")
- .long("no-recursive-whitelist")
+ Arg::with_name("no-recursive-allowlist")
+ .long("no-recursive-allowlist")
+ .alias("no-recursive-whitelist")
.help(
- "Disable whitelisting types recursively. This will cause \
+ "Disable allowlisting types recursively. This will cause \
bindgen to emit Rust code that won't compile! See the \
- `bindgen::Builder::whitelist_recursively` method's \
+ `bindgen::Builder::allowlist_recursively` method's \
documentation for details.",
),
Arg::with_name("objc-extern-crate")
@@ -364,11 +368,12 @@ where
Arg::with_name("use-msvc-mangling")
.long("use-msvc-mangling")
.help("MSVC C++ ABI mangling. DEPRECATED: Has no effect."),
- Arg::with_name("whitelist-function")
- .long("whitelist-function")
+ Arg::with_name("allowlist-function")
+ .long("allowlist-function")
+ .alias("whitelist-function")
.help(
- "Whitelist all the free-standing functions matching \
- <regex>. Other non-whitelisted functions will not be \
+ "Allowlist all the free-standing functions matching \
+ <regex>. Other non-allowlisted functions will not be \
generated.",
)
.value_name("regex")
@@ -378,21 +383,23 @@ where
Arg::with_name("generate-inline-functions")
.long("generate-inline-functions")
.help("Generate inline functions."),
- Arg::with_name("whitelist-type")
- .long("whitelist-type")
+ Arg::with_name("allowlist-type")
+ .long("allowlist-type")
+ .alias("whitelist-type")
.help(
- "Only generate types matching <regex>. Other non-whitelisted types will \
+ "Only generate types matching <regex>. Other non-allowlisted types will \
not be generated.",
)
.value_name("regex")
.takes_value(true)
.multiple(true)
.number_of_values(1),
- Arg::with_name("whitelist-var")
- .long("whitelist-var")
+ Arg::with_name("allowlist-var")
+ .long("allowlist-var")
+ .alias("whitelist-var")
.help(
- "Whitelist all the free-standing variables matching \
- <regex>. Other non-whitelisted variables will not be \
+ "Allowlist all the free-standing variables matching \
+ <regex>. Other non-allowlisted variables will not be \
generated.",
)
.value_name("regex")
@@ -582,21 +589,21 @@ where
}
}
- if let Some(hidden_types) = matches.values_of("blacklist-type") {
+ if let Some(hidden_types) = matches.values_of("blocklist-type") {
for ty in hidden_types {
- builder = builder.blacklist_type(ty);
+ builder = builder.blocklist_type(ty);
}
}
- if let Some(hidden_functions) = matches.values_of("blacklist-function") {
+ if let Some(hidden_functions) = matches.values_of("blocklist-function") {
for fun in hidden_functions {
- builder = builder.blacklist_function(fun);
+ builder = builder.blocklist_function(fun);
}
}
- if let Some(hidden_identifiers) = matches.values_of("blacklist-item") {
+ if let Some(hidden_identifiers) = matches.values_of("blocklist-item") {
for id in hidden_identifiers {
- builder = builder.blacklist_item(id);
+ builder = builder.blocklist_item(id);
}
}
@@ -758,8 +765,8 @@ where
builder = builder.generate_comments(false);
}
- if matches.is_present("no-recursive-whitelist") {
- builder = builder.whitelist_recursively(false);
+ if matches.is_present("no-recursive-allowlist") {
+ builder = builder.allowlist_recursively(false);
}
if matches.is_present("objc-extern-crate") {
@@ -809,21 +816,21 @@ where
builder = builder.generate_inline_functions(true);
}
- if let Some(whitelist) = matches.values_of("whitelist-function") {
- for regex in whitelist {
- builder = builder.whitelist_function(regex);
+ if let Some(allowlist) = matches.values_of("allowlist-function") {
+ for regex in allowlist {
+ builder = builder.allowlist_function(regex);
}
}
- if let Some(whitelist) = matches.values_of("whitelist-type") {
- for regex in whitelist {
- builder = builder.whitelist_type(regex);
+ if let Some(allowlist) = matches.values_of("allowlist-type") {
+ for regex in allowlist {
+ builder = builder.allowlist_type(regex);
}
}
- if let Some(whitelist) = matches.values_of("whitelist-var") {
- for regex in whitelist {
- builder = builder.whitelist_var(regex);
+ if let Some(allowlist) = matches.values_of("allowlist-var") {
+ for regex in allowlist {
+ builder = builder.allowlist_var(regex);
}
}