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

    <tr>
        <th>Summary</th>
        <td>
            clang-analyzer-alpha.cplusplus.DeleteWithNonVirtualDtor does not handle indirection through base pointer
        </td>
    </tr>

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

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

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

<pre>
    The following code will trigger clang-analyzer-alpha.cplusplus.DeleteWithNonVirtualDtor
https://godbolt.org/z/7jPa8dr5W
```
#include <cstdio>

struct A {};

struct B : A {
    virtual ~B() { std::puts("B dtor"); }
};

struct C : B {
    ~C() { std::puts("C dtor"); }
};

int main() {
    C* c1 = new C{};
    C* c2 = nullptr;

    A** pp = (A**)&c2; // note: Casting from 'C' to 'A' here
    *pp = c1;

    delete c2; // warning: Destruction of a polymorphic object with no virtual destructor [clang-analyzer-alpha.cplusplus.DeleteWithNonVirtualDtor]
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyclM-PqzYQx_-a4TJKBAOEcODAj-ZY9VD1nY3tgJ8cG9lmo93D_u2VCWq6q231tJITjGfsz8x8xzDv1WSkbKDsoBwStobZuiYoNtkb48wp65PRitfmz1ni1Wpt78pMyK2QeFdaY3BqmqRDrpmZDsww_fom3YHpZWZHvujVx99xkFoG-UOF-Xdr_lIurEwPwTpIB0jbOYTFQ94CXYAukxWj1eFo3QR0eQO6VD__YGfhyh8Pdzil-3i8Uq4M16uQCHnPfRDKQv7bbtz-fXArD9giVB1UA-TdF9YOIW93n20dEfHlESu-d0BnoDpa0QcRo83bZQ1-W6cORUyHCKiGvMNIeSD-C9dvuO4j7r3_f0z_6xhlAt6YMs8Dn5geqEWeIeQDGnnH_lNdnj708Fm1XoL7RIheLVAcuCybI9B5X4kB0onTFuWmKxobZMy5Zz7ELro6e0OgqgeqMNg4beN0lk4-CUDtfjjPvghAbJ2FH0B35owyU2QN8lFuZQ3aKzJcrH69WbfMiqMdf0oe8K7CjMb-o7XY91iHUHbf7ezyX8p8bNtENLmo85olssmqnIjSuqiTuSkZyaKq8jI9l8WpuBaZTOvsnJ5rOWYypUQ1lFKRZZRRSnVaH7k4V3QqS16xQpyIQZHKG1P6qPXLLd6gRHm_yibLKsrTRLNRar_ddqIo_GaN7VQOiWvipsO4Th6KVCsf_POYoIKWzTdrgcJKH-XHmRmhJSojlJMPVcLs7DrNODIvcbHKBOmS1enm01dBhXkdj9zegC4xrP1xWJyNKgJdtmQ80GXP9qWhvwMAAP__AzJx-A">