Skip to content
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

Work-around https://bugs.llvm.org/show_bug.cgi?id=40813. #1525

Merged
merged 2 commits into from
Feb 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 59 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,51 @@
- [Removed](#removed)
- [Fixed](#fixed)
- [Security](#security)
- [0.47.0](#0470)
- [Changed](#changed-1)
- [0.47.2](#0472)
- [Fixed](#fixed-1)
- [0.47.1](#0471)
- [Changed](#changed-1)
- [Fixed](#fixed-2)
- [0.47.0](#0470)
- [Changed](#changed-2)
- [Fixed](#fixed-3)
- [0.33.1 .. 0.46.0](#0331--0460)
- [Added](#added-1)
- [Removed](#removed-1)
- [Changed](#changed-2)
- [Fixed](#fixed-2)
- [Changed](#changed-3)
- [Fixed](#fixed-4)
- [0.33.1](#0331)
- [Fixed](#fixed-3)
- [Fixed](#fixed-5)
- [0.33.0](#0330)
- [Added](#added-2)
- [Changed](#changed-3)
- [Changed](#changed-4)
- [Deprecated](#deprecated-1)
- [Removed](#removed-2)
- [Fixed](#fixed-4)
- [Fixed](#fixed-6)
- [Security](#security-1)
- [0.32.2](#0322)
- [Fixed](#fixed-5)
- [Fixed](#fixed-7)
- [0.32.1](#0321)
- [Fixed](#fixed-6)
- [Fixed](#fixed-8)
- [0.32.0](#0320)
- [Added](#added-3)
- [Changed](#changed-4)
- [Fixed](#fixed-7)
- [Changed](#changed-5)
- [Fixed](#fixed-9)
- [0.31.0](#0310)
- [Added](#added-4)
- [Changed](#changed-5)
- [Changed](#changed-6)
- [Deprecated](#deprecated-2)
- [Removed](#removed-3)
- [Fixed](#fixed-8)
- [Fixed](#fixed-10)
- [0.30.0](#0300)
- [Added](#added-5)
- [Changed](#changed-6)
- [Changed](#changed-7)
- [Deprecated](#deprecated-3)
- [Fixed](#fixed-9)
- [Fixed](#fixed-11)
- [0.29.0](#0290)
- [Added](#added-6)
- [Changed](#changed-7)
- [Fixed](#fixed-10)
- [Changed](#changed-8)
- [Fixed](#fixed-12)

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

Expand Down Expand Up @@ -84,6 +89,43 @@ Released YYYY/MM/DD

--------------------------------------------------------------------------------

# 0.47.2

Released 2019/02/22

## Fixed

* @flowbish fixed code generation for nested function prototypes. [#1508][]
* Some complex C++ constructs no longer panic on code generation [#1513][]
* Implicit template parameters are now appended to base classes [#1515][]
* @flier fixed single-argument block pointers [#1519][]
* Bindgen won't panic when parsing an undeduced auto type [#1525][]

[#1508]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1508
[#1513]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1513
[#1515]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1515
[#1519]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1519
[#1525]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1525

--------------------------------------------------------------------------------

# 0.47.1

Released 2019/02/02

## Changed

* @luser improved the error message when rustfmt cannot be found [#1501][]

## Fixed

* Reverted `clang-sys` update for regressions [#1505][]

[#1505]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1505
[#1501]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1501

--------------------------------------------------------------------------------

# 0.47.0

Released 2019/01/19
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ readme = "README.md"
repository = "https://github.com/rust-lang/rust-bindgen"
documentation = "https://docs.rs/bindgen"
homepage = "https://rust-lang.github.io/rust-bindgen/"
version = "0.47.1"
version = "0.47.2"
build = "build.rs"

include = [
Expand Down
47 changes: 31 additions & 16 deletions src/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -931,18 +931,37 @@ impl Type {
unsafe { clang_isConstQualifiedType(self.x) != 0 }
}

#[inline]
fn is_non_deductible_auto_type(&self) -> bool {
self.kind() == CXType_Auto && self.canonical_type() == *self
}

#[inline]
fn clang_size_of(&self) -> c_longlong {
if self.is_non_deductible_auto_type() {
return -6; // Work-around https://bugs.llvm.org/show_bug.cgi?id=40813
}
unsafe { clang_Type_getSizeOf(self.x) }
}

#[inline]
fn clang_align_of(&self) -> c_longlong {
if self.is_non_deductible_auto_type() {
return -6; // Work-around https://bugs.llvm.org/show_bug.cgi?id=40813
}
unsafe { clang_Type_getAlignOf(self.x) }
}

/// What is the size of this type? Paper over invalid types by returning `0`
/// for them.
pub fn size(&self) -> usize {
unsafe {
let val = clang_Type_getSizeOf(self.x);
if val < 0 { 0 } else { val as usize }
}
let val = self.clang_size_of();
if val < 0 { 0 } else { val as usize }
}

/// What is the size of this type?
pub fn fallible_size(&self) -> Result<usize, LayoutError> {
let val = unsafe { clang_Type_getSizeOf(self.x) };
let val = self.clang_size_of();
if val < 0 {
Err(LayoutError::from(val as i32))
} else {
Expand All @@ -953,21 +972,17 @@ impl Type {
/// What is the alignment of this type? Paper over invalid types by
/// returning `0`.
pub fn align(&self) -> usize {
unsafe {
let val = clang_Type_getAlignOf(self.x);
if val < 0 { 0 } else { val as usize }
}
let val = self.clang_align_of();
if val < 0 { 0 } else { val as usize }
}

/// What is the alignment of this type?
pub fn fallible_align(&self) -> Result<usize, LayoutError> {
unsafe {
let val = clang_Type_getAlignOf(self.x);
if val < 0 {
Err(LayoutError::from(val as i32))
} else {
Ok(val as usize)
}
let val = self.clang_align_of();
if val < 0 {
Err(LayoutError::from(val as i32))
} else {
Ok(val as usize)
}
}

Expand Down
27 changes: 27 additions & 0 deletions tests/expectations/tests/bug-1529681.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* automatically generated by rust-bindgen */

#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]

#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct BrowsingContext {
pub _address: u8,
}
#[test]
fn bindgen_test_layout_BrowsingContext() {
assert_eq!(
::std::mem::size_of::<BrowsingContext>(),
1usize,
concat!("Size of: ", stringify!(BrowsingContext))
);
assert_eq!(
::std::mem::align_of::<BrowsingContext>(),
1usize,
concat!("Alignment of ", stringify!(BrowsingContext))
);
}
8 changes: 8 additions & 0 deletions tests/headers/bug-1529681.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// bindgen-flags: -- -std=c++14
//
// https://bugzilla.mozilla.org/show_bug.cgi?id=1529681
// https://bugs.llvm.org/show_bug.cgi?id=40813

class BrowsingContext {
auto Tie(void* aUnused) const;
};