Browse Source

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
Aaron Ballman 6 years ago
parent
commit
57d6d8e7de
1 changed files with 3 additions and 4 deletions
  1. 3 4
      include/clang/ASTMatchers/ASTMatchers.h

+ 3 - 4
include/clang/ASTMatchers/ASTMatchers.h

@@ -6445,10 +6445,9 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, CUDAKernelCallExpr>
 /// expr(nullPointerConstant())
 ///   matches the initializer for v1, v2, v3, cp, and ip. Does not match the
 ///   initializer for i.
-AST_MATCHER_FUNCTION(internal::Matcher<Expr>, 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