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
56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
//===--- SwitchCaseFullExpr.h -----------------------------------*- C++ -*-===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_SILGEN_SWITCHCASEFULLEXPR_H
|
|
#define SWIFT_SILGEN_SWITCHCASEFULLEXPR_H
|
|
|
|
#include "Scope.h"
|
|
|
|
namespace swift {
|
|
namespace Lowering {
|
|
|
|
class SILGenFunction;
|
|
|
|
/// A cleanup scope RAII object, like FullExpr, that comes with a JumpDest for a
|
|
/// continuation block. It is intended to be used to handle switch cases.
|
|
///
|
|
/// You *must* call exit() at some point.
|
|
///
|
|
/// This scope is also exposed to the debug info.
|
|
class SwitchCaseFullExpr {
|
|
SILGenFunction &SGF;
|
|
Scope scope;
|
|
CleanupLocation loc;
|
|
NullablePtr<SILBasicBlock> contBlock;
|
|
|
|
public:
|
|
SwitchCaseFullExpr(SILGenFunction &SGF, CleanupLocation loc);
|
|
SwitchCaseFullExpr(SILGenFunction &SGF, CleanupLocation loc,
|
|
SILBasicBlock *contBlock);
|
|
|
|
~SwitchCaseFullExpr() = default;
|
|
|
|
SwitchCaseFullExpr(const SwitchCaseFullExpr &) = delete;
|
|
SwitchCaseFullExpr &operator=(const SwitchCaseFullExpr &) = delete;
|
|
|
|
/// Pop the scope and branch to the cont block.
|
|
void exitAndBranch(SILLocation loc, ArrayRef<SILValue> result = {});
|
|
|
|
/// Pop the scope and do not branch to the cont block.
|
|
void exit();
|
|
};
|
|
|
|
} // namespace Lowering
|
|
} // namespace swift
|
|
|
|
#endif
|