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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy]: `cppcoreguidelines-owning-memory` cannot cope with returning objects of subclasses
        </td>
    </tr>

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

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

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

<pre>
    ```C++
struct A {
    virtual ~A() = default;
};

struct B : public A {};

A* foo(int x)
{
 return new B;
}
```

The above code will pass clang-tidy `cppcoreguidelines-owning-memory` check. It is caused by

![image](https://github.com/llvm/llvm-project/assets/2892107/404a863a-f1e7-45ef-bbf3-f9b27cc33706)

Adding an ignoringParenImpCasts fix the problem
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUUs2O2yAQfprxZeQIgx2bgw_ORpH21kNfADC2aQl4-dlsLn32ytlE2aqXVhqJEYy-4fsRMZrZad1Dc4DmWIicFh_6tzcj3HzJhfTjtYc9-awXoIetyBHIEFPIKuGA0N5vEBHfTUhZWPw1AO2AcgR2xFFPItsE7D4I7fHZfwU7ILAB1yytUXfkv0YHoANO3gPtjEv4AZQ_UB__CDrl4NDpCx7-WPrZPOh8Rf2-aBTSv2tUftR4MdbiKmJEZYWby2TGK8KeqHVVPug5m1Fb43Qs_cUZN5dnffbhCnuCatHq5w5fE5qISuSoR5TXr7uAVtAczFnMGpoj0G5JaY3ABqAnoKfZpCXLnfJnoCdr3x9HuQb_Q6sE9CRi1CkCPdGO04q0QE81qUW3Z6KcKt2WdaOnUsqJlROXtFWKsZbsn1J9KjmOxs0oHJrZ-WDc_E0E7V7P64uIKeJkPjAtGtfgpdXnYuzZyBkXhe6rfcd51TWcFUvfNXWrRMP1VEvG1MQn1XSi5qyjLa9aWZieEspISyvS1LxhO1JNvGtHLggVI-MCaqLPwtjdxnPnw1yYGLPu94zzurBCahtvEaV0M_X2CJRuiQ39TRuZ5wg1sSam-ERJJtlbtp8uboqz4V-9FM75hMqvWyTSck_WppqXmxcR_YQxS2U3S2KRg-3_280bnc3NG93fAQAA__8-SBYW">