Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions flang-rt/lib/runtime/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,23 +347,21 @@ static const char *GetTypeStr(ISO::CFI_type_t type, bool dumpRawType) {
CASE(CFI_type_uint32_t)
CASE(CFI_type_uint64_t)
CASE(CFI_type_uint128_t)
default:
return nullptr;
}
#undef CASE
return nullptr;
}
TypeCode code{type};

if (!code.IsValid())
if (!code.IsValid()) {
return "invalid";

common::optional<std::pair<TypeCategory, int>> categoryAndKind =
code.GetCategoryAndKind();
if (!categoryAndKind)
}
auto categoryAndKind{code.GetCategoryAndKind()};
if (!categoryAndKind) {
return nullptr;

TypeCategory tcat;
int kind;
std::tie(tcat, kind) = *categoryAndKind;
}
TypeCategory tcat{categoryAndKind->first};
int kind{categoryAndKind->second};

#define CASE(cat, k) \
case (k): \
Expand Down Expand Up @@ -434,26 +432,21 @@ void Descriptor::Dump(FILE *f, bool dumpRawType) const {
std::fprintf(f, " base_addr %p\n", raw_.base_addr);
std::fprintf(f, " elem_len %zd\n", ElementBytes());
std::fprintf(f, " version %d\n", static_cast<int>(raw_.version));
if (rank() > 0) {
std::fprintf(f, " rank %d\n", rank());
} else {
std::fprintf(f, " scalar\n");
}
int ty = static_cast<int>(raw_.type);
if (const char *tyStr = GetTypeStr(raw_.type, dumpRawType)) {
std::fprintf(f, " rank %d%s\n", rank(), rank() ? "" : " (scalar)");
int ty{static_cast<int>(raw_.type)};
if (const char *tyStr{GetTypeStr(raw_.type, dumpRawType)}) {
std::fprintf(f, " type %d \"%s\"\n", ty, tyStr);
} else {
std::fprintf(f, " type %d\n", ty);
}
int attr = static_cast<int>(raw_.attribute);
int attr{static_cast<int>(raw_.attribute)};
if (IsPointer()) {
std::fprintf(f, " attribute %d (pointer) \n", attr);
} else if (IsAllocatable()) {
std::fprintf(f, " attribute %d (allocatable)\n", attr);
} else {
std::fprintf(f, " attribute %d\n", attr);
}

std::fprintf(f, " extra %d\n", static_cast<int>(raw_.extra));
std::fprintf(f, " addendum %d\n", static_cast<int>(HasAddendum()));
std::fprintf(f, " alloc_idx %d\n", static_cast<int>(GetAllocIdx()));
Expand Down
4 changes: 2 additions & 2 deletions flang-rt/unittests/Runtime/Descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ TEST(Descriptor, Dump) {
" base_addr [address]\n"
" elem_len 4\n"
" version 20240719\n"
" scalar\n"
" rank 0 (scalar)\n"
" type 9 \"INTEGER(kind=4)\"\n"
" attribute 0\n"
" extra 0\n"
Expand All @@ -207,7 +207,7 @@ TEST(Descriptor, Dump) {
" base_addr [address]\n"
" elem_len 4\n"
" version 20240719\n"
" scalar\n"
" rank 0 (scalar)\n"
" type 9 \"CFI_type_int32_t\"\n"
" attribute 0\n"
" extra 0\n"
Expand Down
Loading