summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-11-07 20:30:22 -0600
committerGitHub <noreply@github.com>2016-11-07 20:30:22 -0600
commit108c4ca68769e7acad2a503001a156e0c51a7a8b (patch)
tree0a912707aef046d5751054ff40dad652e51b2a96
parent6c0d065c63fc99e32557bf28cc268c39a6003866 (diff)
parentd5ee20c9e566db5fc8141a43f886c03377c4389e (diff)
Auto merge of #224 - fitzgen:type-is-valid, r=emilio
Add `clang::Type::is_valid` and use it instead of checking self.kind() against CXType_Invalid Needed `is_valid()` when debugging, so figured we should land this and update places where we compare against the magical sentinel value. r? @emilio
-rwxr-xr-xsrc/clang.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/clang.rs b/src/clang.rs
index c6af517c..e6d78123 100755
--- a/src/clang.rs
+++ b/src/clang.rs
@@ -639,7 +639,7 @@ impl Type {
let ret = Type {
x: unsafe { clang_getPointeeType(self.x) },
};
- debug_assert!(ret.kind() != CXType_Invalid);
+ debug_assert!(ret.is_valid());
Some(ret)
}
_ => None,
@@ -652,7 +652,7 @@ impl Type {
let current_type = Type {
x: unsafe { clang_getElementType(self.x) },
};
- if current_type.kind() != CXType_Invalid {
+ if current_type.is_valid() {
Some(current_type)
} else {
None
@@ -691,10 +691,10 @@ impl Type {
let rt = Type {
x: unsafe { clang_getResultType(self.x) },
};
- if rt.kind() == CXType_Invalid {
- None
- } else {
+ if rt.is_valid() {
Some(rt)
+ } else {
+ None
}
}
@@ -714,6 +714,11 @@ impl Type {
}
}
}
+
+ /// Is this a valid type?
+ pub fn is_valid(&self) -> bool {
+ self.kind() != CXType_Invalid
+ }
}
/// An iterator for a type's template arguments.