Skip to content

[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

Merged
merged 1 commit into from
Jan 6, 2024

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented Dec 21, 2023

Use __attribute__((deprecated)) in SwiftRemoteMirror.h as it needs to be includable from C.

@mikeash mikeash requested a review from w6sec December 21, 2023 20:25
@@ -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()")))
Copy link
Member

@compnerd compnerd Dec 21, 2023

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".

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@mikeash mikeash force-pushed the fix-swift-inspect-attribute branch from 1e96488 to d8ab23a Compare January 2, 2024 15:55
@@ -41,6 +41,13 @@ extern "C" {
# endif
#endif

#if defined(__clang__)
#define SWIFT_REMOTE_MIRROR_DEPRECATED(MSG, FIX) \
__attribute__((deprecated(MSG, FIX)))
Copy link
Member

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)))

Copy link
Contributor Author

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.
@mikeash mikeash force-pushed the fix-swift-inspect-attribute branch from d8ab23a to 679db9a Compare January 2, 2024 18:10
@mikeash
Copy link
Contributor Author

mikeash commented Jan 2, 2024

@swift-ci please test

@mikeash mikeash merged commit 246e6d1 into swiftlang:main Jan 6, 2024
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