@@ -156,11 +156,14 @@ class IndexRecordingConsumer : public IndexDataConsumer {
156
156
// we actually need it (once per Decl instead of once per occurrence).
157
157
std::vector<IndexSymbol> symbolStack;
158
158
159
+ bool includeLocals;
160
+
159
161
std::function<void (SymbolTracker &)> onFinish;
160
162
161
163
public:
162
- IndexRecordingConsumer (std::function<void (SymbolTracker &)> onFinish)
163
- : onFinish(std::move(onFinish)) {}
164
+ IndexRecordingConsumer (bool includeLocals,
165
+ std::function<void (SymbolTracker &)> onFinish)
166
+ : includeLocals(includeLocals), onFinish(std::move(onFinish)) {}
164
167
165
168
void failed (StringRef error) override {
166
169
// FIXME: expose errors?
@@ -183,6 +186,8 @@ class IndexRecordingConsumer : public IndexDataConsumer {
183
186
}
184
187
185
188
void finish () override { onFinish (record); }
189
+
190
+ bool indexLocals () override { return includeLocals; }
186
191
};
187
192
188
193
class StdlibGroupsIndexRecordingConsumer : public IndexDataConsumer {
@@ -323,24 +328,25 @@ static bool writeRecord(SymbolTracker &record, std::string Filename,
323
328
324
329
static std::unique_ptr<IndexRecordingConsumer>
325
330
makeRecordingConsumer (std::string Filename, std::string indexStorePath,
326
- DiagnosticEngine *diags,
331
+ bool includeLocals, DiagnosticEngine *diags,
327
332
std::string *outRecordFile,
328
333
bool *outFailed) {
329
- return std::make_unique<IndexRecordingConsumer>([=](SymbolTracker &record) {
334
+ return std::make_unique<IndexRecordingConsumer>(includeLocals,
335
+ [=](SymbolTracker &record) {
330
336
*outFailed = writeRecord (record, Filename, indexStorePath, diags,
331
337
*outRecordFile);
332
338
});
333
339
}
334
340
335
341
static bool
336
342
recordSourceFile (SourceFile *SF, StringRef indexStorePath,
337
- DiagnosticEngine &diags,
343
+ bool includeLocals, DiagnosticEngine &diags,
338
344
llvm::function_ref<void (StringRef, StringRef)> callback) {
339
345
std::string recordFile;
340
346
bool failed = false ;
341
347
auto consumer =
342
348
makeRecordingConsumer (SF->getFilename ().str (), indexStorePath.str (),
343
- &diags, &recordFile, &failed);
349
+ includeLocals, &diags, &recordFile, &failed);
344
350
indexSourceFile (SF, *consumer);
345
351
346
352
if (!failed && !recordFile.empty ())
@@ -379,6 +385,7 @@ emitDataForSwiftSerializedModule(ModuleDecl *module,
379
385
bool indexClangModules,
380
386
bool indexSystemModules,
381
387
bool skipStdlib,
388
+ bool includeLocals,
382
389
StringRef targetTriple,
383
390
const clang::CompilerInstance &clangCI,
384
391
DiagnosticEngine &diags,
@@ -391,6 +398,7 @@ static void addModuleDependencies(ArrayRef<ImportedModule> imports,
391
398
bool indexClangModules,
392
399
bool indexSystemModules,
393
400
bool skipStdlib,
401
+ bool includeLocals,
394
402
StringRef targetTriple,
395
403
const clang::CompilerInstance &clangCI,
396
404
DiagnosticEngine &diags,
@@ -448,7 +456,8 @@ static void addModuleDependencies(ArrayRef<ImportedModule> imports,
448
456
emitDataForSwiftSerializedModule (mod, indexStorePath,
449
457
indexClangModules,
450
458
indexSystemModules, skipStdlib,
451
- targetTriple, clangCI, diags,
459
+ includeLocals, targetTriple,
460
+ clangCI, diags,
452
461
unitWriter,
453
462
pathRemapper,
454
463
initialFile);
@@ -479,6 +488,7 @@ emitDataForSwiftSerializedModule(ModuleDecl *module,
479
488
bool indexClangModules,
480
489
bool indexSystemModules,
481
490
bool skipStdlib,
491
+ bool includeLocals,
482
492
StringRef targetTriple,
483
493
const clang::CompilerInstance &clangCI,
484
494
DiagnosticEngine &diags,
@@ -514,7 +524,7 @@ emitDataForSwiftSerializedModule(ModuleDecl *module,
514
524
std::string recordFile;
515
525
bool failed = false ;
516
526
auto consumer = makeRecordingConsumer (filename.str (), indexStorePath.str (),
517
- &diags, &recordFile, &failed);
527
+ includeLocals, &diags, &recordFile, &failed);
518
528
indexModule (module , *consumer);
519
529
520
530
if (failed)
@@ -602,9 +612,9 @@ emitDataForSwiftSerializedModule(ModuleDecl *module,
602
612
ModuleDecl::ImportFilterKind::Default});
603
613
StringScratchSpace moduleNameScratch;
604
614
addModuleDependencies (imports, indexStorePath, indexClangModules,
605
- indexSystemModules, skipStdlib, targetTriple, clangCI ,
606
- diags, unitWriter, moduleNameScratch, pathRemapper ,
607
- initialFile);
615
+ indexSystemModules, skipStdlib, includeLocals ,
616
+ targetTriple, clangCI, diags, unitWriter ,
617
+ moduleNameScratch, pathRemapper, initialFile);
608
618
609
619
if (unitWriter.write (error)) {
610
620
diags.diagnose (SourceLoc (), diag::error_write_index_unit, error);
@@ -618,7 +628,8 @@ static bool
618
628
recordSourceFileUnit (SourceFile *primarySourceFile, StringRef indexUnitToken,
619
629
StringRef indexStorePath, bool indexClangModules,
620
630
bool indexSystemModules, bool skipStdlib,
621
- bool isDebugCompilation, StringRef targetTriple,
631
+ bool includeLocals, bool isDebugCompilation,
632
+ StringRef targetTriple,
622
633
ArrayRef<const clang::FileEntry *> fileDependencies,
623
634
const clang::CompilerInstance &clangCI,
624
635
const PathRemapper &pathRemapper,
@@ -645,15 +656,15 @@ recordSourceFileUnit(SourceFile *primarySourceFile, StringRef indexUnitToken,
645
656
ModuleDecl::ImportFilterKind::ImplementationOnly});
646
657
StringScratchSpace moduleNameScratch;
647
658
addModuleDependencies (imports, indexStorePath, indexClangModules,
648
- indexSystemModules, skipStdlib, targetTriple, clangCI ,
649
- diags, unitWriter, moduleNameScratch, pathRemapper ,
650
- primarySourceFile);
659
+ indexSystemModules, skipStdlib, includeLocals ,
660
+ targetTriple, clangCI, diags, unitWriter ,
661
+ moduleNameScratch, pathRemapper, primarySourceFile);
651
662
652
663
// File dependencies.
653
664
for (auto *F : fileDependencies)
654
665
unitWriter.addFileDependency (F, /* FIXME:isSystem=*/ false , /* Module=*/ nullptr );
655
666
656
- recordSourceFile (primarySourceFile, indexStorePath, diags,
667
+ recordSourceFile (primarySourceFile, indexStorePath, includeLocals, diags,
657
668
[&](StringRef recordFile, StringRef filename) {
658
669
auto file = fileMgr.getFile (filename);
659
670
unitWriter.addRecordFile (
@@ -700,6 +711,7 @@ bool index::indexAndRecord(SourceFile *primarySourceFile,
700
711
bool indexClangModules,
701
712
bool indexSystemModules,
702
713
bool skipStdlib,
714
+ bool includeLocals,
703
715
bool isDebugCompilation,
704
716
StringRef targetTriple,
705
717
const DependencyTracker &dependencyTracker,
@@ -729,7 +741,7 @@ bool index::indexAndRecord(SourceFile *primarySourceFile,
729
741
730
742
return recordSourceFileUnit (primarySourceFile, indexUnitToken,
731
743
indexStorePath, indexClangModules,
732
- indexSystemModules, skipStdlib,
744
+ indexSystemModules, skipStdlib, includeLocals,
733
745
isDebugCompilation, targetTriple,
734
746
fileDependencies.getArrayRef (),
735
747
clangCI, pathRemapper, diags);
@@ -742,6 +754,7 @@ bool index::indexAndRecord(ModuleDecl *module,
742
754
bool indexClangModules,
743
755
bool indexSystemModules,
744
756
bool skipStdlib,
757
+ bool includeLocals,
745
758
bool isDebugCompilation,
746
759
StringRef targetTriple,
747
760
const DependencyTracker &dependencyTracker,
@@ -779,7 +792,7 @@ bool index::indexAndRecord(ModuleDecl *module,
779
792
}
780
793
if (recordSourceFileUnit (SF, indexUnitTokens[unitIndex],
781
794
indexStorePath, indexClangModules,
782
- indexSystemModules, skipStdlib,
795
+ indexSystemModules, skipStdlib, includeLocals,
783
796
isDebugCompilation, targetTriple,
784
797
fileDependencies.getArrayRef (),
785
798
clangCI, pathRemapper, diags))
0 commit comments