Skip to content

Commit 9cf8f5b

Browse files
committed
[AST] Remove AbstractFunctionDecl::getSingleExpressionBody
This is now unused.
1 parent 840d52f commit 9cf8f5b

File tree

3 files changed

+0
-27
lines changed

3 files changed

+0
-27
lines changed

include/swift/AST/AnyFunctionRef.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,6 @@ class AnyFunctionRef {
100100
return TheFunction.get<AbstractClosureExpr *>()->hasSingleExpressionBody();
101101
}
102102

103-
Expr *getSingleExpressionBody() const {
104-
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>())
105-
return AFD->getSingleExpressionBody();
106-
return TheFunction.get<AbstractClosureExpr *>()->getSingleExpressionBody();
107-
}
108-
109103
ParameterList *getParameters() const {
110104
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>())
111105
return AFD->getParameters();

include/swift/AST/Decl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7219,8 +7219,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
72197219
return Bits.AbstractFunctionDecl.HasSingleExpressionBody;
72207220
}
72217221

7222-
Expr *getSingleExpressionBody() const;
7223-
72247222
/// Returns the string for the base name, or "_" if this is unnamed.
72257223
StringRef getNameStr() const {
72267224
assert(!getName().isSpecial() && "Cannot get string for special names");

lib/AST/Decl.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,25 +1010,6 @@ AbstractFunctionDecl::getEffectiveThrownErrorType() const {
10101010
return llvm::None;
10111011
}
10121012

1013-
Expr *AbstractFunctionDecl::getSingleExpressionBody() const {
1014-
assert(hasSingleExpressionBody() && "Not a single-expression body");
1015-
auto braceStmt = getBody();
1016-
assert(braceStmt != nullptr && "No body currently available.");
1017-
auto body = getBody()->getLastElement();
1018-
if (auto *stmt = body.dyn_cast<Stmt *>()) {
1019-
if (auto *returnStmt = dyn_cast<ReturnStmt>(stmt)) {
1020-
return returnStmt->getResult();
1021-
} else if (isa<FailStmt>(stmt)) {
1022-
// We can only get to this point if we're a type-checked ConstructorDecl
1023-
// which was originally spelled init?(...) { nil }.
1024-
//
1025-
// There no longer is a single-expression to return, so ignore null.
1026-
return nullptr;
1027-
}
1028-
}
1029-
return body.get<Expr *>();
1030-
}
1031-
10321013
bool AbstractStorageDecl::isCompileTimeConst() const {
10331014
return getAttrs().hasAttribute<CompileTimeConstAttr>();
10341015
}

0 commit comments

Comments
 (0)