-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a workaround for #528, and fix #527 #532
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
18a7d3e
Add an option to distrust clang mangling.
emilio dd9f25e
clang: Print the semantic parent when dumping the AST.
emilio 0063bf3
comp: parse definitions even when they aren't in the correct scope.
emilio ea39b98
ir: Parse cursor definitions in unions as children of the union.
emilio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,6 +212,18 @@ impl Builder { | |
self | ||
} | ||
|
||
/// Whether to use the clang-provided name mangling. This is true and | ||
/// probably needed for C++ features. | ||
/// | ||
/// However, some old libclang versions seem to return incorrect results in | ||
/// some cases for non-mangled functions, see [1], so we allow disabling it. | ||
/// | ||
/// [1]: https://github.com/servo/rust-bindgen/issues/528 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: when rendered as markdown, I think this link is going to disappear, since the "see [1]" isn't a proper markdown link. Instead it should be something like
above. |
||
pub fn trust_clang_mangling(mut self, doit: bool) -> Self { | ||
self.options.enable_mangling = doit; | ||
self | ||
} | ||
|
||
/// Generate a C/C++ file that includes the header and has dummy uses of | ||
/// every type defined in the header. | ||
pub fn dummy_uses<T: Into<String>>(mut self, dummy_uses: T) -> Builder { | ||
|
@@ -572,6 +584,15 @@ pub struct BindgenOptions { | |
/// Intead of emitting 'use objc;' to files generated from objective c files, | ||
/// generate '#[macro_use] extern crate objc;' | ||
pub objc_extern_crate: bool, | ||
|
||
/// Whether to use the clang-provided name mangling. This is true and | ||
/// probably needed for C++ features. | ||
/// | ||
/// However, some old libclang versions seem to return incorrect results in | ||
/// some cases for non-mangled functions, see [1], so we allow disabling it. | ||
/// | ||
/// [1]: https://github.com/servo/rust-bindgen/issues/528 | ||
pub enable_mangling: bool, | ||
} | ||
|
||
/// TODO(emilio): This is sort of a lie (see the error message that results from | ||
|
@@ -626,6 +647,7 @@ impl Default for BindgenOptions { | |
generate_comments: true, | ||
whitelist_recursively: true, | ||
objc_extern_crate: false, | ||
enable_mangling: true, | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* automatically generated by rust-bindgen */ | ||
|
||
|
||
#![allow(non_snake_case)] | ||
|
||
|
||
#[repr(C)] | ||
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); | ||
impl <T> __BindgenUnionField<T> { | ||
#[inline] | ||
pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } | ||
#[inline] | ||
pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } | ||
#[inline] | ||
pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } | ||
} | ||
impl <T> ::std::default::Default for __BindgenUnionField<T> { | ||
#[inline] | ||
fn default() -> Self { Self::new() } | ||
} | ||
impl <T> ::std::clone::Clone for __BindgenUnionField<T> { | ||
#[inline] | ||
fn clone(&self) -> Self { Self::new() } | ||
} | ||
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } | ||
impl <T> ::std::fmt::Debug for __BindgenUnionField<T> { | ||
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { | ||
fmt.write_str("__BindgenUnionField") | ||
} | ||
} | ||
#[repr(C)] | ||
#[derive(Debug, Default, Copy)] | ||
pub struct s { | ||
pub u: s__bindgen_ty_1, | ||
} | ||
#[repr(C)] | ||
#[derive(Debug, Default, Copy)] | ||
pub struct s__bindgen_ty_1 { | ||
pub field: __BindgenUnionField<s__bindgen_ty_1_inner>, | ||
pub bindgen_union_field: u32, | ||
} | ||
#[repr(C)] | ||
#[derive(Debug, Default, Copy)] | ||
pub struct s__bindgen_ty_1_inner { | ||
pub b: ::std::os::raw::c_int, | ||
} | ||
#[test] | ||
fn bindgen_test_layout_s__bindgen_ty_1_inner() { | ||
assert_eq!(::std::mem::size_of::<s__bindgen_ty_1_inner>() , 4usize , | ||
concat ! ( "Size of: " , stringify ! ( s__bindgen_ty_1_inner ) | ||
)); | ||
assert_eq! (::std::mem::align_of::<s__bindgen_ty_1_inner>() , 4usize , | ||
concat ! ( | ||
"Alignment of " , stringify ! ( s__bindgen_ty_1_inner ) )); | ||
assert_eq! (unsafe { | ||
& ( * ( 0 as * const s__bindgen_ty_1_inner ) ) . b as * const | ||
_ as usize } , 0usize , concat ! ( | ||
"Alignment of field: " , stringify ! ( s__bindgen_ty_1_inner ) | ||
, "::" , stringify ! ( b ) )); | ||
} | ||
impl Clone for s__bindgen_ty_1_inner { | ||
fn clone(&self) -> Self { *self } | ||
} | ||
#[test] | ||
fn bindgen_test_layout_s__bindgen_ty_1() { | ||
assert_eq!(::std::mem::size_of::<s__bindgen_ty_1>() , 4usize , concat ! ( | ||
"Size of: " , stringify ! ( s__bindgen_ty_1 ) )); | ||
assert_eq! (::std::mem::align_of::<s__bindgen_ty_1>() , 4usize , concat ! | ||
( "Alignment of " , stringify ! ( s__bindgen_ty_1 ) )); | ||
assert_eq! (unsafe { | ||
& ( * ( 0 as * const s__bindgen_ty_1 ) ) . field as * const _ | ||
as usize } , 0usize , concat ! ( | ||
"Alignment of field: " , stringify ! ( s__bindgen_ty_1 ) , | ||
"::" , stringify ! ( field ) )); | ||
} | ||
impl Clone for s__bindgen_ty_1 { | ||
fn clone(&self) -> Self { *self } | ||
} | ||
#[test] | ||
fn bindgen_test_layout_s() { | ||
assert_eq!(::std::mem::size_of::<s>() , 4usize , concat ! ( | ||
"Size of: " , stringify ! ( s ) )); | ||
assert_eq! (::std::mem::align_of::<s>() , 4usize , concat ! ( | ||
"Alignment of " , stringify ! ( s ) )); | ||
assert_eq! (unsafe { & ( * ( 0 as * const s ) ) . u as * const _ as usize | ||
} , 0usize , concat ! ( | ||
"Alignment of field: " , stringify ! ( s ) , "::" , stringify | ||
! ( u ) )); | ||
} | ||
impl Clone for s { | ||
fn clone(&self) -> Self { *self } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
struct s { | ||
union { | ||
struct inner { | ||
int b; | ||
} field; | ||
} u; | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh