-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[RemoteMirror] Use __attribute__((deprecated)) instead of [[deprecated]]. #70598
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
@@ -188,7 +188,7 @@ swift_reflection_typeRefForMangledTypeName(SwiftReflectionContextRef ContextRef, | |||
/// | |||
/// The returned string is heap allocated and the caller must free() it when | |||
/// done. | |||
[[deprecated("Please use swift_reflection_copyNameForTypeRef()")]] | |||
__attribute__((deprecated("Please use swift_reflection_copyNameForTypeRef()"))) |
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.
This header may be included by MSVC as well right? I think that we should use LLVM_DEPRECATED
. The [[deprecated(...)]]
syntax is part of C23 I think, which is why it was "safe".
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.
That makes sense. I didn't realize we had that macro and didn't find it when looking for one.
LLVM defines it as:
#if defined(__clang__)
#define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
#else
#define LLVM_DEPRECATED(MSG, FIX) [[deprecated(MSG)]]
#endif
Is the [[]]
syntax always going to be OK in the non-clang case? Seems like, if LLVM uses it, but I'm not sure if it uses this in C headers.
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.
I don't think that it is always safe in the else case, but currently the CI is only covering clang and MSVC. It should be okay with any C23 capable compiler. I don't believe that these are guarded by __cplusplus
.
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.
We don't include any LLVM headers here, so I stole the definition for a SWIFT_REMOTE_MIRROR_DEPRECATED
that we can use here.
1e96488
to
d8ab23a
Compare
@@ -41,6 +41,13 @@ extern "C" { | |||
# endif | |||
#endif | |||
|
|||
#if defined(__clang__) | |||
#define SWIFT_REMOTE_MIRROR_DEPRECATED(MSG, FIX) \ | |||
__attribute__((deprecated(MSG, FIX))) |
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.
Would be nice to use the reserved spelling: __attribute__((__deprecated__(MSG, FIX)))
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.
Done.
…d]]. Use __attribute__((deprecated)) in SwiftRemoteMirror.h as it needs to be includable from C.
d8ab23a
to
679db9a
Compare
@swift-ci please test |
Use
__attribute__((deprecated))
in SwiftRemoteMirror.h as it needs to be includable from C.