[clang] [WIP][Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Wed May 15 13:46:12 PDT 2024


haoNoQ wrote:

> serializing the pragmas themselves as AST nodes

These pragmas don't really translate very well into the AST. Similarly to `#pragma clang diagnostic`, they can be placed weirdly "across" other AST nodes, like:
```
#pragma clang unsafe_buffer_usage begin
void foo() {
#pragma clang unsafe_buffer_usage end
}
```
We could support it in the same way that clang supports Duff's Device but I don't think this is really a good idea. We ultimately want them to be textual, a preprocessor-level construct, because that's what security audits are looking for: an extremely clear sign that this is where unchecked pointer operations live. So that they could tell it without looking at anything else in the code.

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


More information about the cfe-commits mailing list