Merge pull request #23251 from nate-chandler/nate/omit-return

Allow return to be omitted from single expression functions.
This commit is contained in:
nate-chandler
2019-04-25 08:36:34 -07:00
committed by GitHub
34 changed files with 2163 additions and 17 deletions

View File

@@ -406,8 +406,7 @@ protected:
SWIFT_INLINE_BITFIELD(SubscriptDecl, VarDecl, 2,
StaticSpelling : 2
);
SWIFT_INLINE_BITFIELD(AbstractFunctionDecl, ValueDecl, 3+8+1+1+1+1+1+1+1,
SWIFT_INLINE_BITFIELD(AbstractFunctionDecl, ValueDecl, 3+8+1+1+1+1+1+1+1+1,
/// \see AbstractFunctionDecl::BodyKind
BodyKind : 3,
@@ -431,7 +430,10 @@ protected:
/// Whether this member was synthesized as part of a derived
/// protocol conformance.
Synthesized : 1
Synthesized : 1,
/// Whether this member's body consists of a single expression.
HasSingleExpressionBody : 1
);
SWIFT_INLINE_BITFIELD(FuncDecl, AbstractFunctionDecl, 1+2+1+1+2,
@@ -5529,6 +5531,7 @@ protected:
Bits.AbstractFunctionDecl.NeedsNewVTableEntry = false;
Bits.AbstractFunctionDecl.HasComputedNeedsNewVTableEntry = false;
Bits.AbstractFunctionDecl.Synthesized = false;
Bits.AbstractFunctionDecl.HasSingleExpressionBody = false;
}
void setBodyKind(BodyKind K) {
@@ -5536,6 +5539,17 @@ protected:
}
public:
void setHasSingleExpressionBody(bool Has = true) {
Bits.AbstractFunctionDecl.HasSingleExpressionBody = Has;
}
bool hasSingleExpressionBody() const {
return Bits.AbstractFunctionDecl.HasSingleExpressionBody;
}
Expr *getSingleExpressionBody() const;
void setSingleExpressionBody(Expr *NewBody);
/// Returns the string for the base name, or "_" if this is unnamed.
StringRef getNameStr() const {
assert(!getFullName().isSpecial() && "Cannot get string for special names");