[SourceKit] Use req options instead of compiler arguments for controlling index-to-store behavior

This commit is contained in:
Sam Kortekaas
2024-01-11 13:30:43 +01:00
parent 4c7e02d80a
commit 1fe5f04574
4 changed files with 66 additions and 29 deletions

View File

@@ -370,12 +370,11 @@ void SwiftLangSupport::indexSource(StringRef InputFile,
}
static void emitIndexDataForSourceFile(SourceFile &PrimarySourceFile,
StringRef IndexStorePath,
StringRef IndexUnitOutputPath,
bool IncludeLocals,
IndexStoreOptions IndexOpts,
const CompilerInstance &Instance) {
const auto &Invocation = Instance.getInvocation();
const auto &Opts = Invocation.getFrontendOptions();
// FIXME: Compiler arguments should be the default for setting options, but this is currently broken (see PR #69076)
// const auto &Opts = Invocation.getFrontendOptions();
bool isDebugCompilation;
switch (Invocation.getSILOptions().OptMode) {
@@ -389,14 +388,15 @@ static void emitIndexDataForSourceFile(SourceFile &PrimarySourceFile,
break;
}
(void) index::indexAndRecord(&PrimarySourceFile, IndexUnitOutputPath,
IndexStorePath,
!Opts.IndexIgnoreClangModules,
Opts.IndexSystemModules,
Opts.IndexIgnoreStdlib,
IncludeLocals,
(void) index::indexAndRecord(&PrimarySourceFile,
IndexOpts.IndexUnitOutputPath,
IndexOpts.IndexStorePath,
!IndexOpts.IgnoreClangModules,
IndexOpts.IncludeSystemModules,
IndexOpts.IgnoreStdlib,
IndexOpts.IncludeLocals,
isDebugCompilation,
Opts.DisableImplicitModules,
IndexOpts.DisableImplicitModules,
Invocation.getTargetTriple(),
*Instance.getDependencyTracker(),
Invocation.getIRGenOptions().FilePrefixMap);
@@ -426,9 +426,7 @@ void SwiftLangSupport::indexToStore(
void handlePrimaryAST(ASTUnitRef AstUnit) override {
auto &SF = AstUnit->getPrimarySourceFile();
auto &CI = AstUnit->getCompilerInstance();
emitIndexDataForSourceFile(SF, Opts.IndexStorePath,
Opts.IndexUnitOutputPath, Opts.IncludeLocals,
CI);
emitIndexDataForSourceFile(SF, Opts, CI);
Receiver(RequestResult<IndexStoreInfo>::fromResult(IndexStoreInfo{}));
}