about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
authorPeter Collingbourne <pcc@google.com>2014-04-03 23:53:01 -0700
committerPeter Collingbourne <pcc@google.com>2014-04-04 11:41:11 -0700
commite3b58660760830e774eff283f957ac5abb8a9b47 (patch)
tree814de114097bf214bcb9e7683481c9fd2aafd9d2 /lib
parentb3d9f1469b66e5409b1b6e8cbaca91d16e802761 (diff)
downloadklee-e3b58660760830e774eff283f957ac5abb8a9b47.tar.gz
Add the ability to control whether the pretty printer uses line breaks
This change makes it possible to more reliably write unit tests which check
that an expression is equivalent to an expected pretty printed string.
Diffstat (limited to 'lib')
-rw-r--r--lib/Expr/ExprPPrinter.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Expr/ExprPPrinter.cpp b/lib/Expr/ExprPPrinter.cpp
index ac1d1d01..d58358b5 100644
--- a/lib/Expr/ExprPPrinter.cpp
+++ b/lib/Expr/ExprPPrinter.cpp
@@ -51,6 +51,7 @@ private:
   unsigned counter;
   unsigned updateCounter;
   bool hasScan;
+  bool forceNoLineBreaks;
   std::string newline;
 
   /// shouldPrintWidth - Predicate for whether this expression should
@@ -307,10 +308,15 @@ public:
     newline = _newline;
   }
 
+  void setForceNoLineBreaks(bool _forceNoLineBreaks) {
+    forceNoLineBreaks = _forceNoLineBreaks;
+  }
+
   void reset() {
     counter = 0;
     updateCounter = 0;
     hasScan = false;
+    forceNoLineBreaks = false;
     bindings.clear();
     updateBindings.clear();
     couldPrint.clear();
@@ -412,7 +418,7 @@ public:
   /* Public utility functions */
 
   void printSeparator(PrintContext &PC, bool simple, unsigned indent) {
-    if (simple) {
+    if (simple || forceNoLineBreaks) {
       PC << ' ';
     } else {
       PC.breakLine(indent);