clang 22.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 {
14LLVM_DUMP_METHOD void CommonEntityInfo::dump(llvm::raw_ostream &OS) const {
15 if (Unavailable)
16 OS << "[Unavailable] (" << UnavailableMsg << ")" << ' ';
18 OS << "[UnavailableInSwift] ";
19 if (SwiftPrivateSpecified)
20 OS << (SwiftPrivate ? "[SwiftPrivate] " : "");
21 if (SwiftSafetyAudited) {
22 switch (*getSwiftSafety()) {
24 OS << "[Safe] ";
25 break;
27 OS << "[Unsafe] ";
28 break;
30 OS << "[Unspecified] ";
31 break;
33 break;
34 }
35 }
36 if (!SwiftName.empty())
37 OS << "Swift Name: " << SwiftName << ' ';
38 OS << '\n';
39}
40
41LLVM_DUMP_METHOD void CommonTypeInfo::dump(llvm::raw_ostream &OS) const {
42 static_cast<const CommonEntityInfo &>(*this).dump(OS);
43 if (SwiftBridge)
44 OS << "Swift Briged Type: " << *SwiftBridge << ' ';
45 if (NSErrorDomain)
46 OS << "NSError Domain: " << *NSErrorDomain << ' ';
47 OS << '\n';
48}
49
50LLVM_DUMP_METHOD void ContextInfo::dump(llvm::raw_ostream &OS) {
51 static_cast<CommonTypeInfo &>(*this).dump(OS);
52 if (HasDefaultNullability)
53 OS << "DefaultNullability: " << DefaultNullability << ' ';
54 if (HasDesignatedInits)
55 OS << "[HasDesignatedInits] ";
56 if (SwiftImportAsNonGenericSpecified)
57 OS << (SwiftImportAsNonGeneric ? "[SwiftImportAsNonGeneric] " : "");
58 if (SwiftObjCMembersSpecified)
59 OS << (SwiftObjCMembers ? "[SwiftObjCMembers] " : "");
60 OS << '\n';
61}
62
63LLVM_DUMP_METHOD void VariableInfo::dump(llvm::raw_ostream &OS) const {
64 static_cast<const CommonEntityInfo &>(*this).dump(OS);
65 if (NullabilityAudited)
66 OS << "Audited Nullability: " << Nullable << ' ';
67 if (!Type.empty())
68 OS << "C Type: " << Type << ' ';
69 OS << '\n';
70}
71
72LLVM_DUMP_METHOD void ObjCPropertyInfo::dump(llvm::raw_ostream &OS) const {
73 static_cast<const VariableInfo &>(*this).dump(OS);
74 if (SwiftImportAsAccessorsSpecified)
75 OS << (SwiftImportAsAccessors ? "[SwiftImportAsAccessors] " : "");
76 OS << '\n';
77}
78
79LLVM_DUMP_METHOD void ParamInfo::dump(llvm::raw_ostream &OS) const {
80 static_cast<const VariableInfo &>(*this).dump(OS);
81 if (NoEscapeSpecified)
82 OS << (NoEscape ? "[NoEscape] " : "");
83 if (LifetimeboundSpecified)
84 OS << (Lifetimebound ? "[Lifetimebound] " : "");
85 OS << "RawRetainCountConvention: " << RawRetainCountConvention << ' ';
86 OS << '\n';
87}
88
89LLVM_DUMP_METHOD void FunctionInfo::dump(llvm::raw_ostream &OS) const {
90 static_cast<const CommonEntityInfo &>(*this).dump(OS);
91 OS << (NullabilityAudited ? "[NullabilityAudited] " : "")
92 << "RawRetainCountConvention: " << RawRetainCountConvention << ' ';
93 if (!ResultType.empty())
94 OS << "Result Type: " << ResultType << ' ';
95 if (!SwiftReturnOwnership.empty())
96 OS << "SwiftReturnOwnership: " << SwiftReturnOwnership << ' ';
97 if (!Params.empty())
98 OS << '\n';
99 for (auto &PI : Params)
100 PI.dump(OS);
101}
102
103LLVM_DUMP_METHOD void ObjCMethodInfo::dump(llvm::raw_ostream &OS) {
104 static_cast<FunctionInfo &>(*this).dump(OS);
105 if (Self)
106 Self->dump(OS);
107 OS << (DesignatedInit ? "[DesignatedInit] " : "")
108 << (RequiredInit ? "[RequiredInit] " : "") << '\n';
109}
110
111LLVM_DUMP_METHOD void CXXMethodInfo::dump(llvm::raw_ostream &OS) {
112 static_cast<FunctionInfo &>(*this).dump(OS);
113 if (This)
114 This->dump(OS);
115}
116
117LLVM_DUMP_METHOD void TagInfo::dump(llvm::raw_ostream &OS) {
118 static_cast<CommonTypeInfo &>(*this).dump(OS);
119 if (HasFlagEnum)
120 OS << (IsFlagEnum ? "[FlagEnum] " : "");
122 OS << "Enum Extensibility: " << static_cast<long>(*EnumExtensibility)
123 << ' ';
124 if (SwiftCopyableSpecified)
125 OS << (SwiftCopyable ? "[SwiftCopyable] " : "[~SwiftCopyable]");
126 if (SwiftEscapableSpecified)
127 OS << (SwiftEscapable ? "[SwiftEscapable] " : "[~SwiftEscapable]");
128 OS << '\n';
129}
130
131LLVM_DUMP_METHOD void TypedefInfo::dump(llvm::raw_ostream &OS) const {
132 static_cast<const CommonTypeInfo &>(*this).dump(OS);
133 if (SwiftWrapper)
134 OS << "Swift Type: " << static_cast<long>(*SwiftWrapper) << ' ';
135 OS << '\n';
136}
137} // namespace api_notes
138} // namespace clang
std::optional< ParamInfo > This
Definition Types.h:738
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
unsigned UnavailableInSwift
Whether this entity is marked unavailable in Swift.
Definition Types.h:65
unsigned Unavailable
Whether this entity is marked unavailable.
Definition Types.h:61
std::string SwiftName
Swift name of this entity.
Definition Types.h:84
std::string UnavailableMsg
Message to use when this entity is unavailable.
Definition Types.h:57
std::optional< SwiftSafetyKind > getSwiftSafety() const
Definition Types.h:100
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)
std::string SwiftReturnOwnership
Ownership convention for return value.
Definition Types.h:584
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
unsigned RawRetainCountConvention
A biased RetainCountConventionKind, where 0 means "unspecified".
Definition Types.h:571
std::vector< ParamInfo > Params
The function parameters.
Definition Types.h:587
std::string ResultType
The result type of this function, as a C type.
Definition Types.h:581
unsigned NullabilityAudited
Whether the signature has been audited with respect to nullability.
Definition Types.h:565
unsigned DesignatedInit
Whether this is a designated initializer of its class.
Definition Types.h:679
std::optional< ParamInfo > Self
Definition Types.h:685
unsigned RequiredInit
Whether this is a required initializer.
Definition Types.h:683
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
std::optional< EnumExtensibilityKind > EnumExtensibility
Definition Types.h:781
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:871
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
The JSON file list parser is used to communicate input to InstallAPI.