Skip to content

Commit be210fc

Browse files
committed
[Sema] Provide copy constructor/assignment operator for TypeCheckRequest.
One of the member variant of the union has a non-trivial copy constructor, therefore the copy cosntructor is implicitly deleted (in C++11). Provide the constructor and the copy assignment operator explictly in order to avoid build errors.
1 parent 563bdb9 commit be210fc

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

include/swift/Sema/TypeCheckRequest.h

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,42 @@ class TypeCheckRequest {
114114
}
115115

116116
#include "swift/Sema/TypeCheckRequestPayloads.def"
117-
117+
118+
TypeCheckRequest(const TypeCheckRequest &T) { *this = T; }
119+
120+
TypeCheckRequest& operator=(const TypeCheckRequest &T) {
121+
TheKind = T.getKind();
122+
switch (getPayloadKind(TheKind)) {
123+
case PayloadKind::Class:
124+
Payload.Class = T.Payload.Class;
125+
break;
126+
case PayloadKind::Enum:
127+
Payload.Enum = T.Payload.Enum;
128+
break;
129+
case PayloadKind::InheritedClauseEntry:
130+
new (&Payload.InheritedClauseEntry)
131+
std::pair<llvm::PointerUnion<TypeDecl *, ExtensionDecl *>, unsigned>();
132+
Payload.InheritedClauseEntry = T.Payload.InheritedClauseEntry;
133+
break;
134+
case PayloadKind::Protocol:
135+
Payload.Protocol = T.Payload.Protocol;
136+
break;
137+
case PayloadKind::DeclContextLookup:
138+
new (&Payload.DeclContextLookup) DeclContextLookupInfo();
139+
Payload.DeclContextLookup = T.Payload.DeclContextLookup;
140+
break;
141+
case PayloadKind::TypeResolution:
142+
new (&Payload.InheritedClauseEntry)
143+
std::tuple<TypeRepr *, DeclContext *, unsigned>();
144+
Payload.TypeResolution = T.Payload.TypeResolution;
145+
break;
146+
case PayloadKind::TypeDeclResolution:
147+
Payload.TypeDeclResolution = T.Payload.TypeDeclResolution;
148+
break;
149+
}
150+
return *this;
151+
}
152+
118153
/// Determine the kind of type check request.
119154
Kind getKind() const { return TheKind; }
120155

0 commit comments

Comments
 (0)