Skip to content

Commit 6984e0d

Browse files
committed
Revert "Implement nullPointerConstant() using a better API."
This reverts commit 9148302 (2019-08-22) which broke the pre-existing unit test for the matcher. Also revert commit 518b226 (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
1 parent 3e1317f commit 6984e0d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7384,9 +7384,10 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, CUDAKernelCallExpr>
73847384
/// expr(nullPointerConstant())
73857385
/// matches the initializer for v1, v2, v3, cp, and ip. Does not match the
73867386
/// initializer for i.
7387-
AST_MATCHER(Expr, nullPointerConstant) {
7388-
return Node.isNullPointerConstant(Finder->getASTContext(),
7389-
Expr::NPC_ValueDependentIsNull);
7387+
AST_MATCHER_FUNCTION(internal::Matcher<Expr>, nullPointerConstant) {
7388+
return anyOf(
7389+
gnuNullExpr(), cxxNullPtrLiteralExpr(),
7390+
integerLiteral(equals(0), hasParent(expr(hasType(pointerType())))));
73907391
}
73917392

73927393
/// Matches the DecompositionDecl the binding belongs to.

clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3663,7 +3663,7 @@ TEST_P(ASTMatchersTest, NullPointerConstant) {
36633663
expr(nullPointerConstant())));
36643664
EXPECT_TRUE(matches("char *cp = (char *)0;", expr(nullPointerConstant())));
36653665
EXPECT_TRUE(matches("int *ip = 0;", expr(nullPointerConstant())));
3666-
EXPECT_TRUE(matches("int i = 0;", expr(nullPointerConstant())));
3666+
EXPECT_FALSE(matches("int i = 0;", expr(nullPointerConstant())));
36673667
}
36683668

36693669
TEST_P(ASTMatchersTest, NullPointerConstant_GNUNull) {

0 commit comments

Comments
 (0)