Skip to content

Commit 5ae231e

Browse files
committed
Rename getFieldNo() to getFieldIndex().
Do I really need to justify this?
1 parent 2829472 commit 5ae231e

38 files changed

+83
-84
lines changed

include/swift/SIL/PatternMatch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ template <typename LTy> struct tupleextractoperation_ty {
406406

407407
template <typename ITy> bool match(ITy *V) {
408408
if (auto *TEI = dyn_cast<TupleExtractInst>(V)) {
409-
return TEI->getFieldNo() == index &&
409+
return TEI->getFieldIndex() == index &&
410410
L.match((ValueBase *)TEI->getOperand());
411411
}
412412

include/swift/SIL/Projection.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ struct ProjectionIndex {
152152
}
153153
case ValueKind::StructElementAddrInst: {
154154
StructElementAddrInst *SEA = cast<StructElementAddrInst>(V);
155-
Index = SEA->getFieldNo();
155+
Index = SEA->getFieldIndex();
156156
Aggregate = SEA->getOperand();
157157
break;
158158
}
159159
case ValueKind::RefElementAddrInst: {
160160
RefElementAddrInst *REA = cast<RefElementAddrInst>(V);
161-
Index = REA->getFieldNo();
161+
Index = REA->getFieldIndex();
162162
Aggregate = REA->getOperand();
163163
break;
164164
}
@@ -177,19 +177,19 @@ struct ProjectionIndex {
177177
}
178178
case ValueKind::TupleElementAddrInst: {
179179
TupleElementAddrInst *TEA = cast<TupleElementAddrInst>(V);
180-
Index = TEA->getFieldNo();
180+
Index = TEA->getFieldIndex();
181181
Aggregate = TEA->getOperand();
182182
break;
183183
}
184184
case ValueKind::StructExtractInst: {
185185
StructExtractInst *SEA = cast<StructExtractInst>(V);
186-
Index = SEA->getFieldNo();
186+
Index = SEA->getFieldIndex();
187187
Aggregate = SEA->getOperand();
188188
break;
189189
}
190190
case ValueKind::TupleExtractInst: {
191191
TupleExtractInst *TEA = cast<TupleExtractInst>(V);
192-
Index = TEA->getFieldNo();
192+
Index = TEA->getFieldIndex();
193193
Aggregate = TEA->getOperand();
194194
break;
195195
}

include/swift/SIL/SILCloner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,7 @@ SILCloner<ImplClass>::visitTupleExtractInst(TupleExtractInst *Inst) {
19461946
recordClonedInstruction(
19471947
Inst, getBuilder().createTupleExtract(
19481948
getOpLocation(Inst->getLoc()), getOpValue(Inst->getOperand()),
1949-
Inst->getFieldNo(), getOpType(Inst->getType())));
1949+
Inst->getFieldIndex(), getOpType(Inst->getType())));
19501950
}
19511951

19521952
template<typename ImplClass>
@@ -1956,7 +1956,7 @@ SILCloner<ImplClass>::visitTupleElementAddrInst(TupleElementAddrInst *Inst) {
19561956
recordClonedInstruction(
19571957
Inst, getBuilder().createTupleElementAddr(
19581958
getOpLocation(Inst->getLoc()), getOpValue(Inst->getOperand()),
1959-
Inst->getFieldNo(), getOpType(Inst->getType())));
1959+
Inst->getFieldIndex(), getOpType(Inst->getType())));
19601960
}
19611961

19621962
template<typename ImplClass>

include/swift/SIL/SILInstruction.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5715,7 +5715,7 @@ class TupleExtractInst
57155715
}
57165716

57175717
public:
5718-
unsigned getFieldNo() const {
5718+
unsigned getFieldIndex() const {
57195719
return SILInstruction::Bits.TupleExtractInst.FieldNo;
57205720
}
57215721

@@ -5747,7 +5747,7 @@ class TupleElementAddrInst
57475747
}
57485748

