Skip to content

Commit 7fe9e88

Browse files
committed
Apply style fixes from Peter (#170227)
1 parent 22f72da commit 7fe9e88

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

flang-rt/lib/runtime/descriptor.cpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -347,23 +347,21 @@ static const char *GetTypeStr(ISO::CFI_type_t type, bool dumpRawType) {
347347
CASE(CFI_type_uint32_t)
348348
CASE(CFI_type_uint64_t)
349349
CASE(CFI_type_uint128_t)
350+
default:
351+
return nullptr;
350352
}
351353
#undef CASE
352-
return nullptr;
353354
}
354355
TypeCode code{type};
355-
356-
if (!code.IsValid())
356+
if (!code.IsValid()) {
357357
return "invalid";
358-
359-
common::optional<std::pair<TypeCategory, int>> categoryAndKind =
360-
code.GetCategoryAndKind();
361-
if (!categoryAndKind)
358+
}
359+
auto categoryAndKind{code.GetCategoryAndKind()};
360+
if (!categoryAndKind) {
362361
return nullptr;
363-
364-
TypeCategory tcat;
365-
int kind;
366-
std::tie(tcat, kind) = *categoryAndKind;
362+
}
363+
TypeCategory tcat{categoryAndKind->first};
364+
int kind{categoryAndKind->second};
367365

368366
#define CASE(cat, k) \
369367
case (k): \
@@ -434,26 +432,21 @@ void Descriptor::Dump(FILE *f, bool dumpRawType) const {
434432
std::fprintf(f, " base_addr %p\n", raw_.base_addr);
435433
std::fprintf(f, " elem_len %zd\n", ElementBytes());
436434
std::fprintf(f, " version %d\n", static_cast<int>(raw_.version));
437-
if (rank() > 0) {
438-
std::fprintf(f, " rank %d\n", rank());
439-
} else {
440-
std::fprintf(f, " scalar\n");
441-
}
442-
int ty = static_cast<int>(raw_.type);
443-
if (const char *tyStr = GetTypeStr(raw_.type, dumpRawType)) {
435+
std::fprintf(f, " rank %d%s\n", rank(), rank() ? "" : " (scalar)");
436+
int ty{static_cast<int>(raw_.type)};
437+
if (const char *tyStr{GetTypeStr(raw_.type, dumpRawType)}) {
444438
std::fprintf(f, " type %d \"%s\"\n", ty, tyStr);
445439
} else {
446440
std::fprintf(f, " type %d\n", ty);
447441
}
448-
int attr = static_cast<int>(raw_.attribute);
442+
int attr{static_cast<int>(raw_.attribute)};
449443
if (IsPointer()) {
450444
std::fprintf(f, " attribute %d (pointer) \n", attr);
451445
} else if (IsAllocatable()) {
452446
std::fprintf(f, " attribute %d (allocatable)\n", attr);
453447
} else {
454448
std::fprintf(f, " attribute %d\n", attr);
455449
}
456-
457450
std::fprintf(f, " extra %d\n", static_cast<int>(raw_.extra));
458451
std::fprintf(f, " addendum %d\n", static_cast<int>(HasAddendum()));
459452
std::fprintf(f, " alloc_idx %d\n", static_cast<int>(GetAllocIdx()));

flang-rt/unittests/Runtime/Descriptor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ TEST(Descriptor, Dump) {
206206
" base_addr [addr]\n"
207207
" elem_len 4\n"
208208
" version 20240719\n"
209-
" scalar\n"
209+
" rank 0 (scalar)\n"
210210
" type 9 \"INTEGER(kind=4)\"\n"
211211
" attribute 0\n"
212212
" extra 0\n"
@@ -216,7 +216,7 @@ TEST(Descriptor, Dump) {
216216
" base_addr [addr]\n"
217217
" elem_len 4\n"
218218
" version 20240719\n"
219-
" scalar\n"
219+
" rank 0 (scalar)\n"
220220
" type 9 \"CFI_type_int32_t\"\n"
221221
" attribute 0\n"
222222
" extra 0\n"

0 commit comments

Comments
 (0)