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

    <tr>
        <th>Summary</th>
        <td>
            clang-tidy: bugprone-undefined-memory-manipulation fails to catch array of NonTriviallyCopyable types
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          nick-schultz
      </td>
    </tr>
</table>

<pre>
    I am using llvm-14.0.3  

Please see the following example:

```
#include <cstring>
#include <vector>

struct my_struct_t {                            
    int counter;
    std::vector<int> my_vector;
};

void foo() {
    my_struct_t bar[10];

    //No warning
    memset(bar, 0, sizeof(bar));

    //Warning: bugprone-undefined-memory-manipulation
    memset(&bar[0], 0, sizeof(bar[0]));
}
```

I would expect the following statement to have triggered the `[bugprone-undefined-memory-manipulation]` clang tidy check, since it is calling `memset` on the entire array of NonTriviallyCopyable structures
```
    //No warning
    memset(bar, 0, sizeof(bar));
```

I suspect there is something wrong with the check's [matcher](https://github.com/llvm/llvm-project/blob/8d03c49f498cb19358aacd28f57a852549d34ebd/clang-tools-extra/clang-tidy/bugprone/UndefinedMemoryManipulationCheck.cpp#L27).  However it's unclear if the matcher expression is incorrect or if perhaps `pointsTo` is not considering `bar` as a pointer.

My knowledge with clang  AST-matchers are extremely limited ,  so any insight or guidance would be much appreciated.  

Thanks,

Nick



</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVE2P2zYQ_TXyhbAgUdJaOujgdRo0QHdRoFv0GFDkWGKXIgWSsqP8-g5pGXYCt02BGgLNj-HMm3mP0xmxtJ8IG8nspO6JUqdxm5dplhaEJNmHJNtfxl8VMAfEARA_ADkapcw53IAvbJwUJMX-3jx5ytbvsqSF1FzNAkhSHLjzFq8mxU-PTk_AvbG3wzjijZl7Mi6fL7PPniS7Z_IPv8u9MJPaE25m7QG9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