[PATCH] D137379: [-Wunsafe-buffer-usage] Add warnings for unsafe buffer accesses by array subscript operations
Ziqing Luo via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 27 12:01:59 PDT 2023
ziqingluo-90 added a comment.
In D137379#4225000 <https://reviews.llvm.org/D137379#4225000>, @manojgupta wrote:
> This is firing even in checked length codes, is that expected?
Yes, it is expected. The unsafe buffer analysis is syntax-based. The analysis warns operations that do not follow the buffer-safe programming model we are suggesting. The programming model prohibits pointer arithmetic. In the model, pointer arithmetic and buffer access can be done using hardened libc++ facilities such as `std::span`.
More information about the analysis and the programming model can be found at https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734.
To suppress the warning, you can either turn the analysis off using `-Wno-unsafe-buffer-usage` or put code in a pair of opt-out pragmas `#pragma clang unsafe_buffer_usage begin` & `#pragma clang unsafe_buffer_usage end`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137379/new/
https://reviews.llvm.org/D137379
More information about the cfe-commits
mailing list