Skip to content

[cas] Fix caching of diagnostics using getCustomDiagID #9299

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 19, 2024

Conversation

benlangmuir
Copy link

Custom diagnostics need to be serialized so that they can be registered with the diagnostic engine during replay. If any custom diagnostics are emitted, we capture all the known custom diagnostics. While this could theoretically be wasteful, in practice custom diagnostics are created only when they will be emitted. Note: this also fixes clang/test/CAS/analyze-action.c.

Custom diagnostics need to be serialized so that they can be registered
with the diagnostic engine during replay. If any custom diagnostics are
emitted, we capture all the known custom diagnostics. While this could
theoretically be wasteful, in practice custom diagnostics are created
only when they will be emitted. Note: this also fixes
clang/test/CAS/analyze-action.c.
@benlangmuir
Copy link
Author

@swift-ci please test llvm

@cachemeifyoucan
Copy link

Does it work if you only capture the customized diagnostics being emitted if that hasn't been registered before? I think DiagID doesn't have to match between two diagnostics engine? I could miss something or it might not work during the implementation.

@benlangmuir
Copy link
Author

Does it work if you only capture the customized diagnostics being emitted if that hasn't been registered before?

In theory yes, but then we need to keep a mapping between the DiagID in the original engine and whatever we're going to use in the serializer. Registration of custom diagnostics always uses the next available DiagID, so we can't just create an arbitrary mapping, and it needs to be consistent if the same diagnostic is emitted a second time. That seems like an unnecessary complication, which is why I didn't do it. If we find cases where this is a real problem then we can revisit, but in practice custom diagnostics are almost always registered immediately before the first time they are emitted.

@cachemeifyoucan
Copy link

Using a one way mapping from original ID to the ID in serializer is what I am thinking. I guess the usage of customized diagnostics is quite limited and it is fine just put a bit more information into the serialized format.

@benlangmuir benlangmuir merged commit 9c3627d into swiftlang:next Sep 19, 2024
0 of 2 checks passed
@benlangmuir benlangmuir deleted the cache-custom-diags branch September 19, 2024 19:59
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.

3 participants