mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Teach the generic specializer how to create SILWitnessTable declarations if a specialized conformance does not have a witness table.
This also teaches IRGen not to emit WitnessTable declarations. This causes them to be left as unknown symbols in the resulting executable. Swift SVN r15361
This commit is contained in:
@@ -93,6 +93,38 @@ SILModule::~SILModule() {
|
||||
delete (SILTypeListUniquingType*)TypeListUniquing;
|
||||
}
|
||||
|
||||
SILWitnessTable *
|
||||
SILModule::createWitnessTableDeclaration(ProtocolConformance *C) {
|
||||
// Walk down to the base NormalProtocolConformance.
|
||||
ProtocolConformance *ParentC = C;
|
||||
ArrayRef<Substitution> Subs;
|
||||
while (!isa<NormalProtocolConformance>(ParentC)) {
|
||||
switch (ParentC->getKind()) {
|
||||
case ProtocolConformanceKind::Normal:
|
||||
llvm_unreachable("should have exited the loop?!");
|
||||
case ProtocolConformanceKind::Inherited:
|
||||
ParentC = cast<InheritedProtocolConformance>(ParentC)
|
||||
->getInheritedConformance();
|
||||
break;
|
||||
case ProtocolConformanceKind::Specialized: {
|
||||
auto SC = cast<SpecializedProtocolConformance>(ParentC);
|
||||
ParentC = SC->getGenericConformance();
|
||||
assert(Subs.empty() && "multiple conformance specializations?!");
|
||||
Subs = SC->getGenericSubstitutions();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
NormalProtocolConformance *NormalC
|
||||
= cast<NormalProtocolConformance>(ParentC);
|
||||
|
||||
SILWitnessTable *WT = SILWitnessTable::create(*this,
|
||||
SILLinkage::PublicExternal,
|
||||
NormalC);
|
||||
WitnessTableLookupCache[NormalC] = WT;
|
||||
return WT;
|
||||
}
|
||||
|
||||
std::pair<SILWitnessTable *, ArrayRef<Substitution>>
|
||||
SILModule::lookUpWitnessTable(const ProtocolConformance *C) {
|
||||
// Walk down to the base NormalProtocolConformance.
|
||||
@@ -143,6 +175,7 @@ SILModule::lookUpWitnessTable(const ProtocolConformance *C) {
|
||||
return {nullptr, Subs};
|
||||
}
|
||||
|
||||
|
||||
SILFunction *SILModule::getOrCreateSharedFunction(SILLocation loc,
|
||||
StringRef name,
|
||||
CanSILFunctionType type,
|
||||
|
||||
Reference in New Issue
Block a user