Skip to content

Commit 37dcacf

Browse files
committed
[sil] Add 'const' to SILArgument methods that are actually 'const'
1 parent 5d2137b commit 37dcacf

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

include/swift/SIL/SILArgument.h

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,22 @@ class SILArgument : public ValueBase {
127127

128128
/// Return true if this block argument is actually a phi argument as
129129
/// opposed to a cast or projection.
130-
bool isPhiArgument();
130+
bool isPhiArgument() const;
131131

132132
/// If this argument is a phi, return the incoming phi value for the given
133133
/// predecessor BB. If this argument is not a phi, return an invalid SILValue.
134-
SILValue getIncomingPhiValue(SILBasicBlock *predBlock);
134+
SILValue getIncomingPhiValue(SILBasicBlock *predBlock) const;
135135

136136
/// If this argument is a phi, populate `OutArray` with the incoming phi
137137
/// values for each predecessor BB. If this argument is not a phi, return
138138
/// false.
139-
bool getIncomingPhiValues(SmallVectorImpl<SILValue> &returnedPhiValues);
139+
bool getIncomingPhiValues(SmallVectorImpl<SILValue> &returnedPhiValues) const;
140140

141141
/// If this argument is a phi, populate `OutArray` with each predecessor block
142142
/// and its incoming phi value. If this argument is not a phi, return false.
143143
bool
144144
getIncomingPhiValues(SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>>
145-
&returnedPredAndPhiValuePairs);
145+
&returnedPredAndPhiValuePairs) const;
146146

147147
/// Returns true if we were able to find a single terminator operand value for
148148
/// each predecessor of this arguments basic block. The found values are
@@ -152,7 +152,7 @@ class SILArgument : public ValueBase {
152152
/// terminator. e.g. the incoming value for a switch_enum payload argument is
153153
/// the enum itself (the operand of the switch_enum).
154154
bool getSingleTerminatorOperands(
155-
SmallVectorImpl<SILValue> &returnedSingleTermOperands);
155+
SmallVectorImpl<SILValue> &returnedSingleTermOperands) const;
156156

157157
/// Returns true if we were able to find single terminator operand values for
158158
/// each predecessor of this arguments basic block. The found values are
@@ -163,7 +163,7 @@ class SILArgument : public ValueBase {
163163
/// the enum itself (the operand of the switch_enum).
164164
bool getSingleTerminatorOperands(
165165
SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>>
166-
&returnedSingleTermOperands);
166+
&returnedSingleTermOperands) const;
167167

