Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. //===- ExtractAPI/AvailabilityInfo.h - Availability Info --------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. ///
  9. /// \file
  10. /// This file defines the AvailabilityInfo struct that collects availability
  11. /// attributes of a symbol.
  12. ///
  13. //===----------------------------------------------------------------------===//
  14.  
  15. #ifndef LLVM_CLANG_EXTRACTAPI_AVAILABILITY_INFO_H
  16. #define LLVM_CLANG_EXTRACTAPI_AVAILABILITY_INFO_H
  17.  
  18. #include "clang/AST/Decl.h"
  19. #include "llvm/ADT/SmallVector.h"
  20. #include "llvm/Support/Error.h"
  21. #include "llvm/Support/VersionTuple.h"
  22. #include "llvm/Support/raw_ostream.h"
  23.  
  24. using llvm::VersionTuple;
  25.  
  26. namespace clang {
  27. namespace extractapi {
  28.  
  29. /// Stores availability attributes of a symbol in a given domain.
  30. struct AvailabilityInfo {
  31.   /// The domain for which this availability info item applies
  32.   std::string Domain;
  33.   VersionTuple Introduced;
  34.   VersionTuple Deprecated;
  35.   VersionTuple Obsoleted;
  36.  
  37.   AvailabilityInfo() = default;
  38.  
  39.   AvailabilityInfo(StringRef Domain, VersionTuple I, VersionTuple D,
  40.                    VersionTuple O)
  41.       : Domain(Domain), Introduced(I), Deprecated(D), Obsoleted(O) {}
  42. };
  43.  
  44. class AvailabilitySet {
  45. private:
  46.   using AvailabilityList = llvm::SmallVector<AvailabilityInfo, 4>;
  47.   AvailabilityList Availabilities;
  48.  
  49.   bool UnconditionallyDeprecated = false;
  50.   bool UnconditionallyUnavailable = false;
  51.  
  52. public:
  53.   AvailabilitySet(const Decl *Decl);
  54.   AvailabilitySet() = default;
  55.  
  56.   AvailabilityList::const_iterator begin() const {
  57.     return Availabilities.begin();
  58.   }
  59.  
  60.   AvailabilityList::const_iterator end() const { return Availabilities.end(); }
  61.  
  62.   /// Check if the symbol is unconditionally deprecated.
  63.   ///
  64.   /// i.e. \code __attribute__((deprecated)) \endcode
  65.   bool isUnconditionallyDeprecated() const { return UnconditionallyDeprecated; }
  66.  
  67.   /// Check if the symbol is unconditionally unavailable.
  68.   ///
  69.   /// i.e. \code __attribute__((unavailable)) \endcode
  70.   bool isUnconditionallyUnavailable() const {
  71.     return UnconditionallyUnavailable;
  72.   }
  73.  
  74.   /// Determine if this AvailabilitySet represents default availability.
  75.   bool isDefault() const { return Availabilities.empty(); }
  76. };
  77.  
  78. } // namespace extractapi
  79. } // namespace clang
  80.  
  81. #endif // LLVM_CLANG_EXTRACTAPI_AVAILABILITY_INFO_H
  82.