Files
swift-mirror/include/swift/Parse/ParseVersion.h
Ben Barham ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00

51 lines
1.7 KiB
C++

//===--- ParseVersion.h - Parser Swift Version Numbers ----------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_PARSE_PARSEVERSION_H
#define SWIFT_PARSE_PARSEVERSION_H
#include "swift/Basic/Version.h"
namespace swift {
class DiagnosticEngine;
namespace version {
/// Returns a version from the currently defined SWIFT_COMPILER_VERSION.
///
/// If SWIFT_COMPILER_VERSION is undefined, this will return the empty
/// compiler version.
Version getCurrentCompilerVersion();
} // namespace version
class VersionParser final {
public:
/// Parse a version in the form used by the _compiler_version(string-literal)
/// \#if condition.
///
/// \note This is \em only used for the string literal version, so it includes
/// backwards-compatibility logic to convert it to something that can be
/// compared with a modern SWIFT_COMPILER_VERSION.
static std::optional<version::Version>
parseCompilerVersionString(StringRef VersionString, SourceLoc Loc,
DiagnosticEngine *Diags);
/// Parse a generic version string of the format [0-9]+(.[0-9]+)*
///
/// Version components can be any unsigned 64-bit number.
static std::optional<version::Version>
parseVersionString(StringRef VersionString, SourceLoc Loc,
DiagnosticEngine *Diags);
};
} // namespace swift
#endif // SWIFT_PARSE_PARSEVERSION_H