summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXidorn Quan <me@upsuper.org>2016-10-25 17:10:18 +1100
committerXidorn Quan <me@upsuper.org>2016-10-25 21:07:04 +1100
commitfaa2ff06abf9f9913aa311e8ee739c761237669d (patch)
treef66f491c040dcb439a7cd8a8e3e07a02815f1445
parente06aab1271978a8005ab84a4296acd7f357b9755 (diff)
Use canonical type for checking integer type
-rw-r--r--src/ir/ty.rs11
-rw-r--r--src/ir/var.rs2
2 files changed, 8 insertions, 5 deletions
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index bf45b9fc..5765a78c 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -104,10 +104,13 @@ impl Type {
Self::new(Some(name), None, kind, false)
}
- pub fn is_integer_literal(&self) -> bool {
- match *self.kind() {
- TypeKind::Int(..) => true,
- _ => false,
+ pub fn is_integer(&self, ctx: &BindgenContext) -> bool {
+ match self.kind {
+ TypeKind::UnresolvedTypeRef(..) => false,
+ _ => match self.canonical_type(ctx).kind {
+ TypeKind::Int(..) => true,
+ _ => false,
+ }
}
}
diff --git a/src/ir/var.rs b/src/ir/var.rs
index 23529bcd..8e7f6c42 100644
--- a/src/ir/var.rs
+++ b/src/ir/var.rs
@@ -112,7 +112,7 @@ impl ClangSubItemParser for Var {
// tests/headers/inner_const.hpp
//
// That's fine because in that case we know it's not a literal.
- if context.safe_resolve_type(ty).map_or(false, |t| t.is_integer_literal()) {
+ if context.safe_resolve_type(ty).map_or(false, |t| t.is_integer(context)) {
// Try to parse a literal token value
cursor.visit(|c, _| {
if c.kind() == CXCursor_IntegerLiteral {