clang  14.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 
9 #include "clang/APINotes/Types.h"
10 #include "llvm/Support/raw_ostream.h"
11 
12 namespace clang {
13 namespace api_notes {
14 LLVM_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 (!SwiftName.empty())
22  OS << "Swift Name: " << SwiftName << ' ';
23  OS << '\n';
24 }
25 
26 LLVM_DUMP_METHOD void CommonTypeInfo::dump(llvm::raw_ostream &OS) const {
27  static_cast<const CommonEntityInfo &>(*this).dump(OS);
28  if (SwiftBridge)
29  OS << "Swift Briged Type: " << *SwiftBridge << ' ';
30  if (NSErrorDomain)
31  OS << "NSError Domain: " << *NSErrorDomain << ' ';
32  OS << '\n';
33 }
34 
35 LLVM_DUMP_METHOD void ObjCContextInfo::dump(llvm::raw_ostream &OS) {
36  static_cast<CommonTypeInfo &>(*this).dump(OS);
37  if (HasDefaultNullability)
38  OS << "DefaultNullability: " << DefaultNullability << ' ';
39  if (HasDesignatedInits)
40  OS << "[HasDesignatedInits] ";
41  if (SwiftImportAsNonGenericSpecified)
42  OS << (SwiftImportAsNonGeneric ? "[SwiftImportAsNonGeneric] " : "");
43  if (SwiftObjCMembersSpecified)
44  OS << (SwiftObjCMembers ? "[SwiftObjCMembers] " : "");
45  OS << '\n';
46 }
47 
48 LLVM_DUMP_METHOD void VariableInfo::dump(llvm::raw_ostream &OS) const {
49  static_cast<const CommonEntityInfo &>(*this).dump(OS);
50  if (NullabilityAudited)
51  OS << "Audited Nullability: " << Nullable << ' ';
52  if (!Type.empty())
53  OS << "C Type: " << Type << ' ';
54  OS << '\n';
55 }
56 
57 LLVM_DUMP_METHOD void ObjCPropertyInfo::dump(llvm::raw_ostream &OS) const {
58  static_cast<const VariableInfo &>(*this).dump(OS);
59  if (SwiftImportAsAccessorsSpecified)
60  OS << (SwiftImportAsAccessors ? "[SwiftImportAsAccessors] " : "");
61  OS << '\n';
62 }
63 
64 LLVM_DUMP_METHOD void ParamInfo::dump(llvm::raw_ostream &OS) const {
65  static_cast<const VariableInfo &>(*this).dump(OS);
66  if (NoEscapeSpecified)
67  OS << (NoEscape ? "[NoEscape] " : "");
68  OS << "RawRetainCountConvention: " << RawRetainCountConvention << ' ';
69  OS << '\n';
70 }
71 
72 LLVM_DUMP_METHOD void FunctionInfo::dump(llvm::raw_ostream &OS) const {
73  static_cast<const CommonEntityInfo &>(*this).dump(OS);
74  OS << (NullabilityAudited ? "[NullabilityAudited] " : "")
75  << "RawRetainCountConvention: " << RawRetainCountConvention << ' ';
76  if (!ResultType.empty())
77  OS << "Result Type: " << ResultType << ' ';
78  if (!Params.empty())
79  OS << '\n';
80  for (auto &PI : Params)
81  PI.dump(OS);
82 }
83 
84 LLVM_DUMP_METHOD void ObjCMethodInfo::dump(llvm::raw_ostream &OS) {
85  static_cast<FunctionInfo &>(*this).dump(OS);
86  OS << (DesignatedInit ? "[DesignatedInit] " : "")
87  << (RequiredInit ? "[RequiredInit] " : "") << '\n';
88 }
89 
90 LLVM_DUMP_METHOD void TagInfo::dump(llvm::raw_ostream &OS) {
91  static_cast<CommonTypeInfo &>(*this).dump(OS);
92  if (HasFlagEnum)
93  OS << (IsFlagEnum ? "[FlagEnum] " : "");
95  OS << "Enum Extensibility: " << static_cast<long>(*EnumExtensibility)
96  << ' ';
97  OS << '\n';
98 }
99 
100 LLVM_DUMP_METHOD void TypedefInfo::dump(llvm::raw_ostream &OS) const {
101  static_cast<const CommonTypeInfo &>(*this).dump(OS);
102  if (SwiftWrapper)
103  OS << "Swift Type: " << static_cast<long>(*SwiftWrapper) << ' ';
104  OS << '\n';
105 }
106 } // namespace api_notes
107 } // namespace clang
clang::api_notes::ObjCMethodInfo::RequiredInit
unsigned RequiredInit
Whether this is a required initializer.
Definition: Types.h:608
clang::api_notes::ObjCPropertyInfo::dump
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
Definition: APINotesTypes.cpp:57
clang::api_notes::VariableInfo::dump
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
Definition: APINotesTypes.cpp:48
clang::api_notes::TypedefInfo::SwiftWrapper
llvm::Optional< SwiftNewTypeKind > SwiftWrapper
Definition: Types.h:707
clang::api_notes::CommonEntityInfo
Describes API notes data for any entity.
Definition: Types.h:47
clang::api_notes::CommonEntityInfo::Unavailable
unsigned Unavailable
Whether this entity is marked unavailable.
Definition: Types.h:53
clang::api_notes::TagInfo::EnumExtensibility
llvm::Optional< EnumExtensibilityKind > EnumExtensibility
Definition: Types.h:663
clang::api_notes::VariableInfo
API notes for a variable/property.
Definition: Types.h:300
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1490
clang::api_notes::ObjCMethodInfo::DesignatedInit
unsigned DesignatedInit
Whether this is a designated initializer of its class.
Definition: Types.h:605
clang::api_notes::FunctionInfo::RawRetainCountConvention
unsigned RawRetainCountConvention
A biased RetainCountConventionKind, where 0 means "unspecified".
Definition: Types.h:501
clang::api_notes::FunctionInfo::dump
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
Definition: APINotesTypes.cpp:72
clang::api_notes::CommonEntityInfo::UnavailableMsg
std::string UnavailableMsg
Message to use when this entity is unavailable.
Definition: Types.h:50
clang::api_notes::FunctionInfo::ResultType
std::string ResultType
The result type of this function, as a C type.
Definition: Types.h:511
clang::api_notes::ParamInfo::dump
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
Definition: APINotesTypes.cpp:64
Types.h
clang::api_notes::ObjCContextInfo::dump
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
Definition: APINotesTypes.cpp:35
clang::api_notes::FunctionInfo::NullabilityAudited
unsigned NullabilityAudited
Whether the signature has been audited with respect to nullability.
Definition: Types.h:495
clang::api_notes::CommonEntityInfo::UnavailableInSwift
unsigned UnavailableInSwift
Whether this entity is marked unavailable in Swift.
Definition: Types.h:56
clang::api_notes::CommonTypeInfo::dump
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
Definition: APINotesTypes.cpp:26
clang::api_notes::TagInfo::dump
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
Definition: APINotesTypes.cpp:90
clang::api_notes::FunctionInfo::Params
std::vector< ParamInfo > Params
The function parameters.
Definition: Types.h:514
clang
Definition: CalledOnceCheck.h:17
clang::api_notes::CommonTypeInfo
Describes API notes for types.
Definition: Types.h:126
clang::api_notes::CommonEntityInfo::SwiftName
std::string SwiftName
Swift name of this entity.
Definition: Types.h:67
clang::api_notes::CommonEntityInfo::dump
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
Definition: APINotesTypes.cpp:14
clang::api_notes::ObjCMethodInfo::dump
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
Definition: APINotesTypes.cpp:84
clang::api_notes::TypedefInfo::dump
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
Definition: APINotesTypes.cpp:100
clang::api_notes::FunctionInfo
API notes for a function or method.
Definition: Types.h:482