Skip to content

embedded: fix source location of diagnostics which appear in imported modules #81502

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 2 commits into from
May 15, 2025

Conversation

eeckstein
Copy link
Contributor

In embedded swift, errors in imported modules can sometimes only be detected when building the client module, because the error can be in a generic function which is specialized in the client module.

To fix this, two changes are required:

  • enable serialization of debug info in embedded mode
  • support source location in diagnostics for de-serialized debug info

rdar://151162353

eeckstein added 2 commits May 14, 2025 11:43
…ug info

Diagnostics only work with `SourceLoc` which is basically a pointer into a buffer of the loaded source file.
But when debug info is de-serialized, the SIL `Location` consists of a filename+line+column.
To "convert" this to a `SourceLoc`, the file must be loaded.
This change adds `DiagnosticEngine.getLocationFromExternalSource` for this purpose.
Also, the new protocol `ProvidingSourceLocation` - to which `SourceLoc` and `Location` conform - help to generalize the helper struct `Diagnostic` and make this "conversion" happen automatically.
This is important to get diagnostics for errors which are located in imported modules.
Such errors can sometimes only be detected when building the client module, because the error can be in a generic function which is specialized in the client module.

rdar://151162353
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

@eeckstein eeckstein merged commit 0d3edd6 into swiftlang:main May 15, 2025
3 checks passed
@eeckstein eeckstein deleted the debug-info-in-embedded branch May 15, 2025 04:58
hamishknight added a commit to hamishknight/swift that referenced this pull request May 22, 2025
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.

1 participant