aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Laskey <jlaskey@mac.com>2006-02-27 10:33:53 +0000
committerJim Laskey <jlaskey@mac.com>2006-02-27 10:33:53 +0000
commit38a409c7ae3f6d1a29879fca26d9dcc032488386 (patch)
treeaf20ecfe4085d4094c491e981adc2b8bf14c753b
parentdae29989cf228a793d1cdbfe2ae2a18f5ab05d69 (diff)
Pretty print large struct constants.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26400 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/VMCore/AsmWriter.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index cf9af3f715..a3ab22c04c 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -419,6 +419,8 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV,
bool PrintName,
std::map<const Type *, std::string> &TypeTable,
SlotMachine *Machine) {
+ const int IndentSize = 4;
+ static std::string Indent = "\n";
if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
Out << (CB == ConstantBool::True ? "true" : "false");
} else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV)) {
@@ -484,7 +486,12 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV,
Out << '{';
unsigned N = CS->getNumOperands();
if (N) {
- Out << ' ';
+ if (N > 2) {
+ Indent += std::string(IndentSize, ' ');
+ Out << Indent;
+ } else {
+ Out << ' ';
+ }
printTypeInt(Out, CS->getOperand(0)->getType(), TypeTable);
WriteAsOperandInternal(Out, CS->getOperand(0),
@@ -492,11 +499,13 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV,
for (unsigned i = 1; i < N; i++) {
Out << ", ";
+ if (N > 2) Out << Indent;
printTypeInt(Out, CS->getOperand(i)->getType(), TypeTable);
WriteAsOperandInternal(Out, CS->getOperand(i),
PrintName, TypeTable, Machine);
}
+ if (N > 2) Indent.resize(Indent.size() - IndentSize);
}
Out << " }";