Add "-swift-version <n>" that sets LangOpts.EffectiveLanguageVersion.

This flag switches the "effective language version" of the compiler,
at least to any version supported (as of this change: "3" or "3.0").

At the moment nothing uses it except the language version build
configuration statements (#if swift(...)) and various other places
that report, encode, or otherwise check version numbers.

In the future, it's intended as scaffolding for backwards compatibility.

Fixes SR-2582
This commit is contained in:
Graydon Hoare
2016-09-20 15:11:37 -07:00
parent 04b7201431
commit 8970d44675
16 changed files with 133 additions and 22 deletions

View File

@@ -765,6 +765,18 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
const FrontendOptions &FrontendOpts) {
using namespace options;
if (auto A = Args.getLastArg(OPT_swift_version)) {
auto vers = version::Version::parseVersionString(
A->getValue(), SourceLoc(), &Diags);
if (vers.hasValue() &&
vers.getValue().isValidEffectiveLanguageVersion()) {
Opts.EffectiveLanguageVersion = vers.getValue();
} else {
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
A->getAsString(Args), A->getValue());
}
}
Opts.AttachCommentsToDecls |= Args.hasArg(OPT_dump_api_path);
Opts.UseMalloc |= Args.hasArg(OPT_use_malloc);