[cfe-commits] r167364 - in /cfe/trunk: lib/Frontend/TextDiagnostic.cpp test/Misc/unnecessary-elipses.cpp
Seth Cantrell
seth.cantrell at gmail.com
Sat Nov 3 16:56:43 PDT 2012
Author: socantre
Date: Sat Nov 3 18:56:43 2012
New Revision: 167364
URL: http://llvm.org/viewvc/llvm-project?rev=167364&view=rev
Log:
only truncate source lines in text diagnostics when
the ellipsis is shorter than the text it replaces
Added:
cfe/trunk/test/Misc/unnecessary-elipses.cpp
Modified:
cfe/trunk/lib/Frontend/TextDiagnostic.cpp
Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=167364&r1=167363&r2=167364&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Sat Nov 3 18:56:43 2012
@@ -494,7 +494,7 @@
// The line needs some trunctiona, and we'd prefer to keep the front
// if possible, so remove the back
- if (BackColumnsRemoved)
+ if (BackColumnsRemoved > strlen(back_ellipse))
SourceLine.replace(SourceEnd, std::string::npos, back_ellipse);
// If that's enough then we're done
@@ -502,7 +502,7 @@
return;
// Otherwise remove the front as well
- if (FrontColumnsRemoved) {
+ if (FrontColumnsRemoved > strlen(front_ellipse)) {
SourceLine.replace(0, SourceStart, front_ellipse);
CaretLine.replace(0, CaretStart, front_space);
if (!FixItInsertionLine.empty())
Added: cfe/trunk/test/Misc/unnecessary-elipses.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/unnecessary-elipses.cpp?rev=167364&view=auto
==============================================================================
--- cfe/trunk/test/Misc/unnecessary-elipses.cpp (added)
+++ cfe/trunk/test/Misc/unnecessary-elipses.cpp Sat Nov 3 18:56:43 2012
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -fmessage-length 80 %s 2>&1 | FileCheck -strict-whitespace %s
+
+int main() {
+ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+// CHECK: {{^ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";}}
+
+ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+// CHECK: {{^ ..."xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";}}
+
+"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ;
+// CHECK: {{^"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"...}}
+
+ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ;
+// CHECK: {{^ ..."xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"...}}
+}
\ No newline at end of file
More information about the cfe-commits
mailing list