Skip to content

Commit 2e06749

Browse files
committed
clang: Push the fix for #3277 into Type::declaration.
Fixes #3264.
1 parent 58a8710 commit 2e06749

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

bindgen-tests/tests/expectations/tests/nested-class-field.rs

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class A {
2+
class I;
3+
};
4+
5+
class A::I {
6+
int i;
7+
};

bindgen/clang.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,11 +1211,11 @@ impl Type {
12111211

12121212
/// Get a cursor pointing to this type's declaration.
12131213
pub(crate) fn declaration(&self) -> Cursor {
1214-
unsafe {
1215-
Cursor {
1216-
x: clang_getTypeDeclaration(self.x),
1217-
}
1218-
}
1214+
let decl = Cursor {
1215+
x: unsafe { clang_getTypeDeclaration(self.x) },
1216+
};
1217+
// Prior to clang 22, the declaration pointed to the definition.
1218+
decl.definition().unwrap_or(decl)
12191219
}
12201220

12211221
/// Get the canonical declaration of this type, if it is available.

bindgen/ir/comp.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,12 +1269,6 @@ impl CompInfo {
12691269
);
12701270

12711271
let mut cursor = ty.declaration();
1272-
1273-
// If there is a definition, that's what we want.
1274-
if let Some(def) = cursor.definition() {
1275-
cursor = def;
1276-
}
1277-
12781272
let mut kind = Self::kind_from_cursor(&cursor);
12791273
if kind.is_err() {
12801274
if let Some(location) = location {

0 commit comments

Comments
 (0)