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 |
17 | |
18 | #include "clang/AST/Decl.h" |
19 | #include "llvm/Support/Error.h" |
20 | #include "llvm/Support/VersionTuple.h" |
21 | #include "llvm/Support/raw_ostream.h" |
22 | |
23 | namespace clang { |
24 | namespace extractapi { |
25 | |
26 | /// Stores availability attributes of a symbol. |
27 | struct { |
28 | /// The domain for which this availability info item applies |
29 | std::string Domain; |
30 | VersionTuple ; |
31 | VersionTuple ; |
32 | VersionTuple ; |
33 | bool = false; |
34 | bool = false; |
35 | |
36 | () = default; |
37 | |
38 | /// Determine if this AvailabilityInfo represents the default availability. |
39 | bool () const { return *this == AvailabilityInfo(); } |
40 | /// Check if the symbol is unconditionally deprecated. |
41 | /// |
42 | /// i.e. \code __attribute__((deprecated)) \endcode |
43 | bool () const { return UnconditionallyDeprecated; } |
44 | /// Check if the symbol is unconditionally unavailable. |
45 | /// |
46 | /// i.e. \code __attribute__((unavailable)) \endcode |
47 | bool () const { |
48 | return UnconditionallyUnavailable; |
49 | } |
50 | |
51 | (StringRef Domain, VersionTuple I, VersionTuple D, |
52 | VersionTuple O, bool UD, bool UU) |
53 | : Domain(Domain), Introduced(I), Deprecated(D), Obsoleted(O), |
54 | UnconditionallyDeprecated(UD), UnconditionallyUnavailable(UU) {} |
55 | |
56 | friend bool operator==(const AvailabilityInfo &Lhs, |
57 | const AvailabilityInfo &Rhs); |
58 | |
59 | public: |
60 | static AvailabilityInfo (const Decl *Decl); |
61 | }; |
62 | |
63 | inline bool (const AvailabilityInfo &Lhs, |
64 | const AvailabilityInfo &Rhs) { |
65 | return std::tie(args: Lhs.Introduced, args: Lhs.Deprecated, args: Lhs.Obsoleted, |
66 | args: Lhs.UnconditionallyDeprecated, |
67 | args: Lhs.UnconditionallyUnavailable) == |
68 | std::tie(args: Rhs.Introduced, args: Rhs.Deprecated, args: Rhs.Obsoleted, |
69 | args: Rhs.UnconditionallyDeprecated, |
70 | args: Rhs.UnconditionallyUnavailable); |
71 | } |
72 | |
73 | } // namespace extractapi |
74 | } // namespace clang |
75 | |
76 | #endif // LLVM_CLANG_EXTRACTAPI_AVAILABILITY_INFO_H |
77 | |