[flang-commits] [mlir] [flang] Make MLIR Value more consistent in terms of `const` "correctness" (NFC) (PR #72765)

David Blaikie via flang-commits flang-commits at lists.llvm.org
Mon Nov 20 13:24:08 PST 2023


================
@@ -335,8 +335,9 @@ namespace llvm {
     MutableArrayRef(T *begin, T *end) : ArrayRef<T>(begin, end) {}
 
     /// Construct a MutableArrayRef from a SmallVector.
-    /*implicit*/ MutableArrayRef(SmallVectorImpl<T> &Vec)
-    : ArrayRef<T>(Vec) {}
+    template <typename U>
+    /*implicit*/ MutableArrayRef(const SmallVectorTemplateCommon<T, U> &Vec)
+        : ArrayRef<T>(Vec) {}
----------------
dwblaikie wrote:

Didn't figure it was NFC - it makes the ctor usable with a wider range of types, so I'd expect the unit test to reflect that wider contract.

And, wait a sec - isn't this invalid? MutableArrayRef needs a non-constant backing store, since it'll expose mutability, but wouldn't `const SmallVectorTemplateCommon<T, U> &` be a constant backing store? So this would allow mutation of a constant sequence?

https://github.com/llvm/llvm-project/pull/72765


More information about the flang-commits mailing list