mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SourceKit] Explicitly specify frontend action type when creating compiler invocation
Explicitly specify the frontend action to make sure we aren’t loading thes stdlib if the performed action is syntactic only.
This commit is contained in:
@@ -1417,7 +1417,8 @@ void SwiftLangSupport::findLocalRenameRanges(
|
||||
ArrayRef<const char *> Args, SourceKitCancellationToken CancellationToken,
|
||||
CategorizedRenameRangesReceiver Receiver) {
|
||||
std::string Error;
|
||||
SwiftInvocationRef Invok = ASTMgr->getInvocation(Args, Filename, Error);
|
||||
SwiftInvocationRef Invok =
|
||||
ASTMgr->getTypecheckInvocation(Args, Filename, Error);
|
||||
if (!Invok) {
|
||||
LOG_WARN_FUNC("failed to create an ASTInvocation: " << Error);
|
||||
Receiver(RequestResult<ArrayRef<CategorizedRenameRanges>>::fromError(Error));
|
||||
@@ -1465,7 +1466,8 @@ SourceFile *SwiftLangSupport::getSyntacticSourceFile(
|
||||
CompilerInvocation Invocation;
|
||||
|
||||
bool Failed = getASTManager()->initCompilerInvocationNoInputs(
|
||||
Invocation, Args, ParseCI.getDiags(), Error);
|
||||
Invocation, Args, FrontendOptions::ActionType::Parse, ParseCI.getDiags(),
|
||||
Error);
|
||||
if (Failed) {
|
||||
Error = "Compiler invocation init failed";
|
||||
return nullptr;
|
||||
@@ -1518,7 +1520,8 @@ void SwiftLangSupport::getDocInfo(llvm::MemoryBuffer *InputBuf,
|
||||
CompilerInvocation Invocation;
|
||||
std::string Error;
|
||||
bool Failed = getASTManager()->initCompilerInvocationNoInputs(
|
||||
Invocation, Args, CI.getDiags(), Error, /*AllowInputs=*/false);
|
||||
Invocation, Args, FrontendOptions::ActionType::Typecheck, CI.getDiags(),
|
||||
Error, /*AllowInputs=*/false);
|
||||
|
||||
if (Failed) {
|
||||
Consumer.failed(Error);
|
||||
@@ -1551,8 +1554,9 @@ findModuleGroups(StringRef ModuleName, ArrayRef<const char *> Args,
|
||||
PrintingDiagnosticConsumer PrintDiags;
|
||||
CI.addDiagnosticConsumer(&PrintDiags);
|
||||
std::string Error;
|
||||
if (getASTManager()->initCompilerInvocationNoInputs(Invocation, Args,
|
||||
CI.getDiags(), Error)) {
|
||||
if (getASTManager()->initCompilerInvocationNoInputs(
|
||||
Invocation, Args, FrontendOptions::ActionType::Typecheck,
|
||||
CI.getDiags(), Error)) {
|
||||
Receiver(RequestResult<ArrayRef<StringRef>>::fromError(Error));
|
||||
return;
|
||||
}
|
||||
@@ -1563,12 +1567,6 @@ findModuleGroups(StringRef ModuleName, ArrayRef<const char *> Args,
|
||||
|
||||
// Load standard library so that Clang importer can use it.
|
||||
ASTContext &Ctx = CI.getASTContext();
|
||||
auto *Stdlib = Ctx.getModuleByIdentifier(Ctx.StdlibModuleName);
|
||||
if (!Stdlib) {
|
||||
Error = "Cannot load stdlib.";
|
||||
Receiver(RequestResult<ArrayRef<StringRef>>::fromError(Error));
|
||||
return;
|
||||
}
|
||||
auto *M = Ctx.getModuleByName(ModuleName);
|
||||
if (!M) {
|
||||
Error = "Cannot find the module.";
|
||||
|
||||
Reference in New Issue
Block a user