r369683 - Implement nullPointerConstant() using a better API.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 22 11:26:44 PDT 2019


Author: aaronballman
Date: Thu Aug 22 11:26:44 2019
New Revision: 369683

URL: http://llvm.org/viewvc/llvm-project?rev=369683&view=rev
Log:
Implement nullPointerConstant() using a better API.

Instead of manually attempting to identify whether something is a null pointer constant, use Expr::isNullPointerConstant().

Modified:
    cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=369683&r1=369682&r2=369683&view=diff
==============================================================================
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Aug 22 11:26:44 2019
@@ -6445,10 +6445,9 @@ extern const internal::VariadicDynCastAl
 /// 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




More information about the cfe-commits mailing list