@@ -653,9 +653,6 @@ static void debugFailWithCrash() {
653
653
LLVM_BUILTIN_TRAP;
654
654
}
655
655
656
- static void emitIndexDataIfNeeded (SourceFile *PrimarySourceFile,
657
- const CompilerInstance &Instance);
658
-
659
656
static void countStatsOfSourceFile (UnifiedStatsReporter &Stats,
660
657
const CompilerInstance &Instance,
661
658
SourceFile *SF) {
@@ -1115,13 +1112,16 @@ static bool performCompileStepsPostSema(CompilerInstance &Instance,
1115
1112
return result;
1116
1113
}
1117
1114
1115
+ static void emitIndexDataForSourceFile (SourceFile *PrimarySourceFile,
1116
+ const CompilerInstance &Instance);
1117
+
1118
1118
// / Emits index data for all primary inputs, or the main module.
1119
1119
static void emitIndexData (const CompilerInstance &Instance) {
1120
1120
if (Instance.getPrimarySourceFiles ().empty ()) {
1121
- emitIndexDataIfNeeded (nullptr , Instance);
1121
+ emitIndexDataForSourceFile (nullptr , Instance);
1122
1122
} else {
1123
1123
for (SourceFile *SF : Instance.getPrimarySourceFiles ())
1124
- emitIndexDataIfNeeded (SF, Instance);
1124
+ emitIndexDataForSourceFile (SF, Instance);
1125
1125
}
1126
1126
}
1127
1127
@@ -1288,12 +1288,13 @@ static bool performCompile(CompilerInstance &Instance,
1288
1288
1289
1289
SWIFT_DEFER {
1290
1290
// We might have freed the ASTContext already, but in that case we must have
1291
- // emitted the dependencies first.
1292
- if (Instance.hasASTContext ())
1291
+ // emitted the dependencies and index first.
1292
+ if (Instance.hasASTContext ()) {
1293
1293
emitReferenceDependenciesForAllPrimaryInputsIfNeeded (Instance);
1294
+ emitIndexData (Instance);
1295
+ }
1294
1296
};
1295
1297
1296
- emitIndexData (Instance);
1297
1298
1298
1299
if (Context.hadError ())
1299
1300
return true ;
@@ -1489,9 +1490,10 @@ static void freeASTContextIfPossible(CompilerInstance &Instance) {
1489
1490
return ;
1490
1491
}
1491
1492
1492
- // Make sure we emit dependencies now, because we can't do it after the
1493
- // context is gone.
1493
+ // Make sure we emit dependencies and index now, because we can't do it after
1494
+ // the context is gone.
1494
1495
emitReferenceDependenciesForAllPrimaryInputsIfNeeded (Instance);
1496
+ emitIndexData (Instance);
1495
1497
1496
1498
Instance.freeASTContext ();
1497
1499
}
@@ -1664,8 +1666,8 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
1664
1666
HadError;
1665
1667
}
1666
1668
1667
- static void emitIndexDataIfNeeded (SourceFile *PrimarySourceFile,
1668
- const CompilerInstance &Instance) {
1669
+ static void emitIndexDataForSourceFile (SourceFile *PrimarySourceFile,
1670
+ const CompilerInstance &Instance) {
1669
1671
const auto &Invocation = Instance.getInvocation ();
1670
1672
const auto &opts = Invocation.getFrontendOptions ();
1671
1673
0 commit comments