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
Change-Id: I4a8f1ce00d7874687d41b8830dcd8d4d88243e00
This commit is contained in:
A. Unique TensorFlower 2019-12-21 09:44:50 -08:00 committed by TensorFlower Gardener
parent 7b3e51824e
commit b37c967b37
2 changed files with 4 additions and 10 deletions
third_party/mlir/include/mlir/IR

View File

@ -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); }

View File

@ -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); }