Skip to content

[silgen] Convert else-if in a for-loop into a if continue. #8693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions lib/SILGen/SILGenApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3155,27 +3155,33 @@ void TupleShuffleArgEmitter::emitDefaultArgsAndFinalize(ArgEmitter &parent) {
parent.Args.append(extent.Args.begin(), extent.Args.end());
for (auto &inoutArg : extent.InOutArgs)
parent.InOutArguments.push_back(std::move(inoutArg));
continue;
}

// If this is default initialization, call the default argument
// generator.
} else if (innerIndex == TupleShuffleExpr::DefaultInitialize) {
if (innerIndex == TupleShuffleExpr::DefaultInitialize) {
// Otherwise, emit the default initializer, then map that as a
// default argument.
CanType eltType = outerElements[outerIndex].getType()->getCanonicalType();
auto origType = origParamType.getTupleElementType(outerIndex);
RValue value = parent.SGF.emitApplyOfDefaultArgGenerator(
outer, defaultArgsOwner, outerIndex, eltType, origType);
parent.emit(ArgumentSource(outer, std::move(value)), origType);
continue;
}

// If this is caller default initialization, generate the
// appropriate value.
} else if (innerIndex == TupleShuffleExpr::CallerDefaultInitialize) {
// If this is caller default initialization, generate the
// appropriate value.
if (innerIndex == TupleShuffleExpr::CallerDefaultInitialize) {
auto arg = callerDefaultArgs[nextCallerDefaultArg++];
parent.emit(ArgumentSource(arg),
origParamType.getTupleElementType(outerIndex));
continue;
}

// If we're supposed to create a varargs array with the rest, do so.
} else if (innerIndex == TupleShuffleExpr::Variadic) {
// If we're supposed to create a varargs array with the rest, do so.
if (innerIndex == TupleShuffleExpr::Variadic) {
auto &varargsField = outerElements[outerIndex];
assert(varargsField.isVararg() &&
"Cannot initialize nonvariadic element");
Expand All @@ -3197,11 +3203,11 @@ void TupleShuffleArgEmitter::emitDefaultArgsAndFinalize(ArgEmitter &parent) {
parent.emit(
ArgumentSource(outer, RValue(parent.SGF, outer, eltType, varargs)),
origParamType.getTupleElementType(outerIndex));

// That's the last special case defined so far.
} else {
llvm_unreachable("unexpected special case in tuple shuffle!");
continue;
}

// That's the last special case defined so far.
llvm_unreachable("unexpected special case in tuple shuffle!");
}
}

Expand Down