[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp

Jim Laskey jlaskey at apple.com
Sat Feb 25 04:27:16 PST 2006



Changes in directory llvm/lib/VMCore:

AsmWriter.cpp updated: 1.191 -> 1.192
---
Log message:

Format large struct constants for readability.


---
Diffs of the changes:  (+13 -4)

 AsmWriter.cpp |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)


Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.191 llvm/lib/VMCore/AsmWriter.cpp:1.192
--- llvm/lib/VMCore/AsmWriter.cpp:1.191	Wed Jan 25 16:26:05 2006
+++ llvm/lib/VMCore/AsmWriter.cpp	Sat Feb 25 06:27:03 2006
@@ -419,6 +419,7 @@
                              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 @@
     }
   } 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();






More information about the llvm-commits mailing list