[all-commits] [llvm/llvm-project] f5fdd4: [clang] Refactor `ASTUnit::LoadFromASTFile()` (#16...
Jan Svoboda via All-commits
all-commits at lists.llvm.org
Wed Oct 22 14:42:59 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f5fdd43b16192bb85beb43e6cfe8d5e12a3ba976
https://github.com/llvm/llvm-project/commit/f5fdd43b16192bb85beb43e6cfe8d5e12a3ba976
Author: Jan Svoboda <jan_svoboda at apple.com>
Date: 2025-10-22 (Wed, 22 Oct 2025)
Changed paths:
M clang/lib/Frontend/ASTUnit.cpp
M clang/lib/Serialization/ASTReader.cpp
Log Message:
-----------
[clang] Refactor `ASTUnit::LoadFromASTFile()` (#164265)
This PR refactors `ASTUnit::LoadFromASTFile()` to be easier to follow.
Conceptually, it tries to read an AST file, adopt the serialized
options, and set up `Sema` and `ASTContext` to deserialize the AST file
contents on-demand.
The implementation of this used to be spread across an
`ASTReaderListener` and the function in question. Figuring out what
listener method gets called when and how it's supposed to interact with
the rest of the functionality was very unclear. The `FileManager`'s VFS
was being swapped-out during deserialization, the options were being
adopted by `Preprocessor` and others just-in-time to pass `ASTReader`'s
validation checks, and the target was being initialized somewhere in
between all of this. This lead to a very muddy semantics.
This PR splits `ASTUnit::LoadFromASTFile()` into three distinct steps:
1. Read out the options from the AST file.
2. Initialize objects from the VFS to the `ASTContext`.
3. Load the AST file and hook it up with the compiler objects.
This should be much easier to understand, and I've done my best to
clearly document the remaining gotchas.
(This was originally motivated by the desire to remove
`FileManager::setVirtualFileSystem()` and make it impossible to swap out
VFSs from underneath `FileManager` mid-compile.)
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list