docs/rationale/swift-whole-module-entries.md
Swift's swiftc driver supports whole-module compilation: a single
invocation can name every .swift source of a module
(swiftc -module-name App -wmo a.swift b.swift c.swift), and the
frontend analyzes them together instead of one at a time. This is the
same "single invocation, multiple sources" shape Bear already handles
for valac, but the consumer that motivates Swift support wants a
different entry shape for it.
Three candidate entry shapes were considered, matching the shapes Bear already produces for other families:
file set to the first source, every source retained. This matches
what a genuine single-translation-unit compiler does (valac
produces one library from many sources), but Swift's per-file
editor tooling looks up a compile command by file path -- only one
file (the first source) gets an entry, so every other source in the
module has no compile command SourceKit-LSP can find for it.Bear emits shape 3 for Swift: one entry per source file, with every
entry's argument list equal to the complete invocation (all sources,
all flags -- only link-only flags are stripped, same as every other
family). This is a distinct converter mode, not a variant of the
existing separable/combined boolean: the per-invocation flag on
semantic::Command becomes a three-way mode (stripped-per-source /
per-source-full / combined) instead of growing a second, orthogonal
flag that every call site would have to reason about in combination.
swift-frontend (and a legacy swiftc -frontend self-invocation)
internal per-file jobs are filtered by ignore_when, the same
mechanism already used for GCC's cc1 and Clang's -cc1 -- no new
filtering mechanism was needed.recognition-compiler-names