clang 24.0.0git
APINotesTypes.cpp
Go to the documentation of this file.
1//===-- APINotesTypes.cpp - API Notes Data Types ----------------*- 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
10#include "llvm/Support/raw_ostream.h"
11
12namespace clang {
13namespace api_notes {
14
15LLVM_DUMP_METHOD void CommonEntityInfo::dump(llvm::raw_ostream &OS) const {
16 if (Unavailable)
17 OS << "[Unavailable] (" << UnavailableMsg << ")" << ' ';
19 OS << "[UnavailableInSwift] ";
20 if (SwiftPrivateSpecified)
21 OS << (SwiftPrivate ? "[SwiftPrivate] " : "");
22 if (SwiftSafetyAudited) {
23 switch (*getSwiftSafety()) {
25 OS << "[Safe] ";
26 break;
28 OS << "[Unsafe] ";
29 break;
31 OS << "[Unspecified] ";
32 break;
34 break;
35 }
36 }
37 if (!SwiftName.empty())
38 OS << "Swift Name: " << SwiftName << ' ';
39 OS << '\n';
40}
41
42LLVM_DUMP_METHOD void CommonTypeInfo::dump(llvm::raw_ostream &OS) const {
43 static_cast<const CommonEntityInfo &>(*this).dump(OS);
44 if (SwiftBridge)
45 OS << "Swift Briged Type: " << *SwiftBridge << ' ';
46 if (NSErrorDomain)
47 OS << "NSError Domain: " << *NSErrorDomain << ' ';
48 OS << '\n';
49}
50
51LLVM_DUMP_METHOD void ContextInfo::dump(llvm::raw_ostream &OS) {
52 static_cast<CommonTypeInfo &>(*this).dump(OS);
54 OS << "DefaultNullability: " << *K << ' ';
55 if (HasDesignatedInits)
56 OS << "[HasDesignatedInits] ";
57 if (SwiftImportAsNonGenericSpecified)
58 OS << (SwiftImportAsNonGeneric ? "[SwiftImportAsNonGeneric] " : "");
59 if (SwiftObjCMembersSpecified)
60 OS << (SwiftObjCMembers ? "[SwiftObjCMembers] " : "");
61 OS << '\n';
62}
63
64LLVM_DUMP_METHOD void VariableInfo::dump(llvm::raw_ostream &OS) const {
65 static_cast<const CommonEntityInfo &>(*this).dump(OS);
67 OS << "Audited Nullability: " << *K << ' ';
68 if (!Type.empty())
69 OS << "C Type: " << Type << ' ';
70 OS << '\n';
71}
72
73LLVM_DUMP_METHOD void ObjCPropertyInfo::dump(llvm::raw_ostream &OS) const {
74 static_cast<const VariableInfo &>(*this).dump(OS);
75 if (SwiftImportAsAccessorsSpecified)
76 OS << (SwiftImportAsAccessors ? "[SwiftImportAsAccessors] " : "");
77 OS << '\n';
78}
79
80LLVM_DUMP_METHOD void BoundsSafetyInfo::dump(llvm::raw_ostream &OS) const {
81 if (KindAudited) {
82 switch (static_cast<BoundsSafetyKind>(Kind)) {
84 OS << "[counted_by] ";
85 break;
87 OS << "[counted_by_or_null] ";
88 break;
90 OS << "[sized_by] ";
91 break;
93 OS << "[sized_by_or_null] ";
94 break;
96 OS << "[ended_by] ";
97 break;
98 }
99 }
100 if (LevelAudited)
101 OS << "Level: " << Level << " ";
102 OS << "ExternalBounds: "
103 << (ExternalBounds.empty() ? "<missing>" : ExternalBounds) << '\n';
104}
105
106LLVM_DUMP_METHOD void ParamInfo::dump(llvm::raw_ostream &OS) const {
107 static_cast<const VariableInfo &>(*this).dump(OS);
108 if (NoEscapeSpecified)
109 OS << (NoEscape ? "[NoEscape] " : "");
110 if (LifetimeboundSpecified)
111 OS << (Lifetimebound ? "[Lifetimebound] " : "");
112 OS << "RawRetainCountConvention: " << RawRetainCountConvention << ' ';
113 OS << '\n';
114 if (BoundsSafety)
115 BoundsSafety->dump(OS);
116}
117
118LLVM_DUMP_METHOD void FunctionInfo::dump(llvm::raw_ostream &OS) const {
119 static_cast<const CommonEntityInfo &>(*this).dump(OS);
120 OS << (NullabilityAudited ? "[NullabilityAudited] " : "")
121 << (UnsafeBufferUsage ? "[UnsafeBufferUsage] " : "")
122 << "RawRetainCountConvention: " << RawRetainCountConvention << ' ';
123 if (!ResultType.empty())
124 OS << "Result Type: " << ResultType << ' ';
125 if (!SwiftReturnOwnership.empty())
126 OS << "SwiftReturnOwnership: " << SwiftReturnOwnership << ' ';
127 if (!Params.empty())
128 OS << '\n';
129 for (auto &PI : Params)
130 PI.dump(OS);
131}
132
133LLVM_DUMP_METHOD void ObjCMethodInfo::dump(llvm::raw_ostream &OS) {
134 static_cast<FunctionInfo &>(*this).dump(OS);
135 if (Self)
136 Self->dump(OS);
137 OS << (DesignatedInit ? "[DesignatedInit] " : "")
138 << (RequiredInit ? "[RequiredInit] " : "") << '\n';
139}
140
141LLVM_DUMP_METHOD void CXXMethodInfo::dump(llvm::raw_ostream &OS) {
142 static_cast<FunctionInfo &>(*this).dump(OS);
143 if (This)
144 This->dump(OS);
145}
146
147LLVM_DUMP_METHOD void TagInfo::dump(llvm::raw_ostream &OS) {
148 static_cast<CommonTypeInfo &>(*this).dump(OS);
149 if (HasFlagEnum)
150 OS << (IsFlagEnum ? "[FlagEnum] " : "");
152 OS << "Enum Extensibility: " << static_cast<long>(*EnumExtensibility)
153 << ' ';
154 if (SwiftCopyableSpecified)
155 OS << (SwiftCopyable ? "[SwiftCopyable] " : "[~SwiftCopyable]");
156 if (SwiftEscapableSpecified)
157 OS << (SwiftEscapable ? "[SwiftEscapable] " : "[~SwiftEscapable]");
158 OS << '\n';
159}
160
161LLVM_DUMP_METHOD void TypedefInfo::dump(llvm::raw_ostream &OS) const {
162 static_cast<const CommonTypeInfo &>(*this).dump(OS);
163 if (SwiftWrapper)
164 OS << "Swift Type: " << static_cast<long>(*SwiftWrapper) << ' ';
165 OS << '\n';
166}
167} // namespace api_notes
168} // namespace clang
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
std::optional< ParamInfo > This
Definition Types.h:825
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
unsigned UnavailableInSwift
Whether this entity is marked unavailable in Swift.
Definition Types.h:83
unsigned Unavailable
Whether this entity is marked unavailable.
Definition Types.h:79
std::string SwiftName
Swift name of this entity.
Definition Types.h:102
std::string UnavailableMsg
Message to use when this entity is unavailable.
Definition Types.h:75
std::optional< SwiftSafetyKind > getSwiftSafety() const
Definition Types.h:118
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
NullabilityKindOrNone getDefaultNullability() const
Determine the default nullability for properties and methods of this class.
Definition Types.h:283
std::string SwiftReturnOwnership
Ownership convention for return value.
Definition Types.h:670
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
unsigned RawRetainCountConvention
A biased RetainCountConventionKind, where 0 means "unspecified".
Definition Types.h:653
std::vector< ParamInfo > Params
The function parameters.
Definition Types.h:673
std::string ResultType
The result type of this function, as a C type.
Definition Types.h:667
unsigned UnsafeBufferUsage
Whether the function has the [[clang::unsafe_buffer_usage]] attribute.
Definition Types.h:657
unsigned NullabilityAudited
Whether the signature has been audited with respect to nullability.
Definition Types.h:647
unsigned DesignatedInit
Whether this is a designated initializer of its class.
Definition Types.h:766
std::optional< ParamInfo > Self
Definition Types.h:772
unsigned RequiredInit
Whether this is a required initializer.
Definition Types.h:770
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
std::optional< BoundsSafetyInfo > BoundsSafety
Definition Types.h:556
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
std::optional< EnumExtensibilityKind > EnumExtensibility
Definition Types.h:868
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
std::optional< SwiftNewTypeKind > SwiftWrapper
Definition Types.h:958
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
NullabilityKindOrNone getNullability() const
Definition Types.h:438
The JSON file list parser is used to communicate input to InstallAPI.
OptionalUnsigned< NullabilityKind > NullabilityKindOrNone
Definition Specifiers.h:365