Jeremy Kuah
Jeremy Kuah

Reputation: 539

Clang AST - isNullPointerConstant()

I'm trying to check if input arguments to a CallExpr is null/nil in Objective C using Clang's AST

I saw that there is a method isNullPointerConstant() that seems like it will do what I want http://clang.llvm.org/doxygen/classclang_1_1Expr.html#ab56d6fd074c831a3e63b45f4f226b35a

However, I'm not really sure how to invoke this method. Specifically, what is NullPointerConstantValueDependence that it is taking in and what is NullPointerConstantKind of the return?

What I need to do is just evaluate whether an argument is null or not, a boolean return value would work fine. Is there any other way that I should be looking at?

Upvotes: 0

Views: 152

Answers (1)

Jeremy Kuah
Jeremy Kuah

Reputation: 539

This worked for me in the end

Expr::NullPointerConstantKind kind = expr->isNullPointerConstant(*Context, Expr::NullPointerConstantValueDependence());

If kind is > 0, means there are some form of null pointer and one can retrieve it to see the cause of it.

Upvotes: 2

Related Questions