Skip to content

Commit 392ba00

Browse files
authored
Merge pull request swiftlang#38211 from xymus/incr-info-and-emit-module
[Frontend] Emit incremental compilation info from some emit-module jobs
2 parents cf71dc9 + 6fd9102 commit 392ba00

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lib/AST/Module.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,11 @@ void SourceLookupCache::populateMemberCache(const ModuleDecl &Mod) {
276276
"populate-module-class-member-cache");
277277

278278
for (const FileUnit *file : Mod.getFiles()) {
279-
auto &SF = *cast<SourceFile>(file);
280-
addToMemberCache(SF.getTopLevelDecls());
279+
assert(isa<SourceFile>(file) ||
280+
isa<SynthesizedFileUnit>(file));
281+
SmallVector<Decl *, 8> decls;
282+
file->getTopLevelDecls(decls);
283+
addToMemberCache(decls);
281284
}
282285

283286
MemberCachePopulated = true;

lib/FrontendTool/FrontendTool.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,9 +1494,19 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
14941494
SerializationOptions serializationOpts =
14951495
Invocation.computeSerializationOptions(outs, Instance.getMainModule());
14961496

1497+
// Infer if this is an emit-module job part of an incremental build,
1498+
// vs a partial emit-module job (with primary files) or other kinds.
1499+
// We may want to rely on a flag instead to differentiate them.
1500+
const bool isEmitModuleSeparately =
1501+
Action == FrontendOptions::ActionType::EmitModuleOnly &&
1502+
MSF.is<ModuleDecl *>() &&
1503+
Instance.getInvocation()
1504+
.getTypeCheckerOptions()
1505+
.SkipFunctionBodies == FunctionBodySkipping::NonInlinableWithoutTypes;
14971506
const bool canEmitIncrementalInfoIntoModule =
14981507
!serializationOpts.DisableCrossModuleIncrementalInfo &&
1499-
(Action == FrontendOptions::ActionType::MergeModules);
1508+
(Action == FrontendOptions::ActionType::MergeModules ||
1509+
isEmitModuleSeparately);
15001510
if (canEmitIncrementalInfoIntoModule) {
15011511
const auto alsoEmitDotFile =
15021512
Instance.getInvocation()

0 commit comments

Comments
 (0)