carbon-lang
carbon-lang copied to clipboard
More closely mimic the Clang compilation
Instead of using ASTUnit and tooling APIs, directly mimic what Clang does during the compilation.
Run the Clang frontend until the translation unit parsing is done, at which point switch back to Carbon to finish the Check face and interface with Clang through ASTContext and Sema. In lower, finish the corresponding Clang compilation phase, i.e. CodeGen.
Clang does not have the corresponding APIs and instead provides a callback-based mechanism. To map this back to Carbon APIs, we create a separate thread that gives control back to Carbon through the callbacks, and then finishes the compilation when the Carbon code is done.
Although essentially a hack, this allows to easily fit into the Carbon codebase quickly and we should have an option of refactoring Clang code in LLVM upstream if this approach proves fruitful.
Replace this paragraph with a description of what this PR is changing or adding, and why.
Closes #ISSUE