Skip to content

Commit 5c0165f

Browse files
authored
Merge pull request #8061 from gottesmm/small_gardening
2 parents 126058c + 6769f78 commit 5c0165f

File tree

2 files changed

+68
-68
lines changed

2 files changed

+68
-68
lines changed

lib/SILGen/ResultPlan.cpp

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ namespace {
2727
/// A result plan for evaluating an indirect result into the address
2828
/// associated with an initialization.
2929
class InPlaceInitializationResultPlan : public ResultPlan {
30-
Initialization *Init;
30+
Initialization *init;
3131

3232
public:
33-
InPlaceInitializationResultPlan(Initialization *init) : Init(init) {}
33+
InPlaceInitializationResultPlan(Initialization *init) : init(init) {}
3434

3535
RValue finish(SILGenFunction &SGF, SILLocation loc, CanType substType,
3636
ArrayRef<ManagedValue> &directResults) override {
37-
Init->finishInitialization(SGF);
37+
init->finishInitialization(SGF);
3838
return RValue();
3939
}
4040
};
@@ -43,17 +43,17 @@ class InPlaceInitializationResultPlan : public ResultPlan {
4343
/// reabstracting it. The value can actually be a tuple if the
4444
/// abstraction is opaque.
4545
class ScalarResultPlan : public ResultPlan {
46-
std::unique_ptr<TemporaryInitialization> Temporary;
47-
AbstractionPattern OrigType;
48-
Initialization *Init;
49-
SILFunctionTypeRepresentation Rep;
46+
std::unique_ptr<TemporaryInitialization> temporary;
47+
AbstractionPattern origType;
48+
Initialization *init;
49+
SILFunctionTypeRepresentation rep;
5050

5151
public:
5252
ScalarResultPlan(std::unique_ptr<TemporaryInitialization> &&temporary,
5353
AbstractionPattern origType, Initialization *init,
5454
SILFunctionTypeRepresentation rep)
55-
: Temporary(std::move(temporary)), OrigType(origType), Init(init),
56-
Rep(rep) {}
55+
: temporary(std::move(temporary)), origType(origType), init(init),
56+
rep(rep) {}
5757

5858
RValue finish(SILGenFunction &SGF, SILLocation loc, CanType substType,
5959
ArrayRef<ManagedValue> &directResults) override {
@@ -65,10 +65,10 @@ class ScalarResultPlan : public ResultPlan {
6565

6666
// If we were created with a temporary, that address was passed as
6767
// an indirect result.
68-
if (Temporary) {
68+
if (temporary) {
6969
// Establish the cleanup.
70-
Temporary->finishInitialization(SGF);
71-
value = Temporary->getManagedAddress();
70+
temporary->finishInitialization(SGF);
71+
value = temporary->getManagedAddress();
7272

7373
// If the value isn't address-only, go ahead and load.
7474
if (!substTL.isAddressOnly()) {
@@ -85,17 +85,17 @@ class ScalarResultPlan : public ResultPlan {
8585

8686
// Reabstract the value if the types don't match. This can happen
8787
// due to either substitution reabstractions or bridging.
88-
if (value.getType().hasAbstractionDifference(Rep,
88+
if (value.getType().hasAbstractionDifference(rep,
8989
substTL.getLoweredType())) {
9090
// Assume that a C-language API doesn't have substitution
9191
// reabstractions. This shouldn't be necessary, but
9292
// emitOrigToSubstValue can get upset.
93-
if (getSILFunctionLanguage(Rep) == SILFunctionLanguage::C) {
94-
value = SGF.emitBridgedToNativeValue(loc, value, Rep, substType);
93+
if (getSILFunctionLanguage(rep) == SILFunctionLanguage::C) {
94+
value = SGF.emitBridgedToNativeValue(loc, value, rep, substType);
9595

9696
} else {
97-
value = SGF.emitOrigToSubstValue(loc, value, OrigType, substType,
98-
SGFContext(Init));
97+
value = SGF.emitOrigToSubstValue(loc, value, origType, substType,
98+
SGFContext(init));
9999

100100
// If that successfully emitted into the initialization, we're done.
101101
if (value.isInContext())
@@ -104,9 +104,9 @@ class ScalarResultPlan : public ResultPlan {
104104
}
105105

106106
// Otherwise, forcibly emit into the initialization if it exists.
107-
if (Init) {
108-
Init->copyOrInitValueInto(SGF, loc, value, /*init*/ true);
109-
Init->finishInitialization(SGF);
107+
if (init) {
108+
init->copyOrInitValueInto(SGF, loc, value, /*init*/ true);
109+
init->finishInitialization(SGF);
110110
return RValue();
111111

112112
// Otherwise, we've got the r-value we want.
@@ -119,26 +119,26 @@ class ScalarResultPlan : public ResultPlan {
119119
/// A result plan which calls copyOrInitValueInto on an Initialization
120120
/// using a temporary buffer initialized by a sub-plan.
121121
class InitValueFromTemporaryResultPlan : public ResultPlan {
122-
Initialization *Init;
123-
ResultPlanPtr SubPlan;
124-
std::unique_ptr<TemporaryInitialization> Temporary;
122+
Initialization *init;
123+
ResultPlanPtr subPlan;
124+
std::unique_ptr<TemporaryInitialization> temporary;
125125

126126
public:
127127
InitValueFromTemporaryResultPlan(
128128
Initialization *init, ResultPlanPtr &&subPlan,
129129
std::unique_ptr<TemporaryInitialization> &&temporary)
130-
: Init(init), SubPlan(std::move(subPlan)),
131-
Temporary(std::move(temporary)) {}
130+
: init(init), subPlan(std::move(subPlan)),
131+
temporary(std::move(temporary)) {}
132132

133133
RValue finish(SILGenFunction &SGF, SILLocation loc, CanType substType,
134134
ArrayRef<ManagedValue> &directResults) override {
135-
RValue subResult = SubPlan->finish(SGF, loc, substType, directResults);
135+
RValue subResult = subPlan->finish(SGF, loc, substType, directResults);
136136
assert(subResult.isUsed() && "sub-plan didn't emit into context?");
137137
(void)subResult;
138138

139-
ManagedValue value = Temporary->getManagedAddress();
140-
Init->copyOrInitValueInto(SGF, loc, value, /*init*/ true);
141-
Init->finishInitialization(SGF);
139+
ManagedValue value = temporary->getManagedAddress();
140+
init->copyOrInitValueInto(SGF, loc, value, /*init*/ true);
141+
init->finishInitialization(SGF);
142142

143143
return RValue();
144144
}
@@ -147,20 +147,20 @@ class InitValueFromTemporaryResultPlan : public ResultPlan {
147147
/// A result plan which calls copyOrInitValueInto using the result of
148148
/// a sub-plan.
149149
class InitValueFromRValueResultPlan : public ResultPlan {
150-
Initialization *Init;
151-
ResultPlanPtr SubPlan;
150+
Initialization *init;
151+
ResultPlanPtr subPlan;
152152

153153
public:
154154
InitValueFromRValueResultPlan(Initialization *init, ResultPlanPtr &&subPlan)
155-
: Init(init), SubPlan(std::move(subPlan)) {}
155+
: init(init), subPlan(std::move(subPlan)) {}
156156

157157
RValue finish(SILGenFunction &SGF, SILLocation loc, CanType substType,
158158
ArrayRef<ManagedValue> &directResults) override {
159-
RValue subResult = SubPlan->finish(SGF, loc, substType, directResults);
159+
RValue subResult = subPlan->finish(SGF, loc, substType, directResults);
160160
ManagedValue value = std::move(subResult).getAsSingleValue(SGF, loc);
161161

162-
Init->copyOrInitValueInto(SGF, loc, value, /*init*/ true);
163-
Init->finishInitialization(SGF);
162+
init->copyOrInitValueInto(SGF, loc, value, /*init*/ true);
163+
init->finishInitialization(SGF);
164164

165165
return RValue();
166166
}
@@ -169,17 +169,17 @@ class InitValueFromRValueResultPlan : public ResultPlan {
169169
/// A result plan which produces a larger RValue from a bunch of
170170
/// components.
171171
class TupleRValueResultPlan : public ResultPlan {
172-
SmallVector<ResultPlanPtr, 4> EltPlans;
172+
SmallVector<ResultPlanPtr, 4> eltPlans;
173173

174174
public:
175175
TupleRValueResultPlan(ResultPlanBuilder &builder, AbstractionPattern origType,
176176
CanTupleType substType) {
177177
// Create plans for all the elements.
178-
EltPlans.reserve(substType->getNumElements());
178+
eltPlans.reserve(substType->getNumElements());
179179
for (auto i : indices(substType->getElementTypes())) {
180180
AbstractionPattern origEltType = origType.getTupleElementType(i);
181181
CanType substEltType = substType.getElementType(i);
182-
EltPlans.push_back(builder.build(nullptr, origEltType, substEltType));
182+
eltPlans.push_back(builder.build(nullptr, origEltType, substEltType));
183183
}
184184
}
185185

@@ -189,9 +189,9 @@ class TupleRValueResultPlan : public ResultPlan {
189189

190190
// Finish all the component tuples.
191191
auto substTupleType = cast<TupleType>(substType);
192-
assert(substTupleType.getElementTypes().size() == EltPlans.size());
192+
assert(substTupleType.getElementTypes().size() == eltPlans.size());
193193
for (auto i : indices(substTupleType.getElementTypes())) {
194-
RValue eltRV = EltPlans[i]->finish(
194+
RValue eltRV = eltPlans[i]->finish(
195195
SGF, loc, substTupleType.getElementType(i), directResults);
196196
tupleRV.addElement(std::move(eltRV));
197197
}
@@ -203,43 +203,43 @@ class TupleRValueResultPlan : public ResultPlan {
203203
/// A result plan which evaluates into the sub-components
204204
/// of a splittable tuple initialization.
205205
class TupleInitializationResultPlan : public ResultPlan {
206-
Initialization *TupleInit;
207-
SmallVector<InitializationPtr, 4> EltInitsBuffer;
208-
MutableArrayRef<InitializationPtr> EltInits;
209-
SmallVector<ResultPlanPtr, 4> EltPlans;
206+
Initialization *tupleInit;
207+
SmallVector<InitializationPtr, 4> eltInitsBuffer;
208+
MutableArrayRef<InitializationPtr> eltInits;
209+
SmallVector<ResultPlanPtr, 4> eltPlans;
210210

211211
public:
212212
TupleInitializationResultPlan(ResultPlanBuilder &builder,
213213
Initialization *tupleInit,
214214
AbstractionPattern origType,
215215
CanTupleType substType)
216-
: TupleInit(tupleInit) {
216+
: tupleInit(tupleInit) {
217217

218218
// Get the sub-initializations.
219-
EltInits = tupleInit->splitIntoTupleElements(builder.SGF, builder.Loc,
220-
substType, EltInitsBuffer);
219+
eltInits = tupleInit->splitIntoTupleElements(builder.SGF, builder.loc,
220+
substType, eltInitsBuffer);
221221

222222
// Create plans for all the sub-initializations.
223-
EltPlans.reserve(substType->getNumElements());
223+
eltPlans.reserve(substType->getNumElements());
224224
for (auto i : indices(substType->getElementTypes())) {
225225
AbstractionPattern origEltType = origType.getTupleElementType(i);
226226
CanType substEltType = substType.getElementType(i);
227-
Initialization *eltInit = EltInits[i].get();
228-
EltPlans.push_back(builder.build(eltInit, origEltType, substEltType));
227+
Initialization *eltInit = eltInits[i].get();
228+
eltPlans.push_back(builder.build(eltInit, origEltType, substEltType));
229229
}
230230
}
231231

232232
RValue finish(SILGenFunction &SGF, SILLocation loc, CanType substType,
233233
ArrayRef<ManagedValue> &directResults) override {
234234
auto substTupleType = cast<TupleType>(substType);
235-
assert(substTupleType.getElementTypes().size() == EltPlans.size());
235+
assert(substTupleType.getElementTypes().size() == eltPlans.size());
236236
for (auto i : indices(substTupleType.getElementTypes())) {
237237
auto eltType = substTupleType.getElementType(i);
238-
RValue eltRV = EltPlans[i]->finish(SGF, loc, eltType, directResults);
238+
RValue eltRV = eltPlans[i]->finish(SGF, loc, eltType, directResults);
239239
assert(eltRV.isUsed());
240240
(void)eltRV;
241241
}
242-
TupleInit->finishInitialization(SGF);
242+
tupleInit->finishInitialization(SGF);
243243

244244
return RValue();
245245
}
@@ -263,8 +263,8 @@ ResultPlanPtr ResultPlanBuilder::build(Initialization *init,
263263
}
264264

265265
// Otherwise, grab the next result.
266-
auto result = AllResults.front();
267-
AllResults = AllResults.slice(1);
266+
auto result = allResults.front();
267+
allResults = allResults.slice(1);
268268

269269
SILValue initAddr;
270270
if (init) {
@@ -274,8 +274,8 @@ ResultPlanPtr ResultPlanBuilder::build(Initialization *init,
274274
// there are no abstraction differences, then just do it.
275275
if (initAddr && SGF.silConv.isSILIndirect(result) &&
276276
!initAddr->getType().hasAbstractionDifference(
277-
Rep, result.getSILStorageType())) {
278-
IndirectResultAddrs.push_back(initAddr);
277+
rep, result.getSILStorageType())) {
278+
indirectResultAddrs.push_back(initAddr);
279279
return ResultPlanPtr(new InPlaceInitializationResultPlan(init));
280280
}
281281
}
@@ -291,12 +291,12 @@ ResultPlanPtr ResultPlanBuilder::build(Initialization *init,
291291
std::unique_ptr<TemporaryInitialization> temporary;
292292
if (SGF.silConv.isSILIndirect(result)) {
293293
auto &resultTL = SGF.getTypeLowering(result.getType());
294-
temporary = SGF.emitTemporary(Loc, resultTL);
295-
IndirectResultAddrs.push_back(temporary->getAddress());
294+
temporary = SGF.emitTemporary(loc, resultTL);
295+
indirectResultAddrs.push_back(temporary->getAddress());
296296
}
297297

298298
return ResultPlanPtr(
299-
new ScalarResultPlan(std::move(temporary), origType, init, Rep));
299+
new ScalarResultPlan(std::move(temporary), origType, init, rep));
300300
}
301301

302302
ResultPlanPtr ResultPlanBuilder::buildForTuple(Initialization *init,
@@ -324,7 +324,7 @@ ResultPlanPtr ResultPlanBuilder::buildForTuple(Initialization *init,
324324
auto &substTL = SGF.getTypeLowering(substType);
325325
if (substTL.isAddressOnly()) {
326326
// Create a temporary.
327-
auto temporary = SGF.emitTemporary(Loc, substTL);
327+
auto temporary = SGF.emitTemporary(loc, substTL);
328328

329329
// Build a sub-plan to emit into the temporary.
330330
auto subplan = buildForTuple(temporary.get(), origType, substType);

lib/SILGen/ResultPlan.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ using ResultPlanPtr = std::unique_ptr<ResultPlan>;
4444
/// The class for building result plans.
4545
struct ResultPlanBuilder {
4646
SILGenFunction &SGF;
47-
SILLocation Loc;
48-
ArrayRef<SILResultInfo> AllResults;
49-
SILFunctionTypeRepresentation Rep;
50-
SmallVectorImpl<SILValue> &IndirectResultAddrs;
47+
SILLocation loc;
48+
ArrayRef<SILResultInfo> allResults;
49+
SILFunctionTypeRepresentation rep;
50+
SmallVectorImpl<SILValue> &indirectResultAddrs;
5151

5252
ResultPlanBuilder(SILGenFunction &SGF, SILLocation loc,
5353
ArrayRef<SILResultInfo> allResults,
5454
SILFunctionTypeRepresentation rep,
5555
SmallVectorImpl<SILValue> &resultAddrs)
56-
: SGF(SGF), Loc(loc), AllResults(allResults), Rep(rep),
57-
IndirectResultAddrs(resultAddrs) {}
56+
: SGF(SGF), loc(loc), allResults(allResults), rep(rep),
57+
indirectResultAddrs(resultAddrs) {}
5858

5959
ResultPlanPtr build(Initialization *emitInto, AbstractionPattern origType,
6060
CanType substType);
@@ -63,7 +63,7 @@ struct ResultPlanBuilder {
6363
CanTupleType substType);
6464

6565
~ResultPlanBuilder() {
66-
assert(AllResults.empty() && "didn't consume all results!");
66+
assert(allResults.empty() && "didn't consume all results!");
6767
}
6868
};
6969

0 commit comments

Comments
 (0)