[4.2] Fixes for batch mode diagnostics in Xcode #16529
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-pick of
for the purpose of improving diagnostics in Xcode.
This is fallout from #14900, which was the first attempt to deal with batch mode being different from single-file mode in terms of what diagnostics get produced and where. There was a hole in that scheme, however: if processing B.swift results in a diagnostic being emitted in A.swift (and B.swift and A.swift are in different batches), that diagnostic would appear in every file in the same batch as B.swift. This (1) looks bad in Xcode's Log Editor, and (2) could result in a diagnostic that never goes away. (How? Fix the problem in A.swift, and A.swift and B.swift will get rebuilt…but not necessarily other files in B.swift's original batch.)
These changes together attempt to enforce two rules:
every diagnostic emitted in file A.swift while processing a different file B.swift would be emitted if we processed A.swift on its own
we actually do process A.swift on its own in the same build (or have previously done an incremental build and produced the same diagnostic)
and use those guarantees to avoid emitting diagnostics located in A.swift altogether if A.swift isn't in the current batch.