diff options
| author | Jim Laskey <jlaskey@mac.com> | 2006-02-27 10:33:53 +0000 |
|---|---|---|
| committer | Jim Laskey <jlaskey@mac.com> | 2006-02-27 10:33:53 +0000 |
| commit | 6be3d8e0df865646d3356656546a3a4cb2b318ed (patch) | |
| tree | b50f3371b30809139ad763a1d9f9fe5d494295bd | |
| parent | 8f2c1021b4870caf175cf77e47c4dc25cdaaeec9 (diff) | |
| download | bcm5719-llvm-6be3d8e0df865646d3356656546a3a4cb2b318ed.tar.gz bcm5719-llvm-6be3d8e0df865646d3356656546a3a4cb2b318ed.zip | |
Pretty print large struct constants.
llvm-svn: 26400
| -rw-r--r-- | llvm/lib/VMCore/AsmWriter.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp index cf9af3f7150..a3ab22c04c9 100644 --- a/llvm/lib/VMCore/AsmWriter.cpp +++ b/llvm/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 << " }"; |

