[all-commits] [llvm/llvm-project] b25630: [-Wunsafe-buffer-usage] Add alloc_size knowledge t...

Ziqing Luo via All-commits all-commits at lists.llvm.org
Fri Mar 7 15:05:41 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b2563028cf8285f1e77f6bdba9268cd92cd9355e
      https://github.com/llvm/llvm-project/commit/b2563028cf8285f1e77f6bdba9268cd92cd9355e
  Author: Ziqing Luo <ziqing at udel.edu>
  Date:   2025-03-07 (Fri, 07 Mar 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] Add alloc_size knowledge to the 2-param span constructor warning (#114894)

We can take advantage of the attribute `alloc_size`.  For example, 
```
void * malloc(size_t size) __attribute__((alloc_size(1)));

std::span<char>{(char *)malloc(x), x}; // this is safe
```

rdar://136634730



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