Skip to content

Commit 6630383

Browse files
committed
AST: Split off Effects.h from Decl.h
Also remove the hash and equality operations on ProtocolRethrowsRequirementList; this is no longer needed now that the AnyValue type eraser is gone.
1 parent 7fe3187 commit 6630383

File tree

7 files changed

+86
-79
lines changed

7 files changed

+86
-79
lines changed

include/swift/AST/Decl.h

Lines changed: 2 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ namespace swift {
8686
struct PropertyWrapperTypeInfo;
8787
struct PropertyWrapperMutability;
8888
class ProtocolDecl;
89+
class ProtocolRethrowsRequirementList;
8990
class ProtocolType;
9091
struct RawComment;
9192
enum class ResilienceExpansion : unsigned;
93+
enum class FunctionRethrowingKind : uint8_t;
9294
class TrailingWhereClause;
9395
class TypeAliasDecl;
9496
class Stmt;
@@ -3918,66 +3920,6 @@ enum class KnownDerivableProtocolKind : uint8_t {
39183920
Actor,
39193921
};
39203922

3921-
class ProtocolRethrowsRequirementList {
3922-
public:
3923-
typedef std::pair<Type, ValueDecl *> Entry;
3924-
3925-
private:
3926-
ArrayRef<Entry> entries;
3927-
3928-
public:
3929-
ProtocolRethrowsRequirementList(ArrayRef<Entry> entries) : entries(entries) {}
3930-
ProtocolRethrowsRequirementList() : entries() {}
3931-
3932-
typedef const Entry *const_iterator;
3933-
typedef const_iterator iterator;
3934-
3935-
const_iterator begin() const { return entries.begin(); }
3936-
const_iterator end() const { return entries.end(); }
3937-
3938-
size_t size() const { return entries.size(); }
3939-
3940-
void print(raw_ostream &OS) const;
3941-
3942-
SWIFT_DEBUG_DUMP;
3943-
3944-
friend bool operator==(const ProtocolRethrowsRequirementList &lhs,
3945-
const ProtocolRethrowsRequirementList &rhs) {
3946-
if (lhs.size() != rhs.size()) {
3947-
return false;
3948-
}
3949-
auto lhsIter = lhs.begin();
3950-
auto rhsIter = rhs.begin();
3951-
while (lhsIter != lhs.end() && rhsIter != rhs.end()) {
3952-
if (lhsIter->first->isEqual(rhsIter->first)) {
3953-
return false;
3954-
}
3955-
if (lhsIter->second != rhsIter->second) {
3956-
return false;
3957-
}
3958-
}
3959-
return true;
3960-
}
3961-
3962-
friend bool operator!=(const ProtocolRethrowsRequirementList &lhs,
3963-
const ProtocolRethrowsRequirementList &rhs) {
3964-
return !(lhs == rhs);
3965-
}
3966-
3967-
friend llvm::hash_code hash_value(
3968-
const ProtocolRethrowsRequirementList &list) {
3969-
return llvm::hash_combine(list.size()); // it is good enought for
3970-
// llvm::hash_code hash;
3971-
// for (auto entry : list) {
3972-
// hash = llvm::hash_combine(hash, entry.first->getCanonicalType());
3973-
// hash = llvm::hash_combine(hash, entry.second);
3974-
// }
3975-
// return hash;
3976-
}
3977-
};
3978-
3979-
void simple_display(raw_ostream &out, const ProtocolRethrowsRequirementList reqs);
3980-
39813923
/// ProtocolDecl - A declaration of a protocol, for example:
39823924
///
39833925
/// protocol Drawable {
@@ -5575,23 +5517,6 @@ class ImportAsMemberStatus {
55755517
}
55765518
};
55775519

