[SourceKit] For the swift header interface request, accept the swift version as a string

This is so we can pass the version as "4.2".

rdar://38673625
This commit is contained in:
Argyrios Kyrtzidis
2018-03-22 16:32:24 -07:00
parent 2866f0e0a6
commit 455e87bd96
9 changed files with 54 additions and 26 deletions

View File

@@ -805,7 +805,7 @@ void SwiftLangSupport::editorOpenHeaderInterface(EditorConsumer &Consumer,
ArrayRef<const char *> Args,
bool UsingSwiftArgs,
bool SynthesizedExtensions,
Optional<unsigned> swiftVersion) {
StringRef swiftVersion) {
CompilerInstance CI;
// Display diagnostics to stderr.
PrintingDiagnosticConsumer PrintDiags;
@@ -838,9 +838,12 @@ void SwiftLangSupport::editorOpenHeaderInterface(EditorConsumer &Consumer,
}
Invocation.getClangImporterOptions().ImportForwardDeclarations = true;
if (swiftVersion.hasValue()) {
auto swiftVer = version::Version({swiftVersion.getValue()});
Invocation.getLangOptions().EffectiveLanguageVersion = swiftVer;
if (!swiftVersion.empty()) {
auto swiftVer = version::Version::parseVersionString(swiftVersion,
SourceLoc(), nullptr);
if (swiftVer.hasValue())
Invocation.getLangOptions().EffectiveLanguageVersion =
swiftVer.getValue();
}
auto IFaceGenRef = SwiftInterfaceGenContext::create(Name,
/*IsModule=*/false,