brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.5 KiB · bff4be1 Raw
139 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "clang/APINotes/Types.h"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 << ")" << ' ';17  if (UnavailableInSwift)18    OS << "[UnavailableInSwift] ";19  if (SwiftPrivateSpecified)20    OS << (SwiftPrivate ? "[SwiftPrivate] " : "");21  if (SwiftSafetyAudited) {22    switch (*getSwiftSafety()) {23    case SwiftSafetyKind::Safe:24      OS << "[Safe] ";25      break;26    case SwiftSafetyKind::Unsafe:27      OS << "[Unsafe] ";28      break;29    case SwiftSafetyKind::Unspecified:30      OS << "[Unspecified] ";31      break;32    case SwiftSafetyKind::None: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] " : "");121  if (EnumExtensibility)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_notes138} // namespace clang139