[SourceKit] Accept swift_version in requests and use to set the swift version for interface generation of an ObjC header

rdar://31432960
This commit is contained in:
Argyrios Kyrtzidis
2017-05-04 16:53:00 -07:00
parent 0db10e9b60
commit 896c4645df
15 changed files with 302 additions and 8 deletions

View File

@@ -16,6 +16,7 @@
#include "swift/AST/ASTPrinter.h"
#include "swift/AST/ASTWalker.h"
#include "swift/Basic/Version.h"
#include "swift/Frontend/Frontend.h"
#include "swift/Frontend/PrintingDiagnosticConsumer.h"
#include "swift/IDE/ModuleInterfacePrinting.h"
@@ -800,7 +801,8 @@ void SwiftLangSupport::editorOpenHeaderInterface(EditorConsumer &Consumer,
StringRef Name,
StringRef HeaderName,
ArrayRef<const char *> Args,
bool SynthesizedExtensions) {
bool SynthesizedExtensions,
Optional<unsigned> swiftVersion) {
CompilerInstance CI;
// Display diagnostics to stderr.
PrintingDiagnosticConsumer PrintDiags;
@@ -831,6 +833,10 @@ void SwiftLangSupport::editorOpenHeaderInterface(EditorConsumer &Consumer,
}
Invocation.getClangImporterOptions().ImportForwardDeclarations = true;
if (swiftVersion.hasValue()) {
auto swiftVer = version::Version({swiftVersion.getValue()});
Invocation.getLangOptions().EffectiveLanguageVersion = swiftVer;
}
auto IFaceGenRef = SwiftInterfaceGenContext::create(Name,
/*IsModule=*/false,
HeaderName,