-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Implement withoutActuallyEscaping verification #15046
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
Implement withoutActuallyEscaping verification #15046
Conversation
Will be used to verify that withoutActuallyEscaping's block does not escape the closure. ``%escaping = is_escaping_closure %closure`` tests the reference count. If the closure is not uniquely referenced it prints out and error message and returns true. Otherwise, it returns false. The returned result can be used with a ``cond_fail %escaping`` instruction to abort the program. rdar://35525730
Check that an ``withoutActuallyEscaping(noescape_closure) { // scope}`` closure has not escaped in the scope using the ``is_escaping_closure %closure`` instruction. rdar://35525730
@swift-ci Please test |
Build failed |
stdlib/public/runtime/SwiftObject.mm
Outdated
auto *fatalErr = reinterpret_cast<const unsigned char *>("Fatal error"); | ||
auto *message = reinterpret_cast<const unsigned char *>( | ||
"closure argument was escaped in withoutActuallyEscaping block"); | ||
_swift_stdlib_reportFatalErrorInFile(fatalErr, 11, message, 62, filename, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use strlen
here (LLVM should be able to fold it away).
Aside: maybe we should rename this callback to not have "fatal" in it, since it doesn't abort itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Build failed |
…introduced rdar://35525730
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
The code can be made correct by moving the code that uses the returned closure into withoutActuallyEscaping. |
Foundation/NSIndexSet.swift has the same issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet 👍
stdlib/public/runtime/SwiftObject.mm
Outdated
auto *fatalErr = reinterpret_cast<const unsigned char *>("Fatal error"); | ||
auto *message = reinterpret_cast<const unsigned char *>( | ||
"closure argument was escaped in withoutActuallyEscaping block"); | ||
_swift_stdlib_reportFatalErrorInFile(fatalErr, 11, message, 62, filename, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
👍🏻👍🏻 |
Please test with following PR: |
Build failed |
The successful source compatibility suite run is here: https://ci.swift.org/view/Pull%20Request/job/swift-PR-source-compat-suite/837/ |
Please test with following PR: |
Build failed |
Please test with following PR: |
swiftlang/swift-corelibs-foundation#1463 has to be merged first to prevent breakage |
@swift-ci Please test mac os x |
@swift-ci Please test macos |
Build failed |
Check that an
withoutActuallyEscaping(noescape_closure) { // scope}
closurehas not escaped in the scope using the
is_escaping_closure %closure
instruction.
rdar://35525730