diff options
-rwxr-xr-x | src/clang.rs | 11 | ||||
-rw-r--r-- | src/ir/comp.rs | 3 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/clang.rs b/src/clang.rs index 57c42eaf..18216125 100755 --- a/src/clang.rs +++ b/src/clang.rs @@ -182,7 +182,7 @@ impl Cursor { /// Is the referent a template specialization? pub fn is_template(&self) -> bool { - self.specialized().is_valid() + self.specialized().is_some() } /// Is the referent a fully specialized template specialization without any @@ -282,11 +282,12 @@ impl Cursor { /// Given that this cursor points to a template specialization, get a cursor /// pointing to the template definition that is being specialized. - pub fn specialized(&self) -> Cursor { + pub fn specialized(&self) -> Option<Cursor> { unsafe { - Cursor { - x: clang_getSpecializedCursorTemplate(self.x), - } + let ret = Cursor { + x: clang_getSpecializedCursorTemplate(self.x) + }; + if ret.is_valid() { Some(ret) } else { None } } } diff --git a/src/ir/comp.rs b/src/ir/comp.rs index 22082772..41e5c3d3 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -512,7 +512,8 @@ impl CompInfo { } }; - ci.ref_template = Item::parse(cursor.specialized(), None, ctx).ok(); + ci.ref_template = cursor.specialized() + .and_then(|c| Item::parse(c, None, ctx).ok()); let mut maybe_anonymous_struct_field = None; cursor.visit(|cur| { |