Change Block::getParent() to be a const function. This is only necessary because ilist_node_with_parent specifically requires a 'getParent() const' method. If/When ilist_node removes this constraint we should drop the const to fit the rest of the MLIR const model.
PiperOrigin-RevId: 273316153
diff --git a/third_party/mlir/include/mlir/IR/Block.h b/third_party/mlir/include/mlir/IR/Block.h
index 37ce002..c7770a1 100644
--- a/third_party/mlir/include/mlir/IR/Block.h
+++ b/third_party/mlir/include/mlir/IR/Block.h
@@ -93,8 +93,12 @@
operations.pop_back();
}
- /// Blocks are maintained in a Region.
- Region *getParent();
+ /// Provide a 'getParent' method for ilist_node_with_parent methods.
+ /// We mark it as a const function because ilist_node_with_parent specifically
+ /// requires a 'getParent() const' method. Once ilist_node removes this
+ /// constraint, we should drop the const to fit the rest of the MLIR const
+ /// model.
+ Region *getParent() const;
/// Returns the closest surrounding operation that contains this block.
Operation *getParentOp();
diff --git a/third_party/mlir/include/mlir/IR/Operation.h b/third_party/mlir/include/mlir/IR/Operation.h
index e7f22ff..5444d6c 100644
--- a/third_party/mlir/include/mlir/IR/Operation.h
+++ b/third_party/mlir/include/mlir/IR/Operation.h
@@ -563,7 +563,7 @@
}
/// Provide a 'getParent' method for ilist_node_with_parent methods.
- /// We mark it as const function because ilist_node_with_parent specifically
+ /// We mark it as a const function because ilist_node_with_parent specifically
/// requires a 'getParent() const' method. Once ilist_node removes this
/// constraint, we should drop the const to fit the rest of the MLIR const
/// model.
diff --git a/third_party/mlir/lib/IR/Block.cpp b/third_party/mlir/lib/IR/Block.cpp
index 741837f..858fcc9 100644
--- a/third_party/mlir/lib/IR/Block.cpp
+++ b/third_party/mlir/lib/IR/Block.cpp
@@ -41,7 +41,9 @@
llvm::DeleteContainerPointers(arguments);
}
-Region *Block::getParent() { return parentValidInstOrderPair.getPointer(); }
+Region *Block::getParent() const {
+ return parentValidInstOrderPair.getPointer();
+}
/// Returns the closest surrounding operation that contains this block or
/// nullptr if this block is unlinked.