Skip to content

Commit c336e54

Browse files
committed
fix dtor
1 parent 3b3c3f6 commit c336e54

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mlir/lib/Bindings/Python/Globals.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "NanobindUtils.h"
1919
#include "mlir-c/IR.h"
20+
#include "mlir-c/Support.h"
2021
#include "mlir/CAPI/Support.h"
2122
#include "llvm/ADT/DenseMap.h"
2223
#include "llvm/ADT/StringExtras.h"
@@ -155,9 +156,13 @@ class PyGlobals {
155156
public:
156157
TypeIDAllocator() : allocator(mlirTypeIDAllocatorCreate()) {}
157158
~TypeIDAllocator() {
158-
if (!allocator.ptr)
159+
if (allocator.ptr)
159160
mlirTypeIDAllocatorDestroy(allocator);
160161
}
162+
TypeIDAllocator(const TypeIDAllocator &) = delete;
163+
TypeIDAllocator(TypeIDAllocator &&other) : allocator(other.allocator) {
164+
other.allocator.ptr = nullptr;
165+
}
161166

162167
MlirTypeIDAllocator get() { return allocator; }
163168
MlirTypeID allocate() {

0 commit comments

Comments
 (0)