Skip to content

Commit 4f33f70

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents 2d6080b + 4a68214 commit 4f33f70

File tree

4 files changed

+56
-31
lines changed

4 files changed

+56
-31
lines changed
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//===--- GenericRequirement.h - Generic requirement -------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 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+
#ifndef SWIFT_AST_GENERIC_REQUIREMENT_H
14+
#define SWIFT_AST_GENERIC_REQUIREMENT_H
15+
16+
#include "swift/AST/Type.h"
17+
18+
namespace swift {
19+
20+
class ProtocolDecl;
21+
22+
/// An abstract generic requirement.
23+
struct GenericRequirement {
24+
CanType TypeParameter;
25+
ProtocolDecl *Protocol;
26+
};
27+
28+
} // end namespace swift
29+
30+
namespace llvm {
31+
template <> struct DenseMapInfo<swift::GenericRequirement> {
32+
using GenericRequirement = swift::GenericRequirement;
33+
using CanTypeInfo = llvm::DenseMapInfo<swift::CanType>;
34+
static GenericRequirement getEmptyKey() {
35+
return {CanTypeInfo::getEmptyKey(), nullptr};
36+
}
37+
static GenericRequirement getTombstoneKey() {
38+
return {CanTypeInfo::getTombstoneKey(), nullptr};
39+
}
40+
static llvm::hash_code getHashValue(GenericRequirement req) {
41+
return hash_combine(CanTypeInfo::getHashValue(req.TypeParameter),
42+
hash_value(req.Protocol));
43+
}
44+
static bool isEqual(GenericRequirement lhs, GenericRequirement rhs) {
45+
return (lhs.TypeParameter == rhs.TypeParameter &&
46+
lhs.Protocol == rhs.Protocol);
47+
}
48+
};
49+
} // end namespace llvm
50+
51+
#endif // SWIFT_AST_GENERIC_REQUIREMENT_H

lib/IRGen/EntryPointArgumentEmission.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class Value;
1818

1919
namespace swift {
2020

21+
struct GenericRequirement;
2122
class SILArgument;
2223

2324
namespace irgen {
2425

2526
class Explosion;
26-
struct GenericRequirement;
2727
class LoadableTypeInfo;
2828
class TypeInfo;
2929

lib/IRGen/GenericRequirement.h

+3-29
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
#ifndef SWIFT_IRGEN_GENERICREQUIREMENT_H
2020
#define SWIFT_IRGEN_GENERICREQUIREMENT_H
2121

22+
#include "swift/AST/GenericRequirement.h"
2223
#include "swift/AST/Type.h"
23-
#include "llvm/ADT/SmallVector.h"
24-
#include "llvm/ADT/STLExtras.h"
2524
#include "llvm/ADT/DenseMapInfo.h"
25+
#include "llvm/ADT/STLExtras.h"
26+
#include "llvm/ADT/SmallVector.h"
2627

2728
namespace llvm {
2829
class Value;
@@ -41,12 +42,6 @@ class Address;
4142
class IRGenFunction;
4243
class IRGenModule;
4344

44-
/// An abstract generic requirement.
45-
struct GenericRequirement {
46-
CanType TypeParameter;
47-
ProtocolDecl *Protocol;
48-
};
49-
5045
using RequirementCallback =
5146
llvm::function_ref<void(GenericRequirement requirement)>;
5247

@@ -152,25 +147,4 @@ class GenericTypeRequirements {
152147
} // end namespace irgen
153148
} // end namespace swift
154149

155-
namespace llvm {
156-
template <> struct DenseMapInfo<swift::irgen::GenericRequirement> {
157-
using GenericRequirement = swift::irgen::GenericRequirement;
158-
using CanTypeInfo = llvm::DenseMapInfo<swift::CanType>;
159-
static GenericRequirement getEmptyKey() {
160-
return { CanTypeInfo::getEmptyKey(), nullptr };
161-
}
162-
static GenericRequirement getTombstoneKey() {
163-
return { CanTypeInfo::getTombstoneKey(), nullptr };
164-
}
165-
static llvm::hash_code getHashValue(GenericRequirement req) {
166-
return hash_combine(CanTypeInfo::getHashValue(req.TypeParameter),
167-
hash_value(req.Protocol));
168-
}
169-
static bool isEqual(GenericRequirement lhs, GenericRequirement rhs) {
170-
return (lhs.TypeParameter == rhs.TypeParameter &&
171-
lhs.Protocol == rhs.Protocol);
172-
}
173-
};
174-
}
175-
176150
#endif

lib/IRGen/IRGenModule.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ namespace swift {
9393
class BraceStmt;
9494
class CanType;
9595
class GeneratedModule;
96+
struct GenericRequirement;
9697
class LinkLibrary;
9798
class SILFunction;
9899
class IRGenOptions;
@@ -152,7 +153,6 @@ namespace irgen {
152153
class Signature;
153154
class StructMetadataLayout;
154155
struct SymbolicMangling;
155-
struct GenericRequirement;
156156
class TypeConverter;
157157
class TypeInfo;
158158
enum class TypeMetadataAddress;

0 commit comments

Comments
 (0)