Skip to content

[Sema] Provide copy constructor/assignment operator for TypeCheckRequ… #601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion include/swift/Sema/TypeCheckRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,42 @@ class TypeCheckRequest {
}

#include "swift/Sema/TypeCheckRequestPayloads.def"


TypeCheckRequest(const TypeCheckRequest &T) { *this = T; }

TypeCheckRequest& operator=(const TypeCheckRequest &T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be equivalent to this? (I'm not entirely sure if that's legal, I haven't written C++ in a while)

TypeCheckRequest(const TypeCheckRequest &T) = default;
TypeCheckRequest& operator=(const TypeCheckRequest &T) = default;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it wouldn't. I tried that earlier and clang rejects it, I think correctly.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf and other papers talk about this.

TheKind = T.getKind();
switch (getPayloadKind(TheKind)) {
case PayloadKind::Class:
Payload.Class = T.Payload.Class;
break;
case PayloadKind::Enum:
Payload.Enum = T.Payload.Enum;
break;
case PayloadKind::InheritedClauseEntry:
new (&Payload.InheritedClauseEntry)
std::pair<llvm::PointerUnion<TypeDecl *, ExtensionDecl *>, unsigned>();
Payload.InheritedClauseEntry = T.Payload.InheritedClauseEntry;
break;
case PayloadKind::Protocol:
Payload.Protocol = T.Payload.Protocol;
break;
case PayloadKind::DeclContextLookup:
new (&Payload.DeclContextLookup) DeclContextLookupInfo();
Payload.DeclContextLookup = T.Payload.DeclContextLookup;
break;
case PayloadKind::TypeResolution:
new (&Payload.InheritedClauseEntry)
std::tuple<TypeRepr *, DeclContext *, unsigned>();
Payload.TypeResolution = T.Payload.TypeResolution;
break;
case PayloadKind::TypeDeclResolution:
Payload.TypeDeclResolution = T.Payload.TypeDeclResolution;
break;
}
return *this;
}

/// Determine the kind of type check request.
Kind getKind() const { return TheKind; }

Expand Down