diff options
author | Valentin Clement <clementval@gmail.com> | 2023-07-19 08:53:50 -0700 |
---|---|---|
committer | Valentin Clement <clementval@gmail.com> | 2023-07-19 08:56:54 -0700 |
commit | 703bf4c7996628c0ec179c6309858049bc11203f (patch) | |
tree | d283593d1fb789448b5162b807727079b595dde4 /flang | |
parent | 3c6ed559e5274307995586c1499a2c8e4e0276a0 (diff) | |
download | llvm-703bf4c7996628c0ec179c6309858049bc11203f.zip llvm-703bf4c7996628c0ec179c6309858049bc11203f.tar.gz llvm-703bf4c7996628c0ec179c6309858049bc11203f.tar.bz2 |
[flang] Represent unknown extent correctly in getTypeAsString
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D155655
Diffstat (limited to 'flang')
-rw-r--r-- | flang/lib/Optimizer/Dialect/FIRType.cpp | 8 | ||||
-rw-r--r-- | flang/unittests/Optimizer/FIRTypesTest.cpp | 5 |
2 files changed, 11 insertions, 2 deletions
diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp index 60d35b2..b3f5653 100644 --- a/flang/lib/Optimizer/Dialect/FIRType.cpp +++ b/flang/lib/Optimizer/Dialect/FIRType.cpp @@ -518,8 +518,12 @@ std::string getTypeAsString(mlir::Type ty, const fir::KindMapping &kindMap, name << "x" << charTy.getLen(); break; } else if (auto seqTy = mlir::dyn_cast_or_null<fir::SequenceType>(ty)) { - for (auto extent : seqTy.getShape()) - name << extent << 'x'; + for (auto extent : seqTy.getShape()) { + if (extent == fir::SequenceType::getUnknownExtent()) + name << "?x"; + else + name << extent << 'x'; + } ty = seqTy.getEleTy(); } else if (auto refTy = mlir::dyn_cast_or_null<fir::ReferenceType>(ty)) { name << "ref_"; diff --git a/flang/unittests/Optimizer/FIRTypesTest.cpp b/flang/unittests/Optimizer/FIRTypesTest.cpp index 819f50a..6a9842c 100644 --- a/flang/unittests/Optimizer/FIRTypesTest.cpp +++ b/flang/unittests/Optimizer/FIRTypesTest.cpp @@ -304,4 +304,9 @@ TEST_F(FIRTypesTest, getTypeAsString) { components.emplace_back("p1", mlir::IntegerType::get(&context, 64)); derivedTy.finalize({}, components); EXPECT_EQ("rec_derived", fir::getTypeAsString(derivedTy, *kindMap)); + mlir::Type dynArrTy = + fir::SequenceType::get({fir::SequenceType::getUnknownExtent(), + fir::SequenceType::getUnknownExtent()}, + ty); + EXPECT_EQ("?x?xi64", fir::getTypeAsString(dynArrTy, *kindMap)); } |