168168
/// If this SILArgument's parent block has a single predecessor whose
169169
/// terminator has a single operand, return the incoming operand of the
@@ -209,22 +209,22 @@ class SILPhiArgument : public SILArgument {
209209
public:
210210
/// Return true if this is block argument is actually a phi argument as
211211
/// opposed to a cast or projection.
212-
bool isPhiArgument();
212+
bool isPhiArgument() const;
213213

214214
/// If this argument is a phi, return the incoming phi value for the given
215215
/// predecessor BB. If this argument is not a phi, return an invalid SILValue.
216216
///
217217
/// FIXME: Once SILPhiArgument actually implies that it is a phi argument,
218218
/// this will be guaranteed to return a valid SILValue.
219-
SILValue getIncomingPhiValue(SILBasicBlock *predBlock);
219+
SILValue getIncomingPhiValue(SILBasicBlock *predBlock) const;
220220

221221
/// If this argument is a phi, populate `OutArray` with the incoming phi
222222
/// values for each predecessor BB. If this argument is not a phi, return
223223
/// false.
224224
///
225225
/// FIXME: Once SILPhiArgument actually implies that it is a phi argument,
226226
/// this will always succeed.
227-
bool getIncomingPhiValues(SmallVectorImpl<SILValue> &returnedPhiValues);
227+
bool getIncomingPhiValues(SmallVectorImpl<SILValue> &returnedPhiValues) const;
228228

229229
/// If this argument is a phi, populate `OutArray` with each predecessor block
230230
/// and its incoming phi value. If this argument is not a phi, return false.
@@ -233,7 +233,7 @@ class SILPhiArgument : public SILArgument {
233233
/// this will always succeed.
234234
bool
235235
getIncomingPhiValues(SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>>
236-
&returnedPredAndPhiValuePairs);
236+
&returnedPredAndPhiValuePairs) const;
237237

238238
/// Returns true if we were able to find a single terminator operand value for
239239
/// each predecessor of this arguments basic block. The found values are
@@ -243,7 +243,7 @@ class SILPhiArgument : public SILArgument {
243243
/// terminator. e.g. the incoming value for a switch_enum payload argument is
244244
/// the enum itself (the operand of the switch_enum).
245245
bool getSingleTerminatorOperands(
246-
SmallVectorImpl<SILValue> &returnedSingleTermOperands);
246+
SmallVectorImpl<SILValue> &returnedSingleTermOperands) const;
247247

248248
/// Returns true if we were able to find single terminator operand values for
249249
/// each predecessor of this arguments basic block. The found values are
@@ -254,7 +254,7 @@ class SILPhiArgument : public SILArgument {
254254
/// the enum itself (the operand of the switch_enum).
255255
bool getSingleTerminatorOperands(
256256
SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>>
257-
&returnedSingleTermOperands);
257+
&returnedSingleTermOperands) const;
258258

259259
/// If this SILArgument's parent block has a single predecessor whose
260260
/// terminator has a single operand, return the incoming operand of the
@@ -333,37 +333,38 @@ class SILFunctionArgument : public SILArgument {
333333
// Out of line Definitions for SILArgument to avoid Forward Decl issues
334334
//===----------------------------------------------------------------------===//
335335

336-
inline bool SILArgument::isPhiArgument() {
336+
inline bool SILArgument::isPhiArgument() const {
337337
if (auto *phiArg = dyn_cast<SILPhiArgument>(this))
338338
return phiArg->isPhiArgument();
339339

340340
return false;
341341
}
342342

343-
inline SILValue SILArgument::getIncomingPhiValue(SILBasicBlock *predBlock) {
343+
inline SILValue
344+
SILArgument::getIncomingPhiValue(SILBasicBlock *predBlock) const {
344345
if (isa<SILFunctionArgument>(this))
345346
return SILValue();
346347
return cast<SILPhiArgument>(this)->getIncomingPhiValue(predBlock);
347348
}
348349

349350
inline bool SILArgument::getIncomingPhiValues(
350-
SmallVectorImpl<SILValue> &returnedPhiValues) {
351+
SmallVectorImpl<SILValue> &returnedPhiValues) const {
351352
if (isa<SILFunctionArgument>(this))
352353
return false;
353354
return cast<SILPhiArgument>(this)->getIncomingPhiValues(returnedPhiValues);
354355
}
355356

356357
inline bool SILArgument::getIncomingPhiValues(
357358
SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>>
358-
&returnedPredAndPhiValuePairs) {
359+
&returnedPredAndPhiValuePairs) const {
359360
if (isa<SILFunctionArgument>(this))
360361
return false;
361362
return cast<SILPhiArgument>(this)->getIncomingPhiValues(
362363
returnedPredAndPhiValuePairs);
363364
}
364365

365366
inline bool SILArgument::getSingleTerminatorOperands(
366-
SmallVectorImpl<SILValue> &returnedSingleTermOperands) {
367+
SmallVectorImpl<SILValue> &returnedSingleTermOperands) const {
367368
if (isa<SILFunctionArgument>(this))
368369
return false;
369370
return cast<SILPhiArgument>(this)->getSingleTerminatorOperands(
@@ -372,7 +373,7 @@ inline bool SILArgument::getSingleTerminatorOperands(
372373

373374
inline bool SILArgument::getSingleTerminatorOperands(
374375
SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>>
375-
&returnedSingleTermOperands) {
376+
&returnedSingleTermOperands) const {
376377
if (isa<SILFunctionArgument>(this))
377378
return false;
378379
return cast<SILPhiArgument>(this)->getSingleTerminatorOperands(

lib/SIL/SILArgument.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ SILModule &SILArgument::getModule() const {
7272
// expensive to call this helper instead of simply specifying phis with an
7373
// opcode. It results in repeated CFG traversals and repeated, unnecessary
7474
// switching over terminator opcodes.
75-
bool SILPhiArgument::isPhiArgument() {
75+
bool SILPhiArgument::isPhiArgument() const {
7676
// No predecessors indicates an unreachable block.
7777
if (getParent()->pred_empty())
7878
return false;
@@ -101,7 +101,7 @@ static SILValue getIncomingPhiValueForPred(const SILBasicBlock *parentBlock,
101101
->getArgForDestBB(parentBlock, argIndex);
102102
}
103103

104-
SILValue SILPhiArgument::getIncomingPhiValue(SILBasicBlock *predBlock) {
104+
SILValue SILPhiArgument::getIncomingPhiValue(SILBasicBlock *predBlock) const {
105105
if (!isPhiArgument())
106106
return SILValue();
107107

@@ -118,7 +118,7 @@ SILValue SILPhiArgument::getIncomingPhiValue(SILBasicBlock *predBlock) {
118118
}
119119

120120
bool SILPhiArgument::getIncomingPhiValues(
121-
SmallVectorImpl<SILValue> &returnedPhiValues) {
121+
SmallVectorImpl<SILValue> &returnedPhiValues) const {
122122
if (!isPhiArgument())
123123
return false;
124124

@@ -137,7 +137,7 @@ bool SILPhiArgument::getIncomingPhiValues(
137137

138138
bool SILPhiArgument::getIncomingPhiValues(
139139
SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>>
140-
&returnedPredBBAndPhiValuePairs) {
140+
&returnedPredBBAndPhiValuePairs) const {
141141
if (!isPhiArgument())
142142
return false;
143143

@@ -189,7 +189,7 @@ getSingleTerminatorOperandForPred(const SILBasicBlock *parentBlock,
189189
}
190190

191191
bool SILPhiArgument::getSingleTerminatorOperands(
192-
SmallVectorImpl<SILValue> &returnedSingleTermOperands) {
192+
SmallVectorImpl<SILValue> &returnedSingleTermOperands) const {
193193
const auto *parentBlock = getParent();
194194

195195
if (parentBlock->pred_empty())
@@ -209,7 +209,7 @@ bool SILPhiArgument::getSingleTerminatorOperands(
209209

210210
bool SILPhiArgument::getSingleTerminatorOperands(
211211
SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>>
212-
&returnedSingleTermOperands) {
212+
&returnedSingleTermOperands) const {
213213
const auto *parentBlock = getParent();
214214

215215
if (parentBlock->pred_empty())

0 commit comments

Comments
 (0)