The AffineMap class follows the same semantic as Type and Attribute.
It is immutable object, so it make sence to mark its methods as const.
Also part of its API is already marked as const, this change just make the API consistent.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
https://mlir.llvm.org/docs/Rationale/UsageOfConst/
AffineMaps are wrappers around a pointer and are passed by-value (I systematically complain about const AffineMap &), so we don't care about const for them.
Comment Actions
@ftynse Here is the code snippet, which doesn't work for me:
if (memref.getAffineMaps().front().isPermutation()) {...}
The MemRefType::getAffineMaps returns ArrayRef, which returns const references to its elements. Also some of the methods in AffineMap already marked as const. The change just makes its API consistent.
I've seen this article about const correctness, but as I understood, it applies to Operations, not to Types and Attributes, which are immutable by their nature. And it seems that AffineMap also follows this immutable immortal singleton model as Types and Attributes. Am I wrong?