apple / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. This fork is used to manage Apple’s stable releases of Clang as well as support the Swift project.
https://llvm.org
Other
1.09k stars 320 forks source link

🍒[Safe Buffers] Serialize unsafe_buffer_usage pragmas (#92031) #8901

Closed ziqingluo-90 closed 1 week ago

ziqingluo-90 commented 2 weeks ago

The commit adds serialization and de-serialization implementations for the stored regions. Basically, the serialized representation of the regions of a PP is a (ordered) sequence of source location encodings. For de-serialization, regions from loaded files are stored by their ASTs. When later one queries if a loaded location L is in an opt-out region, PP looks up the regions of the loaded AST where L is at.

(Background if helps: a pair of #pragma clang unsafe_buffer_usage begin/end pragmas marks a warning-opt-out region. The begin and end locations (opt-out regions) are stored in preprocessor instances (PP) and will be queried by the -Wunsafe-buffer-usage analyzer.)

The reported issue at upstream: https://github.com/llvm/llvm-project/issues/90501 rdar://124035402

(cherry picked from commit 2e7b95e4c080426e5085c38cec01176b56798534)

ziqingluo-90 commented 2 weeks ago

@swift-ci test

ziqingluo-90 commented 2 weeks ago

@swift-ci Please test Windows platform

haoNoQ commented 1 week ago

@tbkka This is the PR we were talking about!