mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 22:00:10 +00:00
[flang] Enhance getTypeAsString for RecordType
Add support for RecordType in getTypeAsString Depends on D153461 Reviewed By: razvanlupusoru, jeanPerier Differential Revision: https://reviews.llvm.org/D153467
This commit is contained in:
parent
f9fd0062b6
commit
8015ea6a6d
@ -482,7 +482,8 @@ int getTypeCode(mlir::Type ty, const fir::KindMapping &kindMap) {
|
||||
|
||||
std::string getTypeAsString(mlir::Type ty, const fir::KindMapping &kindMap,
|
||||
llvm::StringRef prefix) {
|
||||
std::stringstream name;
|
||||
std::string buf;
|
||||
llvm::raw_string_ostream name{buf};
|
||||
name << prefix.str();
|
||||
if (!prefix.empty())
|
||||
name << "_";
|
||||
@ -535,8 +536,10 @@ std::string getTypeAsString(mlir::Type ty, const fir::KindMapping &kindMap,
|
||||
} else if (auto boxTy = mlir::dyn_cast_or_null<fir::BoxType>(ty)) {
|
||||
name << "box_";
|
||||
ty = boxTy.getEleTy();
|
||||
} else if (auto recTy = mlir::dyn_cast_or_null<fir::RecordType>(ty)) {
|
||||
name << "rec_" << recTy.getName();
|
||||
break;
|
||||
} else {
|
||||
// TODO: add support for RecordType
|
||||
llvm::report_fatal_error("unsupported type");
|
||||
}
|
||||
}
|
||||
|
@ -299,4 +299,9 @@ TEST_F(FIRTypesTest, getTypeAsString) {
|
||||
EXPECT_EQ("class_none",
|
||||
fir::getTypeAsString(
|
||||
fir::ClassType::get(mlir::NoneType::get(&context)), *kindMap));
|
||||
auto derivedTy = fir::RecordType::get(&context, "derived");
|
||||
llvm::SmallVector<std::pair<std::string, mlir::Type>> components;
|
||||
components.emplace_back("p1", mlir::IntegerType::get(&context, 64));
|
||||
derivedTy.finalize({}, components);
|
||||
EXPECT_EQ("rec_derived", fir::getTypeAsString(derivedTy, *kindMap));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user