[all-commits] [llvm/llvm-project] 314033: [-Wunsafe-buffer-usage] Support span creation from...

Ziqing Luo via All-commits all-commits at lists.llvm.org
Tue Jun 24 18:32:24 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3140333872f6e54693397882dead2c1387c91189
      https://github.com/llvm/llvm-project/commit/3140333872f6e54693397882dead2c1387c91189
  Author: Ziqing Luo <ziqing at udel.edu>
  Date:   2025-06-25 (Wed, 25 Jun 2025)

  Changed paths:
    M clang/lib/Analysis/UnsafeBufferUsage.cpp
    M clang/test/SemaCXX/warn-unsafe-buffer-usage-in-container-span-construct.cpp

  Log Message:
  -----------
  [-Wunsafe-buffer-usage] Support span creation from std::initializer_list and begin/end pairs (#145311)

Support safe construction of `std::span` from `begin` and `end` calls on
hardened containers or views or `std::initializer_list`s.

For example, the following code is safe:
```
void create(std::initializer_list<int> il) {
    std::span<int> input{ il.begin(), il.end() }; // no warn
}
```

rdar://152637380



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list