[clang] [-Wunsafe-buffer-usage] Fix false positives in warning againt 2-parameter std::span constructor (PR #115797)

Ziqing Luo via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 12 11:18:11 PST 2024


https://github.com/ziqingluo-90 approved this pull request.

Nice!

nit:  please add the pattern `std::span<T>{std::addressor(...), 1}` to the comment:
```
// Given a two-param std::span construct call, matches iff the call has the
// following forms:
//   1. `std::span<T>{new T[n], n}`, where `n` is a literal or a DRE
//   2. `std::span<T>{new T, 1}`
//   3. `std::span<T>{&var, 1}` 
//   4. `std::span<T>{a, n}`, where `a` is of an array-of-T with constant size
//   `n`
//   5. `std::span<T>{any, 0}`
```

https://github.com/llvm/llvm-project/pull/115797


More information about the cfe-commits mailing list