forked from OSchip/llvm-project
Make Type and Attribute classes trivially copyable
This requires using explicitly default copy constructor and copy assignment operator instead of hand-rolled ones. These classes are indeed cheap to copy since they are wrappers around a pointer to the implementation. This change makes sure templated code can use standard type traits to understand that copying such objects is cheap and appeases analysis tools such as clang-tidy. PiperOrigin-RevId: 286725565
This commit is contained in:
parent
ee71ca1d5c
commit
dcc14f0865
|
@ -82,11 +82,8 @@ public:
|
|||
/* implicit */ Attribute(const ImplType *impl)
|
||||
: impl(const_cast<ImplType *>(impl)) {}
|
||||
|
||||
Attribute(const Attribute &other) : impl(other.impl) {}
|
||||
Attribute &operator=(Attribute other) {
|
||||
impl = other.impl;
|
||||
return *this;
|
||||
}
|
||||
Attribute(const Attribute &other) = default;
|
||||
Attribute &operator=(const Attribute &other) = default;
|
||||
|
||||
bool operator==(Attribute other) const { return impl == other.impl; }
|
||||
bool operator!=(Attribute other) const { return !(*this == other); }
|
||||
|
|
|
@ -121,11 +121,8 @@ public:
|
|||
/* implicit */ Type(const ImplType *impl)
|
||||
: impl(const_cast<ImplType *>(impl)) {}
|
||||
|
||||
Type(const Type &other) : impl(other.impl) {}
|
||||
Type &operator=(Type other) {
|
||||
impl = other.impl;
|
||||
return *this;
|
||||
}
|
||||
Type(const Type &other) = default;
|
||||
Type &operator=(const Type &other) = default;
|
||||
|
||||
bool operator==(Type other) const { return impl == other.impl; }
|
||||
bool operator!=(Type other) const { return !(*this == other); }
|
||||
|
|
Loading…
Reference in New Issue