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; }
GenericEnvironment * TypeChecker::markInvalidGenericSignature(DeclContext *DC) { GenericParamList *genericParams = DC->getGenericParamsOfContext(); GenericSignature *genericSig = DC->getGenericSignatureOfContext(); // Build new archetypes without any generic requirements. DeclContext *parentDC = DC->getParent(); auto builder = createArchetypeBuilder(parentDC->getParentModule()); auto parentSig = parentDC->getGenericSignatureOfContext(); auto parentEnv = parentDC->getGenericEnvironmentOfContext(); assert(parentSig != nullptr || DC->isInnermostContextGeneric()); if (parentSig != nullptr) builder.addGenericSignature(parentSig, parentEnv); if (DC->isInnermostContextGeneric()) { // Visit each of the generic parameters. for (auto param : *genericParams) builder.addGenericParameter(param); } // Wire up the archetypes. auto genericEnv = builder.getGenericEnvironment( genericSig->getGenericParams()); return genericEnv; }