Skip to content

Commit d7f6e4a

Browse files
committed
Cleanup
1 parent 758bce9 commit d7f6e4a

File tree

3 files changed

+35
-70
lines changed

3 files changed

+35
-70
lines changed

lib/SIL/SILInstructions.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,6 @@ KeyPathPattern::get(SILModule &M, CanGenericSignature signature,
22422242
case KeyPathPatternComponent::Kind::GettableProperty:
22432243
case KeyPathPatternComponent::Kind::SettableProperty:
22442244
for (auto &index : component.getSubscriptIndices()) {
2245-
index.FormalType.dump();
22462245
maxOperandNo = std::max(maxOperandNo, (int)index.Operand);
22472246
}
22482247
}

lib/SILGen/SILGenExpr.cpp

Lines changed: 35 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252

5353
#include "swift/AST/DiagnosticsSIL.h"
5454

55-
#include <iostream>
56-
5755
using namespace swift;
5856
using namespace Lowering;
5957

@@ -3069,11 +3067,6 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM,
30693067
hashable);
30703068
auto formalCanTy = formalTy->getCanonicalType(genericSig);
30713069

3072-
formalTy.dump();
3073-
index.FormalType.dump();
3074-
equatableProtocol->dump();
3075-
hashable.dump();
3076-
30773070
// Get the Equatable conformance from the Hashable conformance.
30783071
auto equatable = hashable.getAssociatedConformance(formalTy,
30793072
GenericTypeParamType::get(0, 0, C),
@@ -3348,62 +3341,51 @@ lowerKeyPathSubscriptIndexTypes(
33483341
}
33493342
};
33503343

