AsmPrinter: Split out non-DIE printing from DIE::print(), NFC

Split out a helper `printValues()` for printing `DIEBlock` and `DIELoc`,
instead of relying on `DIE::print()`.  The shared code was actually
fairly small there.  No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243856 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2015-08-02 20:46:49 +00:00
parent 69e4c2fc86
commit 94404e8097

View File

@ -145,35 +145,33 @@ DIEValue DIE::findAttribute(dwarf::Attribute Attribute) const {
} }
#ifndef NDEBUG #ifndef NDEBUG
void DIE::print(raw_ostream &O, unsigned IndentCount) const { static void printValues(raw_ostream &O, const DIEValueList &Values,
StringRef Type, unsigned Size, unsigned IndentCount) {
O << Type << ": Size: " << Size << "\n";
unsigned I = 0;
const std::string Indent(IndentCount, ' '); const std::string Indent(IndentCount, ' ');
bool isBlock = getTag() == 0; for (const auto &V : Values.values()) {
O << Indent;
if (!isBlock) { O << "Blk[" << I++ << "]";
O << Indent O << " " << dwarf::FormEncodingString(V.getForm()) << " ";
<< "Die: " V.print(O);
<< format("0x%lx", (long)(intptr_t)this) O << "\n";
<< ", Offset: " << Offset }
<< ", Size: " << Size << "\n";
O << Indent
<< dwarf::TagString(getTag())
<< " "
<< dwarf::ChildrenString(hasChildren()) << "\n";
} else {
O << "Size: " << Size << "\n";
} }
void DIE::print(raw_ostream &O, unsigned IndentCount) const {
const std::string Indent(IndentCount, ' ');
O << Indent << "Die: " << format("0x%lx", (long)(intptr_t) this)
<< ", Offset: " << Offset << ", Size: " << Size << "\n";
O << Indent << dwarf::TagString(getTag()) << " "
<< dwarf::ChildrenString(hasChildren()) << "\n";
IndentCount += 2; IndentCount += 2;
unsigned I = 0;
for (const auto &V : values()) { for (const auto &V : values()) {
O << Indent; O << Indent;
if (!isBlock)
O << dwarf::AttributeString(V.getAttribute()); O << dwarf::AttributeString(V.getAttribute());
else
O << "Blk[" << I++ << "]";
O << " " << dwarf::FormEncodingString(V.getForm()) << " "; O << " " << dwarf::FormEncodingString(V.getForm()) << " ";
V.print(O); V.print(O);
O << "\n"; O << "\n";
@ -183,7 +181,7 @@ void DIE::print(raw_ostream &O, unsigned IndentCount) const {
for (const auto &Child : children()) for (const auto &Child : children())
Child.print(O, IndentCount + 4); Child.print(O, IndentCount + 4);
if (!isBlock) O << "\n"; O << "\n";
} }
void DIE::dump() { void DIE::dump() {
@ -547,8 +545,7 @@ unsigned DIELoc::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
#ifndef NDEBUG #ifndef NDEBUG
void DIELoc::print(raw_ostream &O) const { void DIELoc::print(raw_ostream &O) const {
O << "ExprLoc: "; printValues(O, *this, "ExprLoc", Size, 5);
DIE::print(O, 5);
} }
#endif #endif
@ -596,8 +593,7 @@ unsigned DIEBlock::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
#ifndef NDEBUG #ifndef NDEBUG
void DIEBlock::print(raw_ostream &O) const { void DIEBlock::print(raw_ostream &O) const {
O << "Blk: "; printValues(O, *this, "Blk", Size, 5);
DIE::print(O, 5);
} }
#endif #endif