clang 18.0.0git
AvailabilityInfo.h
Go to the documentation of this file.
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
24using llvm::VersionTuple;
25
26namespace clang {
27namespace extractapi {
28
29/// Stores availability attributes of a symbol in a given domain.
31 /// The domain for which this availability info item applies
32 std::string Domain;
33 VersionTuple Introduced;
34 VersionTuple Deprecated;
35 VersionTuple Obsoleted;
37
38 AvailabilityInfo() = default;
39
40 AvailabilityInfo(StringRef Domain, VersionTuple I, VersionTuple D,
41 VersionTuple O, bool U)
43 Unavailable(U) {}
44};
45
47private:
49 AvailabilityList Availabilities;
50
51 bool UnconditionallyDeprecated = false;
52 bool UnconditionallyUnavailable = false;
53
54public:
56 AvailabilitySet() = default;
57
58 AvailabilityList::const_iterator begin() const {
59 return Availabilities.begin();
60 }
61
62 AvailabilityList::const_iterator end() const { return Availabilities.end(); }
63
64 /// Check if the symbol is unconditionally deprecated.
65 ///
66 /// i.e. \code __attribute__((deprecated)) \endcode
67 bool isUnconditionallyDeprecated() const { return UnconditionallyDeprecated; }
68
69 /// Check if the symbol is unconditionally unavailable.
70 ///
71 /// i.e. \code __attribute__((unavailable)) \endcode
73 return UnconditionallyUnavailable;
74 }
75
76 /// Determine if this AvailabilitySet represents default availability.
77 bool isDefault() const { return Availabilities.empty(); }
78};
79
80} // namespace extractapi
81} // namespace clang
82
83#endif // LLVM_CLANG_EXTRACTAPI_AVAILABILITY_INFO_H
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:85
bool isUnconditionallyDeprecated() const
Check if the symbol is unconditionally deprecated.
bool isDefault() const
Determine if this AvailabilitySet represents default availability.
AvailabilityList::const_iterator begin() const
AvailabilityList::const_iterator end() const
bool isUnconditionallyUnavailable() const
Check if the symbol is unconditionally unavailable.
Stores availability attributes of a symbol in a given domain.
AvailabilityInfo(StringRef Domain, VersionTuple I, VersionTuple D, VersionTuple O, bool U)
std::string Domain
The domain for which this availability info item applies.