diff options
author | Jim Laskey <jlaskey@mac.com> | 2006-02-25 12:27:03 +0000 |
---|---|---|
committer | Jim Laskey <jlaskey@mac.com> | 2006-02-25 12:27:03 +0000 |
commit | a3f332bdc3e8fd1ac78dd3dc868d871e9086c5fd (patch) | |
tree | d89e63f0c05e106a11c411316d193b5365e75272 | |
parent | 9394514eded0a07b2686b6cdb6fada73fe4a2621 (diff) |
Format large struct constants for readability.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26379 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index ec70454e0b..80085d015d 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -419,6 +419,7 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, bool PrintName, std::map<const Type *, std::string> &TypeTable, SlotMachine *Machine) { + 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)) { @@ -482,22 +483,30 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, } } else if (const ConstantStruct *CS = dyn_cast<ConstantStruct>(CV)) { Out << '{'; - if (CS->getNumOperands()) { - Out << ' '; + unsigned N = CS->getNumOperands(); + if (N) { + if (N > 2) { + Indent += " "; + Out << Indent; + } else { + Out << ' '; + } printTypeInt(Out, CS->getOperand(0)->getType(), TypeTable); WriteAsOperandInternal(Out, CS->getOperand(0), PrintName, TypeTable, Machine); - for (unsigned i = 1; i < CS->getNumOperands(); i++) { + 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() - 4); } - + Out << " }"; } else if (const ConstantPacked *CP = dyn_cast<ConstantPacked>(CV)) { const Type *ETy = CP->getType()->getElementType(); |