feat(ir) Simplify ManuallyDrop and MaybeUninit only for C.
This commit is contained in:
committed by
Emilio Cobos Álvarez
parent
af6d2e3fbb
commit
0076a17ac9
@@ -120,10 +120,10 @@ impl Function {
|
||||
&self.path
|
||||
}
|
||||
|
||||
pub fn simplify_standard_types(&mut self) {
|
||||
self.ret.simplify_standard_types();
|
||||
pub fn simplify_standard_types(&mut self, config: &Config) {
|
||||
self.ret.simplify_standard_types(config);
|
||||
for arg in &mut self.args {
|
||||
arg.ty.simplify_standard_types();
|
||||
arg.ty.simplify_standard_types(config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,8 +61,8 @@ impl Static {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simplify_standard_types(&mut self) {
|
||||
self.ty.simplify_standard_types();
|
||||
pub fn simplify_standard_types(&mut self, config: &Config) {
|
||||
self.ty.simplify_standard_types(config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,9 +143,9 @@ impl Struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simplify_standard_types(&mut self) {
|
||||
pub fn simplify_standard_types(&mut self, config: &Config) {
|
||||
for &mut (_, ref mut ty, _) in &mut self.fields {
|
||||
ty.simplify_standard_types();
|
||||
ty.simplify_standard_types(config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::fmt;
|
||||
use std::io::Write;
|
||||
|
||||
use crate::bindgen::cdecl;
|
||||
use crate::bindgen::config::Config;
|
||||
use crate::bindgen::config::{Config, Language};
|
||||
use crate::bindgen::declarationtyperesolver::DeclarationTypeResolver;
|
||||
use crate::bindgen::dependencies::Dependencies;
|
||||
use crate::bindgen::ir::{Documentation, GenericParams, GenericPath, Path};
|
||||
@@ -411,7 +411,7 @@ impl Type {
|
||||
}
|
||||
}
|
||||
|
||||
fn simplified_type(&self) -> Option<Self> {
|
||||
fn simplified_type(&self, config: &Config) -> Option<Self> {
|
||||
let path = match *self {
|
||||
Type::Path(ref p) => p,
|
||||
_ => return None,
|
||||
@@ -422,7 +422,7 @@ impl Type {
|
||||
}
|
||||
|
||||
let mut generic = path.generics()[0].clone();
|
||||
generic.simplify_standard_types();
|
||||
generic.simplify_standard_types(config);
|
||||
|
||||
match path.name() {
|
||||
// FIXME(#223): This is not quite correct.
|
||||
@@ -433,13 +433,14 @@ impl Type {
|
||||
is_nullable: false,
|
||||
is_ref: false,
|
||||
}),
|
||||
"Cell" | "ManuallyDrop" | "MaybeUninit" => Some(generic),
|
||||
"Cell" => Some(generic),
|
||||
"ManuallyDrop" | "MaybeUninit" if config.language == Language::C => Some(generic),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simplify_standard_types(&mut self) {
|
||||
if let Some(ty) = self.simplified_type() {
|
||||
pub fn simplify_standard_types(&mut self, config: &Config) {
|
||||
if let Some(ty) = self.simplified_type(config) {
|
||||
*self = ty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,8 +66,8 @@ impl Typedef {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simplify_standard_types(&mut self) {
|
||||
self.aliased.simplify_standard_types();
|
||||
pub fn simplify_standard_types(&mut self, config: &Config) {
|
||||
self.aliased.simplify_standard_types(config);
|
||||
}
|
||||
|
||||
pub fn transfer_annotations(&mut self, out: &mut HashMap<Path, AnnotationSet>) {
|
||||
|
||||
@@ -96,9 +96,9 @@ impl Union {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simplify_standard_types(&mut self) {
|
||||
pub fn simplify_standard_types(&mut self, config: &Config) {
|
||||
for &mut (_, ref mut ty, _) in &mut self.fields {
|
||||
ty.simplify_standard_types();
|
||||
ty.simplify_standard_types(config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -344,20 +344,22 @@ impl Library {
|
||||
}
|
||||
|
||||
fn simplify_standard_types(&mut self) {
|
||||
let config = &self.config;
|
||||
|
||||
self.structs.for_all_items_mut(|x| {
|
||||
x.simplify_standard_types();
|
||||
x.simplify_standard_types(config);
|
||||
});
|
||||
self.unions.for_all_items_mut(|x| {
|
||||
x.simplify_standard_types();
|
||||
x.simplify_standard_types(config);
|
||||
});
|
||||
self.globals.for_all_items_mut(|x| {
|
||||
x.simplify_standard_types();
|
||||
x.simplify_standard_types(config);
|
||||
});
|
||||
self.typedefs.for_all_items_mut(|x| {
|
||||
x.simplify_standard_types();
|
||||
x.simplify_standard_types(config);
|
||||
});
|
||||
for x in &mut self.functions {
|
||||
x.simplify_standard_types();
|
||||
x.simplify_standard_types(config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user