When we truncate a source line to fit it within the terminal width,
show an ellipsis where we have removed text. An example:

/Users/dgregor/Projects/llvm/tools/clang/test/Misc/message-length.c:18:120:
warning: 
      comparison of distinct pointer types ('int *' and 'float *')
  ...a_func_to_call(ip == FloatPointer, ip[ALongIndexName], ...
                    ~~ ^  ~~~~~~~~~~~~



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70655 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp
index b8c10b5..bcf30a5 100644
--- a/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -143,7 +143,7 @@
   if (CaretEnd < Columns)
     CaretStart = 0;
 
-  unsigned TargetColumns = Columns - 4; // Give us a little extra room.
+  unsigned TargetColumns = Columns - 8; // Give us extra room for the ellipses.
   unsigned SourceLength = SourceLine.size();
   bool StartIsFixed = false;
   while (CaretEnd - CaretStart < TargetColumns) {
@@ -231,16 +231,17 @@
   // [CaretStart, CaretEnd) is the slice we want. Update the various
   // output lines to show only this slice, with two-space padding
   // before the lines so that it looks nicer.
-  SourceLine.erase(CaretEnd, std::string::npos);
+  if (CaretEnd < SourceLine.size())
+    SourceLine.replace(CaretEnd, std::string::npos, "...");
   CaretLine.erase(CaretEnd, std::string::npos);
   if (FixItInsertionLine.size() > CaretEnd)
     FixItInsertionLine.erase(CaretEnd, std::string::npos);
   
   if (CaretStart > 2) {
-    SourceLine.replace(0, CaretStart, "  ");
-    CaretLine.replace(0, CaretStart, "  ");
+    SourceLine.replace(0, CaretStart, "  ...");
+    CaretLine.replace(0, CaretStart, "     ");
     if (FixItInsertionLine.size() >= CaretStart)
-      FixItInsertionLine.replace(0, CaretStart, "  ");
+      FixItInsertionLine.replace(0, CaretStart, "     ");
   }
 }