From 57d6d8e7debf33ffc0421522cd49c4b0c54fb67e Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 22 Aug 2019 18:26:44 +0000 Subject: [PATCH] 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 --- include/clang/ASTMatchers/ASTMatchers.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 -- 2.40.0