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

David Blaikie via flang-commits flang-commits at lists.llvm.org
Wed Nov 22 14:16:45 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:

We do test metaprogramming features too. (eg: the ArrayRef tests have a variety of static_asserts to check certain conversions are valid or invalid)

In this case, it actually reduced functionality/narrowed the contract (my mistake in the previous characterization - I'd thought this generalized the behavior) - so if the wider contract were wrong for some reason, I'd love/expected a test to demonstrate that (a static_assert `!is_convertible_v`) and an explanation in a commit message/review why that was the right thing to do... 

(roughly as far as these ADTs is concerned - I think if it's testable behavior that's intended to be part of the public API (not an implementation detail), we should test it - it's easy to do and helpful to keep track of the intended behavior over time - and we do that pretty well these days, partly based on reviews to ensure this, etc)

Perhaps this'd be an easier conversation in person some time. Not sure how to make progress here.

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


More information about the flang-commits mailing list