[flang-commits] [flang] [flang] get rid of descriptor in scalar type is (PR #188762)

via flang-commits flang-commits at lists.llvm.org
Fri Mar 27 03:07:28 PDT 2026


================
@@ -68,11 +70,20 @@ class BaseBoxType : public mlir::Type {
   /// Is this a box describing volatile memory?
   bool isVolatile() const;
 
+  /// Is this a box describing an array or assumed-rank?
+  bool isArray() const;
+
   /// Return the same type, except for the shape, that is taken the shape
   /// of shapeMold.
   BaseBoxType getBoxTypeWithNewShape(mlir::Type shapeMold) const;
   BaseBoxType getBoxTypeWithNewShape(int rank) const;
 
+  /// Return a box type with the same attributes and shape, except that the
+  /// element type that is changed to the provided one. The returned box will be
+  /// a fir.class if \p polymorphic is true and a fir.box otherwise.
+  BaseBoxType getBoxTypeWithNewElementType(mlir::Type elementType,
----------------
jeanPerier wrote:

I would rather each future call site to make sure they know what they want and avoid default arguments.

My rule of thumbs is that it is OK to use a default value when adding a new argument for a niche usage where all the previous users shared the default intent and where the default is "what most would expect when reading the function name" since you easily miss their omission in when reviewing/reading code.

Here the boolean is not natural IMHO because regardless of its value, it will either change fir.box into fir.class or fir.class into fir.box, which is not someone just reading `getBoxTypeWithNewElementType(elementType)` would expect.

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


More information about the flang-commits mailing list