<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/87008>87008</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            The nullPointerConstant matcher is problematic
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          GKxxQAQ
      </td>
    </tr>
</table>

<pre>
    Current definition of `clang::ast_matchers::nullPointerConstant` (in `clang/include/clang/ASTMatchers.h`) is

```cpp
AST_MATCHER_FUNCTION(internal::Matcher<Expr>, nullPointerConstant) {
  return anyOf(
      gnuNullExpr(), cxxNullPtrLiteralExpr(),
      integerLiteral(equals(0), hasParent(expr(hasType(pointerType())))));
}
```

The third argument to `anyOf` here is problematic, I think. Counterexample:

```cpp
int main() {
  int *p[1];
 p[0];
}
```

The integer literal `0` in `p[0]` is matched by `expr(nullPointerConstant())`.

Possible fix: use `integerLiteral(equals(0), hasParent(expr(implicitCastExpr(hasImplicitDestinationType(pointerType())))))` (not sure if it's right).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVF2PqzYQ_TXDi3WRMeEjDzywJGlX7d2b202fVwYGcGsM9Ueb_PvKgexmV6u2aoQS5QxzPHPOeLgxoleIBSQPkOwC7uww6eKHn87n7-X3oJ7aS1E5rVFZ0mInlLBiUmTqCKS0kVz1EJcQl9zYl5HbZkBtFkQ5KY-TUBZ1NSljubKQUgIsF-otmR2EaqRrEdjhhpTPp68rVThASoFtiTBAd0DL9Tuly9PM84KUz6eXr-Wp-nH_y8vh16fq9Pjt6XqURa24XEpaWSGu9udZQ7wHVpHP6mRbAtnDwkyIRuu0IlxdvnXA8hvsP71yT07KKx3LgW09Y3M-e_Bo9c_Coubvw_fp_tQeb68By_EPx6UBltOVa-DmyL36PrjQDNycLjMCy-el7PXfNeP9E689QLb7INy9mqcBiR2EbgnXvRu91XbyFi0dp5QMqJEIQ2Y91RJHbkXji3v0aer3kFST84XgmY-zRC_2P5ollCUjF2op-l5qHwFWzpA8RJDsXhsgHqH3yL-3tIpL5KKub8i_RpbxeyX0iCHL7LakvvjgqvSno3HTOaXh_YnHyRhRSySdOENcEmfQM_0vh8U4S9EIW3Fj96-mP67oDo0Vivt7-F_nYLl3arLEOO9kR4QFlhmiRT_4cQ-DtojbbbzlARZRFkVpSjdRFAxFFicdIoujrOmSrOuaOkrqjia8yxPWRE0gCkbZhsYsZ1EUx1HYbBLaxnVa082W13UEG4ojFzKU8s8xnHQfCGMcFnlGaR5IXqM01_XDmMK_yDUIjPltpAuf86V2vYENlcJY88ZihZVYeKc_8Wk1VH-Y2sBpWQzWztclxQ7ADr2wg6vDZhqBHTz5-vNl1tNv2Fi_onxJBtjhWvLfAQAA__9He5NV">