From: Aaron Ballman Date: Thu, 22 Aug 2019 18:26:44 +0000 (+0000) Subject: Implement nullPointerConstant() using a better API. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=57d6d8e7debf33ffc0421522cd49c4b0c54fb67e;p=clang Implement nullPointerConstant() using a better API. Instead of manually attempting to identify whether something is a null pointer constant, use Expr::isNullPointerConstant(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369683 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index 909e4d29fb..e34b31cbda 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -6445,10 +6445,9 @@ extern const internal::VariadicDynCastAllOfMatcher /// expr(nullPointerConstant()) /// matches the initializer for v1, v2, v3, cp, and ip. Does not match the /// initializer for i. -AST_MATCHER_FUNCTION(internal::Matcher, nullPointerConstant) { - return anyOf( - gnuNullExpr(), cxxNullPtrLiteralExpr(), - integerLiteral(equals(0), hasParent(expr(hasType(pointerType()))))); +AST_MATCHER(Expr, nullPointerConstant) { + return Node.isNullPointerConstant(Finder->getASTContext(), + Expr::NPC_ValueDependentIsNull); } /// Matches declaration of the function the statement belongs to