Skip to content

Allow identification of OSLogMessage by a @_semantics attribute instead of just name #39455

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
Sep 27, 2021

Conversation

kubamracek
Copy link
Contributor

OSLogOptimization currently special-cases the type name "OSLogMessage" and applies special treatment to it (skips over synthesized witness methods). Let's allow explicitly annotating types with @_semantics("oslog.message.type") to trigger the same treatment. This will be useful for custom implementations of OSLog-like APIs.

rdar://83325012

@kubamracek kubamracek force-pushed the oslog-type-annotation branch 2 times, most recently from 09792be to ab1647d Compare September 25, 2021 00:40
@ravikandhadai
Copy link
Contributor

ravikandhadai commented Sep 25, 2021

@kubamracek Thanks Kuba for making the PR. Is semantics attributes now possible on types?

@ravikandhadai
Copy link
Contributor

I wonder if it may be better to rename the OSLogMessage type in the OSLogTestHelper module apply this semantics attribute. This may enable testing this change.

@kubamracek
Copy link
Contributor Author

kubamracek commented Sep 25, 2021

Semantics attributes on types were added via 454dd00, yes.

@kubamracek kubamracek force-pushed the oslog-type-annotation branch from ab1647d to 3a74ea5 Compare September 25, 2021 03:39
@kubamracek
Copy link
Contributor Author

I wonder if it may be better to rename the OSLogMessage type in the OSLogTestHelper module apply this semantics attribute. This may enable testing this change.

I tried that, and it ended being a bit invasive on the code OSLogTestHelper. Let's see if you prefer that, but I can also perhaps revert and switch only the AnimationFormatString.OSLogMessage type, which can be done as a minimally invasive change.

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 3a74ea5d87183256e18bee93d048d3551691943d

@kubamracek kubamracek force-pushed the oslog-type-annotation branch from 3a74ea5 to b273ec8 Compare September 25, 2021 15:06
@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek
Copy link
Contributor Author

@ravikandhadai This is what only changing the type name on AnimationFormatString.OSLogMessage looks like: kubamracek@668b204

Let me know if you'd prefer that.

@ravikandhadai
Copy link
Contributor

ravikandhadai commented Sep 25, 2021

@ravikandhadai This is what only changing the type name on AnimationFormatString.OSLogMessage looks like: kubamracek@668b204

Let me know if you'd prefer that.

Yes. Changing AnimationFormatString.OSLogMessage instead of the OSLogMessage type sounds great. Thanks Kuba!

On a slightly different note, if you are only interested in converting a string interpolation to a static format string and not very concerned about optimizing varargs lmk. There is a very small design change possible on the client side, compared to the current implementation of OSLogMessage and os_log, that would enable creating a very general custom string interpolation type that can be used in any context and create a static format string.

@kubamracek kubamracek force-pushed the oslog-type-annotation branch from b273ec8 to b2ab4f1 Compare September 26, 2021 00:47
@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek
Copy link
Contributor Author

On a slightly different note, if you are only interested in converting a string interpolation to a static format string and not very concerned about optimizing varargs lmk. There is a very small design change possible on the client side, compared to the current implementation of OSLogMessage and os_log, that would enable creating a very general custom string interpolation type that can be used in any context and create a static format string.

I'm not sure, TBH. Maybe @Catfish-Man does?

@Catfish-Man
Copy link
Contributor

I'm not sure either tbh. It sounds interesting at least!

@kubamracek
Copy link
Contributor Author

@swift-ci please test Windows platform

Copy link
Contributor

@ravikandhadai ravikandhadai left a comment

Choose a reason for hiding this comment

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

LGTM!

@ravikandhadai
Copy link
Contributor

I'm not sure either tbh. It sounds interesting at least!

No worries. Feel free to cc me on the PR you create for that.

@kubamracek kubamracek merged commit 87cc490 into swiftlang:main Sep 27, 2021
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.

4 participants