apple/swift
Fun facts
A few things you can find in this repository if you go looking.
The first commit predates the public Swift launch by four years
The very first commit in this repo:
2010-07-17 23:50:59 +0000 initial swift test
2010-07-18 00:04:11 +0000 initial checkin, nothing much to see here.
2010-07-18 00:48:07 +0000 sketch out lexer and token interfaces.Swift was unveiled at WWDC on 2014-06-02, almost four years after these commits. The repo was open-sourced on 2015-12-03, again with the entire pre-public history preserved.
The docs/Lexicon.md file is half glossary, half dry humor
Real entries from docs/Lexicon.md:
build wrangler — Apple term for "the person assigned to watch CI this week".
DNM — Do not merge. Frequently appearing in commit messages.
reabstraction thunk helpers — small wrapper used when a value's [abstraction pattern] needs to change. (This is where the infamous "reabstraction thunk helpers" sometimes seen in Swift backtraces come from.)
The lexicon is the closest thing Swift has to a curated glossary; it is hand-maintained by compiler engineers and grew organically over a decade.
The largest hand-written source file is a 16,000-line file in Sema
lib/Sema/CSSimplify.cpp (16,668 lines) is the constraint simplifier -- the workhorse of the Hindley-Milner-style type checker. It handles every conversion, overload, and disjunction in the language. Several of its sibling files are also four- and five-digit-line monsters: CSApply.cpp (9,895 lines), CSDiagnostics.cpp (9,800 lines).
The single largest files in the entire repo are stdlib/public/stubs/Unicode/Common/ScalarPropsData.h and stdlib/public/stubs/Unicode/Apple/ScalarPropsData.h at ~26,300 lines each, but those are auto-generated from the Unicode Character Database via utils/gen-unicode-data/.
The stdlib uses Python templates
The standard library has 282 .gyb files. GYB stands for "Generate Your Boilerplate" (utils/gyb.py). It's a Python-based templating language that emits Swift. It exists because Swift's generics didn't always cover variadic generics or integer parameter packs, and writing 28 nearly-identical numeric overloads by hand was unappealing. Try cat stdlib/public/core/Tuple.swift.gyb for the canonical example.
There is a Swift compiler written in Swift, inside the Swift compiler
SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ contains 30+ SIL optimization passes implemented in Swift, calling into bridging code (include/swift/Bridging/) that wraps the C++ SIL data structures. It is, in the literal sense, Swift compiling itself: when you build the compiler from source, an earlier-stage swiftc compiles SwiftCompilerSources/, and the resulting code becomes part of the next-stage compiler.
The repo has a 1,041-file TODO inventory
Across lib/, include/, and stdlib/, 1,041 source files contain a TODO, FIXME, HACK, or XXX comment. Swift contributors have been carefully bookmarking incomplete work for fifteen years; many TODOs reference Swift Evolution proposals, radar bug numbers, or rdar identifiers that survived the GitHub migration.
Naming origins
- SIL -- "Swift Intermediate Language". Distinct from LLVM IR; SIL preserves Swift-specific semantics LLVM cannot represent (ownership, generic signatures, dispatch kind).
- gyb -- "Generate Your Boilerplate" -- a callback to Don't Repeat Yourself.
- shiny -- internal pre-public name for the language; you can occasionally still find it in long-buried comments.
@swift_ci-- the CI bot. Not a person; if you ping@swift_ci please test, an Apple-internal CI farm runs the test matrix.
The driver-of-the-driver
tools/driver/driver.cpp is just five lines of substantive code:
#include "swift/DriverTool/DriverTool.h"
int main(int argc_, const char **argv_) {
return swift::mainEntry(argc_, argv_);
}All of the actual orchestration -- driver vs frontend vs REPL vs swift-package shim -- lives in lib/DriverTool/DriverTool.cpp. The tools/driver/ target is just there because every executable needs a main.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.
Previous
Lore
Next
How to contribute