[clang] [ASTWriter] Do not allocate source location space for module maps used only for textual headers (PR #116374)
Boaz Brickner via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 20 06:02:50 PST 2024
================
@@ -184,14 +184,30 @@ GetAffectingModuleMaps(const Preprocessor &PP, Module *RootModule) {
const SourceManager &SM = PP.getSourceManager();
const ModuleMap &MM = HS.getModuleMap();
- llvm::DenseSet<FileID> ModuleMaps;
-
- llvm::DenseSet<const Module *> ProcessedModules;
- auto CollectModuleMapsForHierarchy = [&](const Module *M) {
+ // Module maps used only by textual headers are special. Their FileID is
+ // non-affecting, but their FileEntry is (i.e. must be written as InputFile).
+ enum AffectedReason : bool {
+ ARTextualHeader = 0,
+ ARImportOrTextualHeader = 1,
+ };
+ auto AssignMostImportant = [](AffectedReason &L, AffectedReason R) {
+ L = std::max(L, R);
+ };
----------------
bricknerb wrote:
Seems like using `LHS` and `RHS` is more common (and more readable IMO) in Clang than `L` and `R`.
```suggestion
auto AssignMostImportant = [](AffectedReason &LHS, AffectedReason RHS) {
LHS = std::max(LHS, RHS);
};
```
https://github.com/llvm/llvm-project/pull/116374
More information about the cfe-commits
mailing list