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:
parent
7b3e51824e
commit
b37c967b37
third_party/mlir/include/mlir/IR
@ -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); }
|
||||
|
7
third_party/mlir/include/mlir/IR/Types.h
vendored
7
third_party/mlir/include/mlir/IR/Types.h
vendored
@ -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
Block a user