SE-0020: Swift Language Version Build Configuration

Introduce a new "swift" build configuration that guards declarations
and statements with a language version - if the current language version
of the compiler is at least that version, the block will parse as normal.
For inactive blocks, the code will not be parsed an no diagnostics will
be emitted there.

Example:

    #if swift(>=2.2)
      print("Active")
    #else
      this code will not parse or emit diagnostics
    #endif

https://github.com/apple/swift-evolution/blob/master/proposals/0020-if-swift-version.md
rdar://problem/19823607
This commit is contained in:
David Farler
2015-12-17 16:25:15 -08:00
parent ec172cde5b
commit c32fb8e7b9
10 changed files with 263 additions and 133 deletions

View File

@@ -97,15 +97,19 @@ public:
/// Parse a generic version string of the format [0-9]+(.[0-9]+)*
///
/// Version components can be any unsigned 64-bit number.
static Version parseVersionString(llvm::StringRef VersionString,
SourceLoc Loc,
DiagnosticEngine *Diags);
static Optional<Version> parseVersionString(llvm::StringRef VersionString,
SourceLoc Loc,
DiagnosticEngine *Diags);
/// Returns a version from the currently defined SWIFT_COMPILER_VERSION.
///
/// If SWIFT_COMPILER_VERSION is undefined, this will return the empty
/// compiler version.
static Version getCurrentCompilerVersion();
/// Returns a version from the currently defined SWIFT_VERSION_MAJOR and
/// SWIFT_VERSION_MAJOR.
static Version getCurrentLanguageVersion();
};
bool operator>=(const Version &lhs, const Version &rhs);