Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ziqingluo-90
Copy link

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: llvm#90501 rdar://124035402

(cherry picked from commit 2e7b95e)

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: llvm#90501
rdar://124035402

(cherry picked from commit 2e7b95e)
@ziqingluo-90
Copy link
Author

@swift-ci test

@rapidsna rapidsna self-requested a review June 17, 2024 17:06
@ziqingluo-90 ziqingluo-90 requested a review from tbkka June 17, 2024 17:48
@ziqingluo-90
Copy link
Author

@swift-ci Please test Windows platform

@haoNoQ
Copy link

haoNoQ commented Jun 19, 2024

@tbkka This is the PR we were talking about!

@tbkka tbkka merged commit c20fe8b into swiftlang:swift/release/6.0 Jun 20, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants