summaryrefslogtreecommitdiff
path: root/clang-plugin/assertion-extracter.cpp
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-05-05 11:43:08 +0100
committerPhilip Withnall <philip.withnall@collabora.co.uk>2014-05-05 11:44:03 +0100
commit526c5aacddffa2c3f0e6300dc621e8fee4316493 (patch)
treeffde6a46f6c63284565b1bde5aaf616c34cf1a4e /clang-plugin/assertion-extracter.cpp
parent989ecb0db66685ec86243f1ef201d336339dbae6 (diff)
clang-plugin: Handle additional Expr types in the assertion extracter
Diffstat (limited to 'clang-plugin/assertion-extracter.cpp')
-rw-r--r--clang-plugin/assertion-extracter.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang-plugin/assertion-extracter.cpp b/clang-plugin/assertion-extracter.cpp
index 6cac6c9..2866849 100644
--- a/clang-plugin/assertion-extracter.cpp
+++ b/clang-plugin/assertion-extracter.cpp
@@ -369,6 +369,14 @@ AssertionExtracter::is_assertion_stmt (Stmt& stmt, const ASTContext& context)
context.getLogicalOperationType (),
SourceLocation ());
}
+ case Stmt::StmtClass::IntegerLiteralClass: {
+ /* Handle an integer literal. This doesn’t modify program state,
+ * and evaluates directly to a boolean.
+ * Transformations:
+ * 0 ↦ FALSE
+ * I ↦ TRUE */
+ return dyn_cast<Expr> (&stmt);
+ }
case Stmt::StmtClass::ParenExprClass: {
/* Handle a parenthesised expression.
* Transformations:
@@ -675,6 +683,7 @@ _assertion_is_gobject_type_check (Expr& assertion_expr,
case Expr::IntegerLiteralClass:
case Expr::BinaryOperatorClass:
case Expr::UnaryOperatorClass:
+ case Expr::ConditionalOperatorClass:
case Expr::CallExprClass:
case Expr::ImplicitCastExprClass: {
/* These can’t be type checks. */
@@ -766,6 +775,17 @@ _assertion_is_explicit_nonnull_check (Expr& assertion_expr,
*/
return 0;
}
+ case Expr::ConditionalOperatorClass: {
+ /* A conditional operator. For the moment, assume this isn’t a
+ * non-null check.
+ *
+ * FIXME: In the future, define a proper program transformation
+ * to check for non-null checks, since we could have expressions
+ * like:
+ * (x == NULL) ? TRUE : FALSE
+ */
+ return 0;
+ }
case Expr::CStyleCastExprClass:
case Expr::ImplicitCastExprClass: {
/* A (explicit or implicit) cast. This can either be: