Skip to content

Commit c8c2b81

Browse files
committed
[gardening] Make a piece of code a little more readable.
Basically the if/else statement of this section of code are unrelated by have the same condition (albeit inverted). Rather than keep them together and make them seem as related semantic checks, move the no implicit copy diagnostic into its own section. I am doing this as a separate commit partially to slim down the next series of commits.
1 parent ee7753c commit c8c2b81

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/SILGen/SILGenProlog.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -109,28 +109,29 @@ class EmitBBArguments : public CanTypeVisitor<EmitBBArguments,
109109

110110
// This can happen if the value is resilient in the calling convention
111111
// but not resilient locally.
112-
if (argType.isLoadable(SGF.F)) {
112+
bool argIsLoadable = argType.isLoadable(SGF.F);
113+
if (argIsLoadable) {
113114
if (argType.isAddress()) {
114115
if (mv.isPlusOne(SGF))
115116
mv = SGF.B.createLoadTake(loc, mv);
116117
else
117118
mv = SGF.B.createLoadBorrow(loc, mv);
118119
argType = argType.getObjectType();
119120
}
120-
} else {
121-
if (isNoImplicitCopy) {
122-
// We do not support no implicit copy address only types. Emit an error.
123-
auto diag = diag::noimplicitcopy_used_on_generic_or_existential;
124-
diagnose(SGF.getASTContext(), mv.getValue().getLoc().getSourceLoc(),
125-
diag);
126-
}
127121
}
128122

129123
if (argType.getASTType() != paramType.getASTType()) {
130124
// Reabstract the value if necessary.
131125
mv = SGF.emitOrigToSubstValue(loc, mv.ensurePlusOne(SGF, loc), orig, t);
132126
}
133127

128+
if (isNoImplicitCopy && !argIsLoadable) {
129+
// We do not support no implicit copy address only types. Emit an error.
130+
auto diag = diag::noimplicitcopy_used_on_generic_or_existential;
131+
diagnose(SGF.getASTContext(), mv.getValue().getLoc().getSourceLoc(),
132+
diag);
133+
}
134+
134135
// If the value is a (possibly optional) ObjC block passed into the entry
135136
// point of the function, then copy it so we can treat the value reliably
136137
// as a heap object. Escape analysis can eliminate this copy if it's

0 commit comments

Comments
 (0)