3351-
static void
3352-
lowerKeyPathSubscriptEqualsIndexPatterns(
3353-
SmallVectorImpl<KeyPathPatternComponent::Index> &indexPatterns,
3354-
ArrayRef<IndexTypePair> indexTypes,
3355-
ArrayRef<ProtocolConformanceRef> indexHashables,
3356-
unsigned baseOperand,
3357-
SILGenModule &SGM,
3358-
ResilienceExpansion expansion) {
3344+
static void lowerKeyPathSubscriptEqualsIndexPatterns(
3345+
SmallVectorImpl<KeyPathPatternComponent::Index> &indexPatterns,
3346+
ArrayRef<IndexTypePair> indexTypes,
3347+
ArrayRef<ProtocolConformanceRef> indexHashables, unsigned baseOperand,
3348+
SILGenModule &SGM, ResilienceExpansion expansion) {
33593349
for (unsigned i : indices(indexTypes)) {
33603350
CanType formalTy;
33613351
SILType loweredTy;
33623352
std::tie(formalTy, loweredTy) = indexTypes[i];
33633353
auto hashable = indexHashables[i].mapConformanceOutOfContext();
3364-
// TODO: this only works if varaidic parameters must come last
33653354
// We have an array of variadic parameters...
33663355
if (!hashable.getConcrete()->getType()->isEqual(formalTy)) {
3367-
// Add all the hashable types
3356+
// Use the element type instead of the array type for hash/equals.
33683357
auto arrayTy = cast<BoundGenericStructType>(formalTy.getPointer());
33693358
auto elementTy = arrayTy->getGenericArgs()[0];
3370-
// for (unsigned hashableIndex = i; hashableIndex < indexHashables.size(); ++hashableIndex);
3371-
3359+
3360+
// Make sure that we aren't leaving out any hashables.
33723361
assert(indexTypes.size() == indexHashables.size());
3373-
3362+
3363+
// Make sure the element type matches the hashable.
33743364
assert(hashable.getConcrete()->getType()->isEqual(elementTy));
33753365
auto newLoweredTy = SGM.Types.getLoweredType(
33763366
AbstractionPattern::getOpaque(), elementTy,
33773367
TypeExpansionContext::noOpaqueTypeArchetypesSubstitution(expansion));
33783368
newLoweredTy = newLoweredTy.mapTypeOutOfContext();
3379-
auto newFormalTy = elementTy->mapTypeOutOfContext()
3380-
->getCanonicalType();
3381-
3382-
std::cout << "lowered variadic arg formal type: " << std::endl;
3383-
newFormalTy.dump();
3384-
loweredTy.dump();
3385-
3386-
indexPatterns.push_back({baseOperand++, newFormalTy,
3387-
newLoweredTy, hashable});
3369+
auto newFormalTy = elementTy->mapTypeOutOfContext()->getCanonicalType();
3370+
3371+
indexPatterns.push_back(
3372+
{baseOperand++, newFormalTy, newLoweredTy, hashable});
3373+
3374+
// We're done because variadics must come last.
33883375
break;
33893376
}
3390-
// hashable.dump(); // Int
3391-
// hashable.getConcrete()->getType().dump(); // Int
3392-
// formalTy.dump(); // Array<Int>
3393-
// loweredTy.dump(); // $Array<Int>
3377+
33943378
assert(hashable.isAbstract() ||
33953379
hashable.getConcrete()->getType()->isEqual(formalTy));
33963380

33973381
indexPatterns.push_back({baseOperand++, formalTy, loweredTy, hashable});
33983382
}
33993383
};
34003384

3401-
static void
3402-
lowerKeyPathSubscriptIndexPatterns(
3403-
SmallVectorImpl<KeyPathPatternComponent::Index> &indexPatterns,
3404-
ArrayRef<IndexTypePair> indexTypes,
3405-
ArrayRef<ProtocolConformanceRef> indexHashables,
3406-
unsigned &baseOperand) {
3385+
static void lowerKeyPathSubscriptIndexPatterns(
3386+
SmallVectorImpl<KeyPathPatternComponent::Index> &indexPatterns,
3387+
ArrayRef<IndexTypePair> indexTypes,
3388+
ArrayRef<ProtocolConformanceRef> indexHashables, unsigned &baseOperand) {
34073389
for (unsigned i : indices(indexTypes)) {
34083390
CanType formalTy;
34093391
SILType loweredTy;
@@ -3554,24 +3536,24 @@ SILGenModule::emitKeyPathComponentForDecl(SILLocation loc,
35543536
decl, subs,
35553537
expansion,
35563538
needsGenericContext);
3557-
3539+
35583540
SmallVector<KeyPathPatternComponent::Index, 4> equalsIndexPatterns;
3559-
SmallVector<KeyPathPatternComponent::Index, 4> xIndexPatterns;
3541+
SmallVector<KeyPathPatternComponent::Index, 4> indexPatterns;
35603542
SILFunction *indexEquals = nullptr, *indexHash = nullptr;
35613543
// Property descriptors get their index information from the client.
35623544
if (!forPropertyDescriptor) {
3563-
lowerKeyPathSubscriptEqualsIndexPatterns(equalsIndexPatterns,
3564-
indexTypes, indexHashables,
3565-
baseOperand, *this, expansion);
3566-
lowerKeyPathSubscriptIndexPatterns(xIndexPatterns,
3545+
// Gather the index patters that we will use for the component.
3546+
lowerKeyPathSubscriptEqualsIndexPatterns(equalsIndexPatterns, indexTypes,
3547+
indexHashables, baseOperand,
3548+
*this, expansion);
3549+
// Gather the index patterns that we will use for equals and hash.
3550+
lowerKeyPathSubscriptIndexPatterns(indexPatterns,
35673551
indexTypes, indexHashables,
35683552
baseOperand);
3569-
3570-
getOrCreateKeyPathEqualsAndHash(*this, loc,
3571-
needsGenericContext ? genericEnv : nullptr,
3572-
expansion,
3573-
equalsIndexPatterns,
3574-
indexEquals, indexHash);
3553+
3554+
getOrCreateKeyPathEqualsAndHash(
3555+
*this, loc, needsGenericContext ? genericEnv : nullptr, expansion,
3556+
equalsIndexPatterns, indexEquals, indexHash);
35753557
}
35763558

35773559
auto id = getIdForKeyPathComponentComputedProperty(*this, decl, strategy);
@@ -3582,7 +3564,7 @@ SILGenModule::emitKeyPathComponentForDecl(SILLocation loc,
35823564
indexTypes,
35833565
baseTy, componentTy);
35843566

3585-
auto indexPatternsCopy = getASTContext().AllocateCopy(xIndexPatterns);
3567+
auto indexPatternsCopy = getASTContext().AllocateCopy(indexPatterns);
35863568
if (isSettableInComponent()) {
35873569
auto setter = getOrCreateKeyPathSetter(*this, loc,
35883570
decl, subs,
@@ -3599,13 +3581,6 @@ SILGenModule::emitKeyPathComponentForDecl(SILLocation loc,
35993581
externalSubs,
36003582
componentTy);
36013583
} else {
3602-
for (auto &i : indexPatternsCopy) {
3603-
std::cout << "formal type: " << std::endl;
3604-
i.FormalType.dump();
3605-
std::cout << "lowered type: " << std::endl;
3606-
i.LoweredType.dump();
3607-
std::cout << std::endl;
3608-
}
36093584
return KeyPathPatternComponent::forComputedGettableProperty(id,
36103585
getter,
36113586
indexPatternsCopy,
@@ -3647,10 +3622,7 @@ RValue RValueEmitter::visitKeyPathExpr(KeyPathExpr *E, SGFContext C) {
36473622
case KeyPathExpr::Component::Kind::Property:
36483623
case KeyPathExpr::Component::Kind::Subscript: {
36493624
auto decl = cast<AbstractStorageDecl>(component.getDeclRef().getDecl());
3650-
3651-
decl->dump();
3652-
component.getIndexExpr()->dump();
3653-
3625+
36543626
unsigned numOperands = operands.size();
36553627
loweredComponents.push_back(
36563628
SGF.SGM.emitKeyPathComponentForDecl(SILLocation(E),
@@ -3673,7 +3645,6 @@ RValue RValueEmitter::visitKeyPathExpr(KeyPathExpr *E, SGFContext C) {
36733645
component.getIndexExpr());
36743646

36753647
for (auto &arg : loweredArgs) {
3676-
arg.dump();
36773648
operands.push_back(arg.forward(SGF));
36783649
}
36793650

@@ -3744,9 +3715,6 @@ RValue RValueEmitter::visitKeyPathExpr(KeyPathExpr *E, SGFContext C) {
37443715
rootTy, baseTy,
37453716
loweredComponents,
37463717
objcString);
3747-
3748-
std::cout << "[pattern] num operands: " << pattern->getNumOperands() << std::endl;
3749-
std::cout << "[operand] num operands: " << operands.size() << std::endl;
37503718
auto keyPath = SGF.B.createKeyPath(SILLocation(E), pattern,
37513719
needsGenericContext
37523720
? SGF.F.getForwardingSubstitutionMap()

lib/Sema/CSApply.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4589,8 +4589,6 @@ namespace {
45894589
auto fnType = overload.openedType->castTo<FunctionType>();
45904590
SmallVector<Identifier, 4> newLabels;
45914591
for (auto &param : fnType->getParams()) {
4592-
param.getParameterType().dump();
4593-
45944592
newLabels.push_back(param.getLabel());
45954593

45964594
auto indexType = simplifyType(param.getPlainType());

0 commit comments

Comments
 (0)