mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This commit does a few things: 1. It uses SwitchEnumBuilder so we are not re-inventing any wheels. 2. Instead of hacking around not putting in a destroy for .None on the fail pass, just *do the right thing* and recognize that we have a binary case enum and in such a case, just emit code for the other case rather than use a default case (meaning no cleanup on .none). rdar://31145255
40 lines
1.4 KiB
C++
40 lines
1.4 KiB
C++
//===--- SwitchCaseFullExpr.cpp -------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "SwitchCaseFullExpr.h"
|
|
#include "SILGenFunction.h"
|
|
#include "Scope.h"
|
|
#include "swift/SIL/SILLocation.h"
|
|
|
|
using namespace swift;
|
|
using namespace Lowering;
|
|
|
|
SwitchCaseFullExpr::SwitchCaseFullExpr(SILGenFunction &SGF, CleanupLocation loc,
|
|
SILBasicBlock *contBlock)
|
|
: SGF(SGF), scope(SGF.Cleanups, loc), loc(loc), contBlock(contBlock) {}
|
|
|
|
void SwitchCaseFullExpr::exitAndBranch(SILLocation loc,
|
|
ArrayRef<SILValue> branchArgs) {
|
|
assert(contBlock &&
|
|
"Should not call this if we do not have a continuation block");
|
|
assert(SGF.B.hasValidInsertionPoint());
|
|
scope.pop();
|
|
SGF.B.createBranch(loc, contBlock.get(), branchArgs);
|
|
}
|
|
|
|
void SwitchCaseFullExpr::exit() {
|
|
assert(!contBlock &&
|
|
"Should not call this if we do have a continuation block");
|
|
assert(SGF.B.hasValidInsertionPoint());
|
|
scope.pop();
|
|
}
|