lib/IRGen/GenMeta.cpp
MetadataAccessStrategy irgen::getTypeMetadataAccessStrategy(CanType type) {
  // We should not be emitting accessors for partially-substituted
  // generic types.
  assert(!type->hasArchetype());

  // Non-generic structs, enums, and classes are special cases.
  //
  // Note that while protocol types don't have a metadata pattern,
  // we still require an accessor since we actually want to get
  // the metadata for the existential type.
  //
  // This needs to kept in sync with hasRequiredTypeMetadataAccessPattern.
  auto nominal = type->getAnyNominal();
  if (nominal && !isa<ProtocolDecl>(nominal)) {
    // Metadata accessors for fully-substituted generic types are
    // emitted with shared linkage.
    if (nominal->isGenericContext() && !nominal->isObjC()) {
      if (type->isSpecialized())
        return MetadataAccessStrategy::NonUniqueAccessor;
      assert(type->hasUnboundGenericType());
    }

    // If the type doesn't guarantee that it has an access function,
    // we might have to use a non-unique accessor.

    // Everything else requires accessors.
    switch (getDeclLinkage(nominal)) {
    case FormalLinkage::PublicUnique:
      return MetadataAccessStrategy::PublicUniqueAccessor;
    case FormalLinkage::HiddenUnique:
      return MetadataAccessStrategy::HiddenUniqueAccessor;
    case FormalLinkage::Private:
      return MetadataAccessStrategy::PrivateAccessor;

    case FormalLinkage::PublicNonUnique:
    case FormalLinkage::HiddenNonUnique:
      return MetadataAccessStrategy::NonUniqueAccessor;
    }
    llvm_unreachable("bad formal linkage");
  }

  // Everything else requires a shared accessor function.
  return MetadataAccessStrategy::NonUniqueAccessor;
}
/// Return the standard access strategy for getting a non-dependent
/// type metadata object.
Return the standard access strategy for getting a non-dependent
type metadata object.
Return the standard access strategy for getting a non - dependent type metadata object .
MetadataAccessStrategy irgen::getTypeMetadataAccessStrategy(CanType type) {
  assert(!type->hasArchetype());
   Note that while protocol types don't have a metadata pattern,
   we still require an accessor since we actually want to get
   the metadata for the existential type.
   This needs to kept in sync with hasRequiredTypeMetadataAccessPattern.
  auto nominal = type->getAnyNominal();
  if (nominal && !isa<ProtocolDecl>(nominal)) {
     Metadata accessors for fully-substituted generic types are
     emitted with shared linkage.
    if (nominal->isGenericContext() && !nominal->isObjC()) {
      if (type->isSpecialized())
        return MetadataAccessStrategy::NonUniqueAccessor;
      assert(type->hasUnboundGenericType());
    }
     If the type doesn't guarantee that it has an access function,
     we might have to use a non-unique accessor.
     Everything else requires accessors.
    switch (getDeclLinkage(nominal)) {
    case FormalLinkage::PublicUnique:
      return MetadataAccessStrategy::PublicUniqueAccessor;
    case FormalLinkage::HiddenUnique:
      return MetadataAccessStrategy::HiddenUniqueAccessor;
    case FormalLinkage::Private:
      return MetadataAccessStrategy::PrivateAccessor;
    case FormalLinkage::PublicNonUnique:
    case FormalLinkage::HiddenNonUnique:
      return MetadataAccessStrategy::NonUniqueAccessor;
    }
    llvm_unreachable("bad formal linkage");
  }
   Everything else requires a shared accessor function.
  return MetadataAccessStrategy::NonUniqueAccessor;
}
MetadataAccessStrategy irgen :: getTypeMetadataAccessStrategy ( CanType type ) { assert ( ! type -> hasArchetype ( ) ) ; auto nominal = type -> getAnyNominal ( ) ; if ( nominal && ! isa < ProtocolDecl > ( nominal ) ) { if ( nominal -> isGenericContext ( ) && ! nominal -> isObjC ( ) ) { if ( type -> isSpecialized ( ) ) return MetadataAccessStrategy :: NonUniqueAccessor ; assert ( type -> hasUnboundGenericType ( ) ) ; } switch ( getDeclLinkage ( nominal ) ) { case FormalLinkage :: PublicUnique : return MetadataAccessStrategy :: PublicUniqueAccessor ; case FormalLinkage :: HiddenUnique : return MetadataAccessStrategy :: HiddenUniqueAccessor ; case FormalLinkage :: Private : return MetadataAccessStrategy :: PrivateAccessor ; case FormalLinkage :: PublicNonUnique : case FormalLinkage :: HiddenNonUnique : return MetadataAccessStrategy :: NonUniqueAccessor ; } llvm_unreachable ( " " ) ; } return MetadataAccessStrategy :: NonUniqueAccessor ; }
Return the standard access strategy for getting a non-dependent
type metadata object.
Return the standard access strategy for getting a non - dependent type metadata object .
// We should not be emitting accessors for partially-substituted // generic types. // Non-generic structs, enums, and classes are special cases. // // Note that while protocol types don't have a metadata pattern, // we still require an accessor since we actually want to get // the metadata for the existential type. // // This needs to kept in sync with hasRequiredTypeMetadataAccessPattern. // Metadata accessors for fully-substituted generic types are // emitted with shared linkage. // If the type doesn't guarantee that it has an access function, // we might have to use a non-unique accessor. // Everything else requires accessors. // Everything else requires a shared accessor function.