5578-
enum class FunctionRethrowingKind : uint8_t {
5579-
/// The function is not throwing
5580-
None,
5581-
5582-
/// The function rethrows by closure
5583-
ByClosure,
5584-
5585-
/// The function rethrows by conformance
5586-
ByConformance,
5587-
5588-
/// The function throws
5589-
Throws,
5590-
5591-
/// The function throwing determinate is invalid
5592-
Invalid
5593-
};
5594-
55955520
/// Base class for function-like declarations.
55965521
class AbstractFunctionDecl : public GenericContext, public ValueDecl {
55975522
friend class NeedsNewVTableEntryRequest;

include/swift/AST/Effects.h

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
//===--- Decl.h - Swift Language Declaration ASTs ---------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2020 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 defines some data types for rethrows and reasync effects.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#ifndef SWIFT_EFFECTS_H
18+
#define SWIFT_EFFECTS_H
19+
20+
#include "swift/AST/Type.h"
21+
22+
#include <utility>
23+
24+
namespace llvm {
25+
class raw_ostream;
26+
}
27+
28+
namespace swift {
29+
30+
class ValueDecl;
31+
32+
class ProtocolRethrowsRequirementList {
33+
public:
34+
typedef std::pair<Type, ValueDecl *> Entry;
35+
36+
private:
37+
ArrayRef<Entry> entries;
38+
39+
public:
40+
ProtocolRethrowsRequirementList(ArrayRef<Entry> entries) : entries(entries) {}
41+
ProtocolRethrowsRequirementList() : entries() {}
42+
43+
typedef const Entry *const_iterator;
44+
typedef const_iterator iterator;
45+
46+
const_iterator begin() const { return entries.begin(); }
47+
const_iterator end() const { return entries.end(); }
48+
49+
size_t size() const { return entries.size(); }
50+
51+
void print(raw_ostream &OS) const;
52+
53+
SWIFT_DEBUG_DUMP;
54+
};
55+
56+
void simple_display(llvm::raw_ostream &out, const ProtocolRethrowsRequirementList reqs);
57+
58+
enum class FunctionRethrowingKind : uint8_t {
59+
/// The function is not throwing
60+
None,
61+
62+
/// The function rethrows by closure
63+
ByClosure,
64+
65+
/// The function rethrows by conformance
66+
ByConformance,
67+
68+
/// The function throws
69+
Throws,
70+
71+
/// The function throwing determinate is invalid
72+
Invalid
73+
};
74+
75+
void simple_display(llvm::raw_ostream &out, FunctionRethrowingKind value);
76+
77+
} // end namespace swift
78+
79+
#endif

include/swift/AST/TypeCheckRequests.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "swift/AST/ActorIsolation.h"
2020
#include "swift/AST/AnyFunctionRef.h"
2121
#include "swift/AST/ASTTypeIDs.h"
22+
#include "swift/AST/Effects.h"
2223
#include "swift/AST/GenericParamList.h"
2324
#include "swift/AST/GenericSignature.h"
2425
#include "swift/AST/Type.h"
@@ -790,8 +791,6 @@ class FunctionRethrowingKindRequest :
790791
bool isCached() const { return true; }
791792
};
792793

793-
void simple_display(llvm::raw_ostream &out, FunctionRethrowingKind value);
794-
795794
/// Request the custom attribute which attaches a result builder to the
796795
/// given declaration.
797796
class AttachedResultBuilderRequest :

lib/AST/ASTVerifier.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "swift/AST/ASTWalker.h"
1919
#include "swift/AST/AccessScope.h"
2020
#include "swift/AST/Decl.h"
21+
#include "swift/AST/Effects.h"
2122
#include "swift/AST/ExistentialLayout.h"
2223
#include "swift/AST/Expr.h"
2324
#include "swift/AST/ForeignAsyncConvention.h"

lib/SILGen/SILGenApply.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "Varargs.h"
2525
#include "swift/AST/ASTContext.h"
2626
#include "swift/AST/DiagnosticsSIL.h"
27+
#include "swift/AST/Effects.h"
2728
#include "swift/AST/ForeignAsyncConvention.h"
2829
#include "swift/AST/ForeignErrorConvention.h"
2930
#include "swift/AST/GenericEnvironment.h"

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "swift/AST/ASTVisitor.h"
2424
#include "swift/AST/ClangModuleLoader.h"
2525
#include "swift/AST/DiagnosticsParse.h"
26+
#include "swift/AST/Effects.h"
2627
#include "swift/AST/GenericEnvironment.h"
2728
#include "swift/AST/GenericSignatureBuilder.h"
2829
#include "swift/AST/ImportCache.h"

lib/Sema/TypeCheckEffects.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "TypeCheckConcurrency.h"
2020
#include "swift/AST/ASTWalker.h"
2121
#include "swift/AST/DiagnosticsSema.h"
22+
#include "swift/AST/Effects.h"
2223
#include "swift/AST/Initializer.h"
2324
#include "swift/AST/Pattern.h"
2425
#include "swift/AST/PrettyStackTrace.h"

0 commit comments

Comments
 (0)