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

    <tr>
        <th>Summary</th>
        <td>
            clang-query returns results for invalid queries
        </td>
    </tr>

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

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

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

<pre>
    Thanks to @AaronBallman on IRC for helping me understand the actual problem here.

In some cases when presented with a bogus query, clang-query not only fails to detect it, but it responds with bogus matches.

Simplified test-case:
```c++
int testfunc(int)
{
    return 0;
}

void caller()
{
    using functype = int(*)(int);
    functype fpointer = testfunc;
    fpointer(1);
    return;
}
```
```bash
clang-query> m  invocation(functionDecl(returns(asString("void"))))

Match #1:

/home/cory/dev/bitcoin-tidy/build/../example2.cc:10:5: note: "root" binds here
    fpointer(1);
    ^~~~~~~~~~~
1 match.
```
Rather than complaining about `invocation` being incompatible with `functionDecl` as it apparently should (thanks @AaronBallman!), a match is returned.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVM1y2jAQfhr7soPHyBjigw8khJkcekn6Amt7wWqF5OqHlLfvSiYpyWQ6ZYRkaT_tfvunzgyX9vuI-qcDbyBblVu0Rt-jUifUYDQ8PT_AwVgYSU1SH-FEEPRA1nnUA_iRAHsfUMFkTafoxEBLRVbusnI7z08anOFrPTpy8DqSZiw50p4GeJV-BITOHIODX4HsJRMP0CvUx0XagjaeeagLHFCqxHIgT70H6SO0C_ELWOFk9OBmhbO6E_p-JPeBzIs8TUoeJJv25PwiksqqqzBbl_PoM3EfRzqV2ifsIWg-v-NtJprrhc0VA_yz5IPVUGbV_Zt0d2v6bOTAQVCKLKv5WkdwMcbRkr9MBFm1g2SP4dt44918dXPpHX6YDIvJpnvvlD9ArwhWtPysZub_Bfu3qHzadujG-egmXVn1CCdg0mfTo5dGs6XEjz931CveznYcf6F78ZYdTv6JGB9ekptv4yZ832I2IRPV8m--5lnsR64vXnoTy2c_0JnnTvqenV14OcTDLkjF6vdFwRP9Ri4DEkXP4dkuOWXbmv-x1mI1sBVhjeFAC-hkrKpY1P8Xxax-zDb_HAm6nKuz-DLEz8h9Zbm5uAV7w0xR6lgX2BmudobdhHddQkdRKHWE8iF34dwFLPsQeoaii82C04SW-4-byo0mqIEdvvPzK_DpCchE8pAbDWfGIN21Umgo8qGthqZqMPfSK2pv-_aa5tiZQXmXHhHmjYq7ICIkuTxY1Y7eTy6mVOx5HJl46Ap2hTdKnd-WBT8vP7jreSudC8Tls69Xm3KTj215EF1T93VZHURTr6lCGqoSG6zrmup1nSvsSLk2q7mphaZXSCpirdW7XLaiFKJclUuxrMpqWTT9eoPrZtNUy3KzWt1xROjEb08ReRTGHnPbJkpdODoWKum8-ytE5-RREyVzrB-DH41tOaNByzxZbhPzPzjBrGI">