@@ -653,8 +653,7 @@ static void debugFailWithCrash() {
653
653
LLVM_BUILTIN_TRAP;
654
654
}
655
655
656
- // / \return true on error.
657
- static bool emitIndexDataIfNeeded (SourceFile *PrimarySourceFile,
656
+ static void emitIndexDataIfNeeded (SourceFile *PrimarySourceFile,
658
657
const CompilerInvocation &Invocation,
659
658
const CompilerInstance &Instance);
660
659
@@ -1144,15 +1143,14 @@ static bool performCompileStepsPostSema(const CompilerInvocation &Invocation,
1144
1143
}
1145
1144
1146
1145
// / Emits index data for all primary inputs, or the main module.
1147
- static bool
1146
+ static void
1148
1147
emitIndexData (const CompilerInvocation &Invocation, const CompilerInstance &Instance) {
1149
- bool hadEmitIndexDataError = false ;
1150
1148
if (Instance.getPrimarySourceFiles ().empty ())
1151
- return emitIndexDataIfNeeded (nullptr , Invocation, Instance);
1152
- for (SourceFile *SF : Instance. getPrimarySourceFiles ())
1153
- hadEmitIndexDataError = emitIndexDataIfNeeded (SF, Invocation, Instance) ||
1154
- hadEmitIndexDataError ;
1155
- return hadEmitIndexDataError;
1149
+ emitIndexDataIfNeeded (nullptr , Invocation, Instance);
1150
+ else {
1151
+ for (SourceFile *SF : Instance. getPrimarySourceFiles ())
1152
+ emitIndexDataIfNeeded (SF, Invocation, Instance) ;
1153
+ }
1156
1154
}
1157
1155
1158
1156
// / Emits all "one-per-module" supplementary outputs that don't depend on
@@ -1317,19 +1315,16 @@ static bool performCompile(CompilerInstance &Instance,
1317
1315
emitSwiftRangesForAllPrimaryInputsIfNeeded (Invocation, Instance);
1318
1316
emitCompiledSourceForAllPrimaryInputsIfNeeded (Invocation, Instance);
1319
1317
1320
- if (Context. hadError ()) {
1321
- // Emit the index store data even if there were compiler errors.
1322
- ( void ) emitIndexData (Invocation, Instance);
1318
+ emitIndexData (Invocation, Instance);
1319
+
1320
+ if (Context. hadError ())
1323
1321
return true ;
1324
- }
1325
1322
1326
1323
(void )emitLoadedModuleTraceForAllPrimariesIfNeeded (
1327
1324
Instance.getMainModule (), Instance.getDependencyTracker (), opts);
1328
1325
1329
1326
// We've just been told to perform a typecheck, so we can return now.
1330
1327
if (Action == FrontendOptions::ActionType::Typecheck) {
1331
- if (emitIndexData (Invocation, Instance))
1332
- return true ;
1333
1328
// FIXME: Whole-module outputs with a non-whole-module -typecheck ought to
1334
1329
// be disallowed, but the driver implements -index-file mode by generating a
1335
1330
// regular whole-module frontend command line and modifying it to index just
@@ -1641,17 +1636,10 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
1641
1636
if (Action == FrontendOptions::ActionType::EmitSIB)
1642
1637
return serializeSIB (SM.get (), PSPs, Context, MSF);
1643
1638
1644
- {
1645
- if (PSPs.haveModuleOrModuleDocOutputPaths ()) {
1646
- if (Action == FrontendOptions::ActionType::MergeModules ||
1647
- Action == FrontendOptions::ActionType::EmitModuleOnly) {
1648
- // What if MSF is a module?
1649
- // emitIndexDataIfNeeded already handles that case;
1650
- // it'll index everything.
1651
- return emitIndexDataIfNeeded (MSF.dyn_cast <SourceFile *>(), Invocation,
1652
- Instance) ||
1653
- Context.hadError ();
1654
- }
1639
+ if (PSPs.haveModuleOrModuleDocOutputPaths ()) {
1640
+ if (Action == FrontendOptions::ActionType::MergeModules ||
1641
+ Action == FrontendOptions::ActionType::EmitModuleOnly) {
1642
+ return Context.hadError ();
1655
1643
}
1656
1644
}
1657
1645
@@ -1703,11 +1691,6 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
1703
1691
IRGenOpts, std::move (SM), PSPs, OutputFilename, MSF, HashGlobal,
1704
1692
ParallelOutputFilenames, LinkerDirectives);
1705
1693
1706
- // Walk the AST for indexing after IR generation. Walking it before seems
1707
- // to cause miscompilation issues.
1708
- if (emitIndexDataIfNeeded (MSF.dyn_cast <SourceFile *>(), Invocation, Instance))
1709
- return true ;
1710
-
1711
1694
// Just because we had an AST error it doesn't mean we can't performLLVM.
1712
1695
bool HadError = Instance.getASTContext ().hadError ();
1713
1696
@@ -1726,13 +1709,13 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
1726
1709
HadError;
1727
1710
}
1728
1711
1729
- static bool emitIndexDataIfNeeded (SourceFile *PrimarySourceFile,
1712
+ static void emitIndexDataIfNeeded (SourceFile *PrimarySourceFile,
1730
1713
const CompilerInvocation &Invocation,
1731
1714
const CompilerInstance &Instance) {
1732
1715
const FrontendOptions &opts = Invocation.getFrontendOptions ();
1733
1716
1734
1717
if (opts.IndexStorePath .empty ())
1735
- return false ;
1718
+ return ;
1736
1719
1737
1720
// FIXME: provide index unit token(s) explicitly and only use output file
1738
1721
// paths as a fallback.
@@ -1753,29 +1736,23 @@ static bool emitIndexDataIfNeeded(SourceFile *PrimarySourceFile,
1753
1736
const PrimarySpecificPaths &PSPs =
1754
1737
opts.InputsAndOutputs .getPrimarySpecificPathsForPrimary (
1755
1738
PrimarySourceFile->getFilename ());
1756
- if (index ::indexAndRecord (PrimarySourceFile, PSPs.OutputFilename ,
1757
- opts.IndexStorePath , opts.IndexSystemModules ,
1758
- opts.IndexIgnoreStdlib , isDebugCompilation,
1759
- Invocation.getTargetTriple (),
1760
- *Instance.getDependencyTracker ())) {
1761
- return true ;
1762
- }
1739
+ (void ) index ::indexAndRecord (PrimarySourceFile, PSPs.OutputFilename ,
1740
+ opts.IndexStorePath , opts.IndexSystemModules ,
1741
+ opts.IndexIgnoreStdlib , isDebugCompilation,
1742
+ Invocation.getTargetTriple (),
1743
+ *Instance.getDependencyTracker ());
1763
1744
} else {
1764
1745
std::string moduleToken =
1765
1746
Invocation.getModuleOutputPathForAtMostOnePrimary ();
1766
1747
if (moduleToken.empty ())
1767
1748
moduleToken = opts.InputsAndOutputs .getSingleOutputFilename ();
1768
1749
1769
- if (index ::indexAndRecord (Instance.getMainModule (), opts.InputsAndOutputs .copyOutputFilenames (),
1770
- moduleToken, opts.IndexStorePath ,
1771
- opts.IndexSystemModules , opts.IndexIgnoreStdlib ,
1772
- isDebugCompilation, Invocation.getTargetTriple (),
1773
- *Instance.getDependencyTracker ())) {
1774
- return true ;
1775
- }
1750
+ (void ) index ::indexAndRecord (Instance.getMainModule (), opts.InputsAndOutputs .copyOutputFilenames (),
1751
+ moduleToken, opts.IndexStorePath ,
1752
+ opts.IndexSystemModules , opts.IndexIgnoreStdlib ,
1753
+ isDebugCompilation, Invocation.getTargetTriple (),
1754
+ *Instance.getDependencyTracker ());
1776
1755
}
1777
-
1778
- return false ;
1779
1756
}
1780
1757
1781
1758
// / Returns true if an error occurred.
0 commit comments