Availability.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--- Availability.h - Classes for availability --------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This files defines some classes that implement availability checking.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_CLANG_AST_AVAILABILITY_H
  18. #define LLVM_CLANG_AST_AVAILABILITY_H
  19. #include "clang/Basic/SourceLocation.h"
  20. #include "llvm/ADT/StringRef.h"
  21. #include "llvm/Support/VersionTuple.h"
  22. namespace clang {
  23. /// One specifier in an @available expression.
  24. ///
  25. /// \code
  26. /// @available(macos 10.10, *)
  27. /// \endcode
  28. ///
  29. /// Here, 'macos 10.10' and '*' both map to an instance of this type.
  30. ///
  31. class AvailabilitySpec {
  32. /// Represents the version that this specifier requires. If the host OS
  33. /// version is greater than or equal to Version, the @available will evaluate
  34. /// to true.
  35. VersionTuple Version;
  36. /// Name of the platform that Version corresponds to.
  37. StringRef Platform;
  38. SourceLocation BeginLoc, EndLoc;
  39. public:
  40. AvailabilitySpec(VersionTuple Version, StringRef Platform,
  41. SourceLocation BeginLoc, SourceLocation EndLoc)
  42. : Version(Version), Platform(Platform), BeginLoc(BeginLoc),
  43. EndLoc(EndLoc) {}
  44. /// This constructor is used when representing the '*' case.
  45. AvailabilitySpec(SourceLocation StarLoc)
  46. : BeginLoc(StarLoc), EndLoc(StarLoc) {}
  47. VersionTuple getVersion() const { return Version; }
  48. StringRef getPlatform() const { return Platform; }
  49. SourceLocation getBeginLoc() const { return BeginLoc; }
  50. SourceLocation getEndLoc() const { return EndLoc; }
  51. /// Returns true when this represents the '*' case.
  52. bool isOtherPlatformSpec() const { return Version.empty(); }
  53. };
  54. } // end namespace clang
  55. #endif
  56. #ifdef __GNUC__
  57. #pragma GCC diagnostic pop
  58. #endif