-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ClangImporter] Look through __ended_by and __null_terminated #81630
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
[ClangImporter] Look through __ended_by and __null_terminated #81630
Conversation
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
2c488a2
to
1090ee0
Compare
@swift-ci please smoke test |
@swift-ci please smoke test macos |
@swift-ci please smoke test |
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.
LGTM, thanks for the really thorough testing! Left some nits, mostly about documentation and formatting.
#endif | ||
|
||
#if !__cplusplus | ||
void p(int len, int p[len]); |
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.
Why this isn't allowed in C++? (And can you add a comment with your explanation?)
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.
VLAs are a C only feature
char * __single j(char *__single p); | ||
void *__single k(void *__single p); | ||
|
||
#if __has_ptrcheck |
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.
Why are only __indexable
and __bidi_indexable
guarded with __has_ptrcheck
?
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.
Other macros defined in ptrcheck.h
are defined to nothing when -fbounds-safety
is not enabled, these two are intentionally left undefined since they can affect ABI, so you don't want one TU thinking they are normal pointers and one TU expanding them to wide pointers
@@ -0,0 +1,48 @@ | |||
#pragma once | |||
|
|||
#include <ptrcheck.h> |
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.
Is this header file guaranteed to be on every platform we deploy to?
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.
ah probably not, no
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.
or actually, maybe? We ship it with clang, and we ship clang with swift. So I think it ought to be there
test/Interop/C/bounds-safety/import-bounds-attributed-global.swift
Outdated
Show resolved
Hide resolved
test/Interop/C/bounds-safety/import-bounds-attributed-struct.swift
Outdated
Show resolved
Hide resolved
Previously we would not import decls containing these types. This was not an issue, because they can only occur when -fbounds-safety or -fexperimental-bounds-safety-attributes is passed to clang. When SafeInteropWrappers is enabled we pass -fexperimental-bound-safety-attributes to clang however, so these types can now occur without the user specifying any -Xcc flags. rdar://151611718
1090ee0
to
51eb212
Compare
@swift-ci please smoke test |
@swift-ci please smoke test windows |
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.
LGTM!
@swift-ci please smoke test windows |
@swift-ci please smoke test |
|
||
func access() { | ||
#if VERIFY | ||
let _ = a // expected-error{{cannot reference invalid declaration 'a'}} rdar://151665752 |
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.
@egorzhdan Do you have any idea why this wouldn't error on Windows?
@swift-ci please smoke test |
@swift-ci please smoke test |
…ang#81630) Previously we would not import decls containing these types. This was not an issue, because they can only occur when -fbounds-safety or -fexperimental-bounds-safety-attributes is passed to clang. When SafeInteropWrappers is enabled we pass -fexperimental-bound-safety-attributes to clang however, so these types can now occur without the user specifying any -Xcc flags. rdar://151611718 (cherry picked from commit ac068c2)
…es-6.2 [ClangImporter] Look through __ended_by and __null_terminated (#81630)
Previously we would not import decls containing these types. This was not an issue, because they can only occur when -fbounds-safety or -fexperimental-bounds-safety-attributes is passed to clang. When SafeInteropWrappers is enabled we pass
-fexperimental-bound-safety-attributes to clang however, so these types can now occur without the user specifying any -Xcc flags.
rdar://151611718