| 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 << ")"<< ' '; |
| 17 | if (UnavailableInSwift) |
| 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 ContextInfo::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 | if (LifetimeboundSpecified) |
| 69 | OS << (Lifetimebound ? "[Lifetimebound] ": ""); |
| 70 | OS << "RawRetainCountConvention: "<< RawRetainCountConvention << ' '; |
| 71 | OS << '\n'; |
| 72 | } |
| 73 | |
| 74 | LLVM_DUMP_METHOD void FunctionInfo::dump(llvm::raw_ostream &OS) const { |
| 75 | static_cast<const CommonEntityInfo &>(*this).dump(OS); |
| 76 | OS << (NullabilityAudited ? "[NullabilityAudited] ": "") |
| 77 | << "RawRetainCountConvention: "<< RawRetainCountConvention << ' '; |
| 78 | if (!ResultType.empty()) |
| 79 | OS << "Result Type: "<< ResultType << ' '; |
| 80 | if (!SwiftReturnOwnership.empty()) |
| 81 | OS << "SwiftReturnOwnership: "<< SwiftReturnOwnership << ' '; |
| 82 | if (!Params.empty()) |
| 83 | OS << '\n'; |
| 84 | for (auto &PI : Params) |
| 85 | PI.dump(OS); |
| 86 | } |
| 87 | |
| 88 | LLVM_DUMP_METHOD void ObjCMethodInfo::dump(llvm::raw_ostream &OS) { |
| 89 | static_cast<FunctionInfo &>(*this).dump(OS); |
| 90 | if (Self) |
| 91 | Self->dump(OS); |
| 92 | OS << (DesignatedInit ? "[DesignatedInit] ": "") |
| 93 | << (RequiredInit ? "[RequiredInit] ": "") << '\n'; |
| 94 | } |
| 95 | |
| 96 | LLVM_DUMP_METHOD void CXXMethodInfo::dump(llvm::raw_ostream &OS) { |
| 97 | static_cast<FunctionInfo &>(*this).dump(OS); |
| 98 | if (This) |
| 99 | This->dump(OS); |
| 100 | } |
| 101 | |
| 102 | LLVM_DUMP_METHOD void TagInfo::dump(llvm::raw_ostream &OS) { |
| 103 | static_cast<CommonTypeInfo &>(*this).dump(OS); |
| 104 | if (HasFlagEnum) |
| 105 | OS << (IsFlagEnum ? "[FlagEnum] ": ""); |
| 106 | if (EnumExtensibility) |
| 107 | OS << "Enum Extensibility: "<< static_cast<long>(*EnumExtensibility) |
| 108 | << ' '; |
| 109 | if (SwiftCopyableSpecified) |
| 110 | OS << (SwiftCopyable ? "[SwiftCopyable] ": "[~SwiftCopyable]"); |
| 111 | if (SwiftEscapableSpecified) |
| 112 | OS << (SwiftEscapable ? "[SwiftEscapable] ": "[~SwiftEscapable]"); |
| 113 | OS << '\n'; |
| 114 | } |
| 115 | |
| 116 | LLVM_DUMP_METHOD void TypedefInfo::dump(llvm::raw_ostream &OS) const { |
| 117 | static_cast<const CommonTypeInfo &>(*this).dump(OS); |
| 118 | if (SwiftWrapper) |
| 119 | OS << "Swift Type: "<< static_cast<long>(*SwiftWrapper) << ' '; |
| 120 | OS << '\n'; |
| 121 | } |
| 122 | } // namespace api_notes |
| 123 | } // namespace clang |
| 124 |