summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-04-18 13:00:14 -0500
committerGitHub <noreply@github.com>2017-04-18 13:00:14 -0500
commit5b74655a00f4838e711aa02468e80ffa33765623 (patch)
treee5b1a4a1a1e1debf9a91561060e2dffa7bcf2720 /src
parent65f672c2d95ed89015cecf6a57279cacce1fe683 (diff)
parentbcf1ba38ac9f67ead8642b0b36d745f498e84f24 (diff)
Auto merge of #641 - emilio:anon-struct-typedef, r=fitzgen
ir: Ensure we check for typedefs of anonymous structs at the right time. They appear later in the clang AST, so we need to check for them as a special-case before flushing the new field.
Diffstat (limited to 'src')
-rw-r--r--src/ir/comp.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/ir/comp.rs b/src/ir/comp.rs
index 80c51b8f..7a85794b 100644
--- a/src/ir/comp.rs
+++ b/src/ir/comp.rs
@@ -500,11 +500,19 @@ impl CompInfo {
let mut maybe_anonymous_struct_field = None;
cursor.visit(|cur| {
if cur.kind() != CXCursor_FieldDecl {
- if let Some((ty, _, offset)) =
+ if let Some((ty, clang_ty, offset)) =
maybe_anonymous_struct_field.take() {
- let field =
- Field::new(None, ty, None, None, None, false, offset);
- ci.fields.push(field);
+ if cur.kind() == CXCursor_TypedefDecl &&
+ cur.typedef_type().unwrap().canonical_type() == clang_ty {
+ // Typedefs of anonymous structs appear later in the ast
+ // than the struct itself, that would otherwise be an
+ // anonymous field. Detect that case here, and do
+ // nothing.
+ } else {
+ let field =
+ Field::new(None, ty, None, None, None, false, offset);
+ ci.fields.push(field);
+ }
}
}
@@ -737,7 +745,8 @@ impl CompInfo {
});
if let Some((ty, _, offset)) = maybe_anonymous_struct_field {
- let field = Field::new(None, ty, None, None, None, false, offset);
+ let field =
+ Field::new(None, ty, None, None, None, false, offset);
ci.fields.push(field);
}