[SourceKit] Use "-" as fallback complier argument

Since compiler arguments are processed by Driver, arbitrary filename
passed as 'request.name' (e.g. "", "-1", etc.) may cause problems.
Using '-' guarantees successful initialization of 'CompilerInvocation'.

rdar://problem/40646921
rdar://problem/40955808
This commit is contained in:
Rintaro Ishizaki
2018-07-02 13:42:33 +09:00
parent 471af31c31
commit 2b0728bc95
2 changed files with 5 additions and 2 deletions

View File

@@ -1749,8 +1749,11 @@ void SwiftEditorDocument::parse(ImmutableTextSnapshotRef Snapshot,
Impl.SemanticInfo->getInvocation()->applyTo(CompInv);
Impl.SemanticInfo->getInvocation()->raw(Args, PrimaryFile);
} else {
// Use stdin as a .swift input to satisfy the driver. Note that we don't
// use Impl.FilePath here because it may be invalid filename for driver
// like "" or "-foobar".
SmallVector<const char *, 1> Args;
Args.push_back(Impl.FilePath.c_str()); // Input
Args.push_back("-");
std::string Error;
// Ignore possible error(s)
Lang.getASTManager().