Author: Stephen Kelly Date: 2021-02-20T17:33:07Z New Revision: 6984e0d4398592a20055cb12842fc72462ce01a5
URL: https://github.com/llvm/llvm-project/commit/6984e0d4398592a20055cb12842fc72462ce01a5 DIFF: https://github.com/llvm/llvm-project/commit/6984e0d4398592a20055cb12842fc72462ce01a5.diff LOG: Revert "Implement nullPointerConstant() using a better API." This reverts commit 9148302a (2019-08-22) which broke the pre-existing unit test for the matcher. Also revert commit 518b2266 (Fix the nullPointerConstant() test to get bots back to green., 2019-08-22) which incorrectly changed the test to expect the broken behavior. Differential Revision: https://reviews.llvm.org/D96665 Added: Modified: clang/include/clang/ASTMatchers/ASTMatchers.h clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Removed: ################################################################################ diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index 6cd4d26768b5..b82929019f6c 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -7384,9 +7384,10 @@ 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(Expr, nullPointerConstant) { - return Node.isNullPointerConstant(Finder->getASTContext(), - Expr::NPC_ValueDependentIsNull); +AST_MATCHER_FUNCTION(internal::Matcher<Expr>, nullPointerConstant) { + return anyOf( + gnuNullExpr(), cxxNullPtrLiteralExpr(), + integerLiteral(equals(0), hasParent(expr(hasType(pointerType()))))); } /// Matches the DecompositionDecl the binding belongs to. diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp index 1c6947acf0ab..c26e8f8d4d22 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp @@ -3663,7 +3663,7 @@ TEST_P(ASTMatchersTest, NullPointerConstant) { expr(nullPointerConstant()))); EXPECT_TRUE(matches("char *cp = (char *)0;", expr(nullPointerConstant()))); EXPECT_TRUE(matches("int *ip = 0;", expr(nullPointerConstant()))); - EXPECT_TRUE(matches("int i = 0;", expr(nullPointerConstant()))); + EXPECT_FALSE(matches("int i = 0;", expr(nullPointerConstant()))); } TEST_P(ASTMatchersTest, NullPointerConstant_GNUNull) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits