Example #1
0
DebugTypeInfo DebugTypeInfo::getGlobal(SILGlobalVariable *GV,
                                       llvm::Type *StorageTy, Size size,
                                       Alignment align) {
  // Prefer the original, potentially sugared version of the type if
  // the type hasn't been mucked with by an optimization pass.
  DeclContext *DC = nullptr;
  GenericEnvironment *GE = nullptr;
  auto LowTy = GV->getLoweredType().getSwiftRValueType();
  auto *Type = LowTy.getPointer();
  if (auto *Decl = GV->getDecl()) {
    DC = Decl->getDeclContext();
    GE = DC->getGenericEnvironmentOfContext();
    auto DeclType =
        (Decl->hasType() ? Decl->getType()
                         : DC->mapTypeIntoContext(Decl->getInterfaceType()));
    if (DeclType->isEqual(LowTy))
      Type = DeclType.getPointer();
  }
  DebugTypeInfo DbgTy(DC, GE, Type, StorageTy, size, align);
  assert(StorageTy && "StorageType is a nullptr");
  assert(!DbgTy.isArchetype() &&
         "type of a global var cannot contain an archetype");
  assert(align.getValue() != 0);
  return DbgTy;
}
Example #2
0
 bool mismatch(SubstitutableType *paramType, TypeBase *argType,
               Type sugaredFirstType) {
   Type type = paramType;
   if (type->is<GenericTypeParamType>()) {
     assert(dc);
     type = dc->mapTypeIntoContext(paramType);
   }
   
   if (auto archetype = type->getAs<ArchetypeType>()) {
     auto existing = archetypesMap[archetype];
     if (existing)
       return existing->isEqual(argType);
     archetypesMap[archetype] = argType;
     return true;
   }
   return false;
 }