Skip to content

Commit f4f47d5

Browse files
authored
Merge pull request rust-lang#1525 from emilio/llvm-bug-workaround
Work-around https://bugs.llvm.org/show_bug.cgi?id=40813.
2 parents 9fb016e + 592c7cb commit f4f47d5

File tree

6 files changed

+127
-35
lines changed

6 files changed

+127
-35
lines changed

CHANGELOG.md

+59-17
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,51 @@
99
- [Removed](#removed)
1010
- [Fixed](#fixed)
1111
- [Security](#security)
12-
- [0.47.0](#0470)
13-
- [Changed](#changed-1)
12+
- [0.47.2](#0472)
1413
- [Fixed](#fixed-1)
14+
- [0.47.1](#0471)
15+
- [Changed](#changed-1)
16+
- [Fixed](#fixed-2)
17+
- [0.47.0](#0470)
18+
- [Changed](#changed-2)
19+
- [Fixed](#fixed-3)
1520
- [0.33.1 .. 0.46.0](#0331--0460)
1621
- [Added](#added-1)
1722
- [Removed](#removed-1)
18-
- [Changed](#changed-2)
19-
- [Fixed](#fixed-2)
23+
- [Changed](#changed-3)
24+
- [Fixed](#fixed-4)
2025
- [0.33.1](#0331)
21-
- [Fixed](#fixed-3)
26+
- [Fixed](#fixed-5)
2227
- [0.33.0](#0330)
2328
- [Added](#added-2)
24-
- [Changed](#changed-3)
29+
- [Changed](#changed-4)
2530
- [Deprecated](#deprecated-1)
2631
- [Removed](#removed-2)
27-
- [Fixed](#fixed-4)
32+
- [Fixed](#fixed-6)
2833
- [Security](#security-1)
2934
- [0.32.2](#0322)
30-
- [Fixed](#fixed-5)
35+
- [Fixed](#fixed-7)
3136
- [0.32.1](#0321)
32-
- [Fixed](#fixed-6)
37+
- [Fixed](#fixed-8)
3338
- [0.32.0](#0320)
3439
- [Added](#added-3)
35-
- [Changed](#changed-4)
36-
- [Fixed](#fixed-7)
40+
- [Changed](#changed-5)
41+
- [Fixed](#fixed-9)
3742
- [0.31.0](#0310)
3843
- [Added](#added-4)
39-
- [Changed](#changed-5)
44+
- [Changed](#changed-6)
4045
- [Deprecated](#deprecated-2)
4146
- [Removed](#removed-3)
42-
- [Fixed](#fixed-8)
47+
- [Fixed](#fixed-10)
4348
- [0.30.0](#0300)
4449
- [Added](#added-5)
45-
- [Changed](#changed-6)
50+
- [Changed](#changed-7)
4651
- [Deprecated](#deprecated-3)
47-
- [Fixed](#fixed-9)
52+
- [Fixed](#fixed-11)
4853
- [0.29.0](#0290)
4954
- [Added](#added-6)
50-
- [Changed](#changed-7)
51-
- [Fixed](#fixed-10)
55+
- [Changed](#changed-8)
56+
- [Fixed](#fixed-12)
5257

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

@@ -84,6 +89,43 @@ Released YYYY/MM/DD
8489

8590
--------------------------------------------------------------------------------
8691

92+
# 0.47.2
93+
94+
Released 2019/02/22
95+
96+
## Fixed
97+
98+
* @flowbish fixed code generation for nested function prototypes. [#1508][]
99+
* Some complex C++ constructs no longer panic on code generation [#1513][]
100+
* Implicit template parameters are now appended to base classes [#1515][]
101+
* @flier fixed single-argument block pointers [#1519][]
102+
* Bindgen won't panic when parsing an undeduced auto type [#1525][]
103+
104+
[#1508]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1508
105+
[#1513]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1513
106+
[#1515]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1515
107+
[#1519]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1519
108+
[#1525]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1525
109+
110+
--------------------------------------------------------------------------------
111+
112+
# 0.47.1
113+
114+
Released 2019/02/02
115+
116+
## Changed
117+
118+
* @luser improved the error message when rustfmt cannot be found [#1501][]
119+
120+
## Fixed
121+
122+
* Reverted `clang-sys` update for regressions [#1505][]
123+
124+
[#1505]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1505
125+
[#1501]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1501
126+
127+
--------------------------------------------------------------------------------
128+
87129
# 0.47.0
88130

89131
Released 2019/01/19

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ readme = "README.md"
1414
repository = "https://github.com/rust-lang/rust-bindgen"
1515
documentation = "https://docs.rs/bindgen"
1616
homepage = "https://rust-lang.github.io/rust-bindgen/"
17-
version = "0.47.1"
17+
version = "0.47.2"
1818
build = "build.rs"
1919

2020
include = [

src/clang.rs

+31-16
Original file line numberDiff line numberDiff line change
@@ -931,18 +931,37 @@ impl Type {
931931
unsafe { clang_isConstQualifiedType(self.x) != 0 }
932932
}
933933

934+
#[inline]
935+
fn is_non_deductible_auto_type(&self) -> bool {
936+
self.kind() == CXType_Auto && self.canonical_type() == *self
937+
}
938+
939+
#[inline]
940+
fn clang_size_of(&self) -> c_longlong {
941+
if self.is_non_deductible_auto_type() {
942+
return -6; // Work-around https://bugs.llvm.org/show_bug.cgi?id=40813
943+
}
944+
unsafe { clang_Type_getSizeOf(self.x) }
945+
}
946+
947+
#[inline]
948+
fn clang_align_of(&self) -> c_longlong {
949+
if self.is_non_deductible_auto_type() {
950+
return -6; // Work-around https://bugs.llvm.org/show_bug.cgi?id=40813
951+
}
952+
unsafe { clang_Type_getAlignOf(self.x) }
953+
}
954+
934955
/// What is the size of this type? Paper over invalid types by returning `0`
935956
/// for them.
936957
pub fn size(&self) -> usize {
937-
unsafe {
938-
let val = clang_Type_getSizeOf(self.x);
939-
if val < 0 { 0 } else { val as usize }
940-
}
958+
let val = self.clang_size_of();
959+
if val < 0 { 0 } else { val as usize }
941960
}
942961

943962
/// What is the size of this type?
944963
pub fn fallible_size(&self) -> Result<usize, LayoutError> {
945-
let val = unsafe { clang_Type_getSizeOf(self.x) };
964+
let val = self.clang_size_of();
946965
if val < 0 {
947966
Err(LayoutError::from(val as i32))
948967
} else {
@@ -953,21 +972,17 @@ impl Type {
953972
/// What is the alignment of this type? Paper over invalid types by
954973
/// returning `0`.
955974
pub fn align(&self) -> usize {
956-
unsafe {
957-
let val = clang_Type_getAlignOf(self.x);
958-
if val < 0 { 0 } else { val as usize }
959-
}
975+
let val = self.clang_align_of();
976+
if val < 0 { 0 } else { val as usize }
960977
}
961978

962979
/// What is the alignment of this type?
963980
pub fn fallible_align(&self) -> Result<usize, LayoutError> {
964-
unsafe {
965-
let val = clang_Type_getAlignOf(self.x);
966-
if val < 0 {
967-
Err(LayoutError::from(val as i32))
968-
} else {
969-
Ok(val as usize)
970-
}
981+
let val = self.clang_align_of();
982+
if val < 0 {
983+
Err(LayoutError::from(val as i32))
984+
} else {
985+
Ok(val as usize)
971986
}
972987
}
973988

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
#![allow(
4+
dead_code,
5+
non_snake_case,
6+
non_camel_case_types,
7+
non_upper_case_globals
8+
)]
9+
10+
#[repr(C)]
11+
#[derive(Debug, Default, Copy, Clone)]
12+
pub struct BrowsingContext {
13+
pub _address: u8,
14+
}
15+
#[test]
16+
fn bindgen_test_layout_BrowsingContext() {
17+
assert_eq!(
18+
::std::mem::size_of::<BrowsingContext>(),
19+
1usize,
20+
concat!("Size of: ", stringify!(BrowsingContext))
21+
);
22+
assert_eq!(
23+
::std::mem::align_of::<BrowsingContext>(),
24+
1usize,
25+
concat!("Alignment of ", stringify!(BrowsingContext))
26+
);
27+
}

tests/headers/bug-1529681.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// bindgen-flags: -- -std=c++14
2+
//
3+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1529681
4+
// https://bugs.llvm.org/show_bug.cgi?id=40813
5+
6+
class BrowsingContext {
7+
auto Tie(void* aUnused) const;
8+
};

0 commit comments

Comments
 (0)