Skip to content

Commit 5470573

Browse files
committed
AST: Split off Effects.cpp from Decl.cpp
1 parent f7952ab commit 5470573

File tree

4 files changed

+74
-51
lines changed

4 files changed

+74
-51
lines changed

lib/AST/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ add_swift_host_library(swiftAST STATIC
4444
DiagnosticEngine.cpp
4545
DiagnosticList.cpp
4646
DocComment.cpp
47+
Effects.cpp
4748
Evaluator.cpp
4849
Expr.cpp
4950
ExtInfo.cpp

lib/AST/Decl.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4934,26 +4934,6 @@ bool ProtocolDecl::existentialTypeSupported() const {
49344934
ExistentialTypeSupportedRequest{const_cast<ProtocolDecl *>(this)}, true);
49354935
}
49364936

4937-
void swift::simple_display(llvm::raw_ostream &out, const ProtocolRethrowsRequirementList list) {
4938-
for (auto entry : list) {
4939-
simple_display(out, entry.first);
4940-
simple_display(out, entry.second);
4941-
}
4942-
}
4943-
4944-
4945-
ProtocolRethrowsRequirementList
4946-
ProtocolDecl::getRethrowingRequirements() const {
4947-
return evaluateOrDefault(getASTContext().evaluator,
4948-
ProtocolRethrowsRequirementsRequest{const_cast<ProtocolDecl *>(this)},
4949-
ProtocolRethrowsRequirementList());
4950-
}
4951-
4952-
bool
4953-
ProtocolDecl::isRethrowingProtocol() const {
4954-
return getRethrowingRequirements().size() > 0;
4955-
}
4956-
49574937
StringRef ProtocolDecl::getObjCRuntimeName(
49584938
llvm::SmallVectorImpl<char> &buffer) const {
49594939
// If there is an 'objc' attribute with a name, use that name.
@@ -6800,12 +6780,6 @@ bool AbstractFunctionDecl::canBeAsyncHandler() const {
68006780
false);
68016781
}
68026782

6803-
FunctionRethrowingKind AbstractFunctionDecl::getRethrowingKind() const {
6804-
return evaluateOrDefault(getASTContext().evaluator,
6805-
FunctionRethrowingKindRequest{const_cast<AbstractFunctionDecl *>(this)},
6806-
FunctionRethrowingKind::Invalid);
6807-
}
6808-
68096783
BraceStmt *AbstractFunctionDecl::getBody(bool canSynthesize) const {
68106784
if ((getBodyKind() == BodyKind::Synthesize ||
68116785
getBodyKind() == BodyKind::Unparsed) &&

lib/AST/Effects.cpp

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//===--- Effects.cpp - Effect Checking ASTs -------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file implements some logic for rethrows and reasync checking.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#include "swift/AST/ASTContext.h"
18+
#include "swift/AST/Effects.h"
19+
#include "swift/AST/Evaluator.h"
20+
#include "swift/AST/Decl.h"
21+
#include "swift/AST/Type.h"
22+
#include "swift/AST/TypeCheckRequests.h"
23+
#include "llvm/ADT/ArrayRef.h"
24+
#include "llvm/Support/raw_ostream.h"
25+
26+
using namespace swift;
27+
28+
void swift::simple_display(llvm::raw_ostream &out,
29+
const ProtocolRethrowsRequirementList list) {
30+
for (auto entry : list) {
31+
simple_display(out, entry.first);
32+
simple_display(out, entry.second);
33+
}
34+
}
35+
36+
ProtocolRethrowsRequirementList
37+
ProtocolDecl::getRethrowingRequirements() const {
38+
return evaluateOrDefault(getASTContext().evaluator,
39+
ProtocolRethrowsRequirementsRequest{const_cast<ProtocolDecl *>(this)},
40+
ProtocolRethrowsRequirementList());
41+
}
42+
43+
bool
44+
ProtocolDecl::isRethrowingProtocol() const {
45+
return getRethrowingRequirements().size() > 0;
46+
}
47+
48+
FunctionRethrowingKind AbstractFunctionDecl::getRethrowingKind() const {
49+
return evaluateOrDefault(getASTContext().evaluator,
50+
FunctionRethrowingKindRequest{const_cast<AbstractFunctionDecl *>(this)},
51+
FunctionRethrowingKind::Invalid);
52+
}
53+
54+
void swift::simple_display(llvm::raw_ostream &out,
55+
FunctionRethrowingKind kind) {
56+
switch (kind) {
57+
case FunctionRethrowingKind::None:
58+
out << "non-throwing";
59+
break;
60+
case FunctionRethrowingKind::ByClosure:
61+
out << "by closure";
62+
break;
63+
case FunctionRethrowingKind::ByConformance:
64+
out << "by conformance";
65+
break;
66+
case FunctionRethrowingKind::Throws:
67+
out << "throws";
68+
break;
69+
case FunctionRethrowingKind::Invalid:
70+
out << "invalid";
71+
break;
72+
}
73+
}

lib/AST/TypeCheckRequests.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -278,31 +278,6 @@ void ExistentialTypeSupportedRequest::cacheResult(bool value) const {
278278
decl->setCachedExistentialTypeSupported(value);
279279
}
280280

281-
//----------------------------------------------------------------------------//
282-
// getRethrowingKind computation.
283-
//----------------------------------------------------------------------------//
284-
285-
void swift::simple_display(llvm::raw_ostream &out,
286-
FunctionRethrowingKind kind) {
287-
switch (kind) {
288-
case FunctionRethrowingKind::None:
289-
out << "non-throwing";
290-
break;
291-
case FunctionRethrowingKind::ByClosure:
292-
out << "by closure";
293-
break;
294-
case FunctionRethrowingKind::ByConformance:
295-
out << "by conformance";
296-
break;
297-
case FunctionRethrowingKind::Throws:
298-
out << "throws";
299-
break;
300-
case FunctionRethrowingKind::Invalid:
301-
out << "invalid";
302-
break;
303-
}
304-
}
305-
306281
//----------------------------------------------------------------------------//
307282
// isFinal computation.
308283
//----------------------------------------------------------------------------//

0 commit comments

Comments
 (0)