Skip to content

[Clang] Permit noescape on non-pointer types #9789

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

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

Xazax-hun
Copy link

In modern C++ we often use span, string_view or other view objects instead of raw pointers. This PR opens the door to mark those noescape. This can be useful to document the API contracts, for interop with memory safe languages like Swift or Rust, and possibly in the future to implement take this into account in codegen.

The PR also adds a feature test macro. The goal is to help avoiding warnings when the code is compiler by earlier versions of clang that does not permit this attribute on non-pointer types.

rdar://140196481

@Xazax-hun Xazax-hun requested a review from a team as a code owner December 23, 2024 15:27
@Xazax-hun
Copy link
Author

I am not sure yet if this would land upstream, but we definitely need this downstream. Upstream PR: llvm#117344

@Xazax-hun Xazax-hun requested a review from egorzhdan December 23, 2024 15:28
@Xazax-hun
Copy link
Author

@swift-ci please test LLVM

@Xazax-hun
Copy link
Author

@swift-ci please test

Copy link

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
I think we should probably try to upstream this in the future.

In modern C++ we often use span, string_view or other view objects instead of
raw pointers. This PR opens the door to mark those noescape. This can be useful
to document the API contracts, for interop with memory safe languages like
Swift or Rust, and possibly in the future to implement take this into account
in codegen.

The PR also adds a feature test macro. The goal is to help avoiding warnings
when the code is compiler by earlier versions of clang that does not permit
this attribute on non-pointer types.

rdar://140196481
@Xazax-hun Xazax-hun force-pushed the gaborh/noescape-nonptr branch from c13f4d9 to e465c25 Compare January 2, 2025 10:53
@Xazax-hun
Copy link
Author

@swift-ci please test LLVM

@Xazax-hun
Copy link
Author

@swift-ci test

@Xazax-hun
Copy link
Author

The LLVM test failures are unrelated.

@Xazax-hun Xazax-hun merged commit 06a77c5 into stable/20240723 Jan 2, 2025
2 of 5 checks passed
@Xazax-hun Xazax-hun deleted the gaborh/noescape-nonptr branch January 2, 2025 18:56
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.

2 participants