Skip to content

Commit 5821b09

Browse files
authored
[clang][bytecode] Print primitive arrays in Descriptor::dumpFull() (#166393)
And recurse into records properly.
1 parent a65867a commit 5821b09

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

clang/lib/AST/ByteCode/Disasm.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,28 @@ LLVM_DUMP_METHOD void Descriptor::dumpFull(unsigned Offset,
436436

437437
FO += ElemDesc->getAllocSize();
438438
}
439+
} else if (isPrimitiveArray()) {
440+
OS.indent(Spaces) << "Elements: " << getNumElems() << '\n';
441+
OS.indent(Spaces) << "Element type: " << primTypeToString(getPrimType())
442+
<< '\n';
443+
unsigned FO = Offset + sizeof(InitMapPtr);
444+
for (unsigned I = 0; I != getNumElems(); ++I) {
445+
OS.indent(Spaces) << "Element " << I << " offset: " << FO << '\n';
446+
FO += getElemSize();
447+
}
439448
} else if (isRecord()) {
440449
ElemRecord->dump(OS, Indent + 1, Offset);
450+
unsigned I = 0;
451+
for (const Record::Field &F : ElemRecord->fields()) {
452+
OS.indent(Spaces) << "- Field " << I << ": ";
453+
{
454+
ColorScope SC(OS, true, {llvm::raw_ostream::BRIGHT_RED, true});
455+
OS << F.Decl->getName();
456+
}
457+
OS << ". Offset " << (Offset + F.Offset) << "\n";
458+
F.Desc->dumpFull(Offset + F.Offset, Indent + 1);
459+
++I;
460+
}
441461
} else if (isPrimitive()) {
442462
} else {
443463
}

0 commit comments

Comments
 (0)