57495749
public:
5750-
unsigned getFieldNo() const {
5750+
unsigned getFieldIndex() const {
57515751
return SILInstruction::Bits.TupleElementAddrInst.FieldNo;
57525752
}
57535753

@@ -5811,8 +5811,7 @@ class FieldIndexCacheBase : public SingleValueInstruction {
58115811

58125812
VarDecl *getField() const { return field; }
58135813

5814-
// FIXME: this should be called getFieldIndex().
5815-
unsigned getFieldNo() const {
5814+
unsigned getFieldIndex() const {
58165815
unsigned idx = SILInstruction::Bits.FieldIndexCacheBase.FieldIndex;
58175816
if (idx != InvalidFieldIndex)
58185817
return idx;

lib/IRGen/IRGenSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3787,7 +3787,7 @@ void IRGenSILFunction::visitTupleExtractInst(swift::TupleExtractInst *i) {
37873787
projectTupleElementFromExplosion(*this,
37883788
baseType,
37893789
fullTuple,
3790-
i->getFieldNo(),
3790+
i->getFieldIndex(),
37913791
output);
37923792
(void)fullTuple.claimAll();
37933793
setLoweredExplosion(i, output);
@@ -3799,7 +3799,7 @@ void IRGenSILFunction::visitTupleElementAddrInst(swift::TupleElementAddrInst *i)
37993799
SILType baseType = i->getOperand()->getType();
38003800

38013801
Address field = projectTupleElementAddress(*this, base, baseType,
3802-
i->getFieldNo());
3802+
i->getFieldIndex());
38033803
setLoweredAddress(i, field);
38043804
}
38053805

lib/SIL/IR/SILGlobalVariable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ BuiltinInst *SILGlobalVariable::getOffsetSubtract(const TupleExtractInst *TE,
8585
// Match the pattern:
8686
// tuple_extract(usub_with_overflow(x, integer_literal, integer_literal 0), 0)
8787

88-
if (TE->getFieldNo() != 0)
88+
if (TE->getFieldIndex() != 0)
8989
return nullptr;
9090

9191
auto *BI = dyn_cast<BuiltinInst>(TE->getOperand());

lib/SIL/IR/SILInstruction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ namespace {
579579
auto *X = cast<TupleExtractInst>(LHS);
580580
if (X->getTupleType() != RHS->getTupleType())
581581
return false;
582-
if (X->getFieldNo() != RHS->getFieldNo())
582+
if (X->getFieldIndex() != RHS->getFieldIndex())
583583
return false;
584584
return true;
585585
}
@@ -590,7 +590,7 @@ namespace {
590590
auto *X = cast<TupleElementAddrInst>(LHS);
591591
if (X->getTupleType() != RHS->getTupleType())
592592
return false;
593-
if (X->getFieldNo() != RHS->getFieldNo())
593+
if (X->getFieldIndex() != RHS->getFieldIndex())
594594
return false;
595595
return true;
596596
}

lib/SIL/IR/SILInstructions.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ bool TupleExtractInst::isTrivialEltOfOneRCIDTuple() const {
12581258
// parent tuple has only one non-trivial field.
12591259
bool FoundNonTrivialField = false;
12601260
SILType OpTy = getOperand()->getType();
1261-
unsigned FieldNo = getFieldNo();
1261+
unsigned FieldNo = getFieldIndex();
12621262

12631263
// For each element index of the tuple...
12641264
for (unsigned i = 0, e = getNumTupleElts(); i != e; ++i) {
@@ -1300,7 +1300,7 @@ bool TupleExtractInst::isEltOnlyNonTrivialElt() const {
13001300
// Ok, we know that the elt we are extracting is non-trivial. Make sure that
13011301
// we have no other non-trivial elts.
13021302
SILType OpTy = getOperand()->getType();
1303-
unsigned FieldNo = getFieldNo();
1303+
unsigned FieldNo = getFieldIndex();
13041304

13051305
// For each element index of the tuple...
13061306
for (unsigned i = 0, e = getNumTupleElts(); i != e; ++i) {
@@ -1348,7 +1348,7 @@ VarDecl *swift::getIndexedField(NominalTypeDecl *decl, unsigned index) {
13481348
if (auto *classDecl = dyn_cast<ClassDecl>(decl)) {
13491349
for (auto *superDecl = classDecl->getSuperclassDecl(); superDecl != nullptr;
13501350
superDecl = superDecl->getSuperclassDecl()) {
1351-
assert(index > superDecl->getStoredProperties().size()
1351+
assert(index >= superDecl->getStoredProperties().size()
13521352
&& "field index cannot refer to a superclass field");
13531353
index -= superDecl->getStoredProperties().size();
13541354
}
@@ -1357,7 +1357,7 @@ VarDecl *swift::getIndexedField(NominalTypeDecl *decl, unsigned index) {
13571357
}
13581358

13591359
unsigned FieldIndexCacheBase::cacheFieldIndex() {
1360-
unsigned index = getFieldIndex(getParentDecl(), getField());
1360+
unsigned index = ::getFieldIndex(getParentDecl(), getField());
13611361
SILInstruction::Bits.FieldIndexCacheBase.FieldIndex = index;
13621362
return index;
13631363
}

lib/SIL/IR/SILPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,11 +1774,11 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
17741774
}
17751775

17761776
void visitTupleExtractInst(TupleExtractInst *EI) {
1777-
*this << getIDAndType(EI->getOperand()) << ", " << EI->getFieldNo();
1777+
*this << getIDAndType(EI->getOperand()) << ", " << EI->getFieldIndex();
17781778
}
17791779

17801780
void visitTupleElementAddrInst(TupleElementAddrInst *EI) {
1781-
*this << getIDAndType(EI->getOperand()) << ", " << EI->getFieldNo();
1781+
*this << getIDAndType(EI->getOperand()) << ", " << EI->getFieldIndex();
17821782
}
17831783
void visitStructExtractInst(StructExtractInst *EI) {
17841784
*this << getIDAndType(EI->getOperand()) << ", #";

lib/SIL/Utils/MemAccessUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ AccessedStorage::AccessedStorage(SILValue base, Kind kind) {
118118
// conservative given that classes are not "uniquely identified".
119119
auto *REA = cast<RefElementAddrInst>(base);
120120
value = stripBorrow(REA->getOperand());
121-
setElementIndex(REA->getFieldNo());
121+
setElementIndex(REA->getFieldIndex());
122122
break;
123123
}
124124
case Tail: {

0 commit comments

Comments
 (0)