mirror of
https://github.com/apple/swift.git
synced 2026-10-24 20:15:56 +02:00
Avoiding the duplicate `cannot_find_module_version` diagnostics routed `ExportedSourceFile.configuredRegions(astContext:)` through the side-effect-free `.analyzing` canImport query. For the default C++ parser that is always correct: its `EvaluateIfConditionRequest` remains the canonical site that emits the diagnostic and records the result in `CanImportModuleVersions`, and the configured-regions walk is only a secondary re-derivation used for various compiler analysis clients (e.g. warning group control). In ASTGen-only mode (`-enable-experimental-feature ParserASTGen`) the C++ parser, and therefore `EvaluateIfConditionRequest`, never runs; the configured-regions walk is the only evaluation that drives `canImport`. Routing it through `.analyzing` consequently suppressed the diagnostic. This change adds `swift_ASTGen_evaluateConfiguredRegionsForDiagnostics`, invoked once at the start of `parseSourceFileViaASTGen`, which evaluates the file's `#if` directives in `.driving` mode to emit the diagnostics and populate the version cache before any analysis path consumes the configured-regions cache.