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
diff --git a/third_party/mlir/include/mlir/IR/Attributes.h b/third_party/mlir/include/mlir/IR/Attributes.h
index 94aea94..b5f4b1a 100644
--- a/third_party/mlir/include/mlir/IR/Attributes.h
+++ b/third_party/mlir/include/mlir/IR/Attributes.h
@@ -82,11 +82,8 @@
/* 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); }
diff --git a/third_party/mlir/include/mlir/IR/Types.h b/third_party/mlir/include/mlir/IR/Types.h
index 11af3eb..2ab3635 100644
--- a/third_party/mlir/include/mlir/IR/Types.h
+++ b/third_party/mlir/include/mlir/IR/Types.h
@@ -121,11 +121,8 @@
/* 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); }