[6.0 🍒][Dependency Scanning] Emit diagnostics on scan query failure during initialization or cycle detection #75117
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.
Explanation: [Dependency Scanning] Collect emitted diagnostics per-scan-query #71907 was an important fix that moved the diagnostics collected during dependency scanning to be associated with an individual scan query, instead of scanner overall. This meant that multiple concurrent scans launched by
libSwiftScanclients would have isolated diagnostic domains. However, upon query failure, either when constructing a scanning instance (e.g. un-recognized scanner argument) or upon encountering and diagnosing a dependency cycle, the new per-scan diagnostic state was lost and the scanner query returned an error.This means that scanner clients (SwiftDriver) would no longer see diagnostics from such failures. With this change, on dependency scan query failure, we ensure any diagnostics that the compiler has accumulated along the way are still produced to the client, by constructing a hollow output object that contains just enough state to also carry the diagnostic error payload.
Scope: This change primarily affects Explicit Module Builds (not default, opt-in with
-explicit-module-build) which were already going to fail. On such failures the client would simply get an error from the dependency scanning query without additional context, and will now produce scanner-emitted diagnostics.Risk: Low. Due to the scope of this change being largely limited to compilation tasks which were already going to fail, and only on opt-in Explicit Module Builds
Original PR: [Dependency Scanning] Emit diagnostics on scan query failure during initialization or cycle detection #75111
Issue/Radar: rdar://130897498
Reviewed By: @cachemeifyoucan