reminder this is the official swiftc architecture diagram
@Gankra why is clang there?

@wffl their frontend/parser is *literally* clang, and they use that to have very powerful automagic importing of (Obj)-C(++) code.

for instance they can lower simple C defines directly into Swift https://github.com/apple/swift/blob/main/lib/ClangImporter/ImportMacro.cpp

swift/lib/ClangImporter/ImportMacro.cpp at main · apple/swift

The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.

GitHub
@Gankra @wffl This is a little bit misleading. The Swift compiler has its own parser, AST, type checker, and intermediate representation (SIL) with its own optimizer pipeline. Much of that is written in C++, but we're moving toward Swift implementations. The Swift compiler does embed a complete copy of Clang, though, and maps directly from Clang ASTs to Swift ASTs for it's (Objective-)C(++) interoperability, as well as merging in Clang-generated LLVM IR with Swift-generated LLVM IR. We talked about the architecture back in 2014: https://www.youtube.com/watch?v=_xAqf-VwaOM&list=PL_R5A0lGi1ADVUPpI_tPxwxWZNFv_5j4-&index=13&pp=iAQB

@dgregor79 @wffl one of the reasons i like to summarize it as "being clang" was a recollection that a lot of the core types/apis in "swift's own parts" were built on top clang types/apis

(which in principle makes perfect sense, y'all already build a framework for building production-quality compiler front-end, reuse it)

but skimming the code that appears to be less overwhelmingly true than i recall. maybe i just ended up in a very clang-y part, or maybe y'all have diverged a lot more 😅

@Gankra @wffl We’ve basically been rearchitecting the compiler in place over the last few years, toward a lazy-resolution model. The compiler definitely had the feel of Clang early on (can’t imagine why), but that wasn’t a great match for compiling Swift.
@Gankra llvm-ir is stored in the balls