diff options
author | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2016-10-14 14:18:52 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2016-10-18 15:55:43 +0200 |
commit | db32040baa632682b6f2ff5d533e5d6ffbe7a003 (patch) | |
tree | 68a763b48f80cbd43ff8c84bb36b4c95119ba605 | |
parent | 4646b9df3b50844f9576152737e002ce2dd37455 (diff) |
ir: Add a few edge cases discovered by testing.
-rw-r--r-- | src/ir/item.rs | 11 | ||||
-rw-r--r-- | src/ir/ty.rs | 6 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/ir/item.rs b/src/ir/item.rs index 0c1de20a..9ebda88e 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -713,6 +713,17 @@ impl ItemCanonicalPath for Item { } let mut parent_path = self.parent_id().canonical_path(&ctx); + if parent_path.last().map_or(false, |parent_name| parent_name.is_empty()) { + // This only happens (or should only happen) when we're an alias, + // and our parent is a templated alias, in which case the last + // component of the path will be empty. + let is_alias = match *self.expect_type().kind() { + TypeKind::Alias(..) => true, + _ => false, + }; + debug_assert!(is_alias, "How can this ever happen?"); + parent_path.pop().unwrap(); + } parent_path.push(self.real_canonical_name(ctx, true)); parent_path diff --git a/src/ir/ty.rs b/src/ir/ty.rs index 769b7650..0cf8174e 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -472,6 +472,12 @@ impl Type { ctx); } CXCursor_TemplateTypeParameter => { + // See the comment in src/ir/comp.rs + // about the same situation. + if cur.spelling().is_empty() { + return CXChildVisit_Continue; + } + let default_type = Item::from_ty(&cur.cur_type(), Some(*cur), |