================
@@ -65,6 +65,9 @@ class iterator_parent_access<IteratorTy, ParentTy, true> {
template <class IteratorTy, class ParentTy>
class iterator_parent_access<IteratorTy, ParentTy, false> {
public:
+ inline const ParentTy *getNodeParent() const {
+ return static_cast<const IteratorTy *>(this)->NodePtr->getParent();
+ }
----------------
antoniofrighetto wrote:
Not sure if we perhaps copied this from the specialization above, but, there
`IsConst = true` (a const_iterator) is what justifies returning a `const
ParentTy *`, whereas, here, only the iterator object is const, so returning a
non-const `ParentTy *` should suffice (consistently with `operator*() const`
returning a non-const reference). You could therefore drop all the
`const_cast<BasicBlock *>` in OMPIRBuilder.h.
Thinking more on the const_iterator overload, I think there is a bug as `this`
should have type `const iterator_parent_access *`, but then we cast it to
`IteratorTy *` dropping const, which I don't think should be legal (not sure
how this compiles though).
IListIteratorTest.cpp might use a bit of testing for this new overload (and
perhaps the one above too).
https://github.com/llvm/llvm-project/pull/228117
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits