diff options
author | Seth Cantrell <seth.cantrell@gmail.com> | 2012-11-03 23:56:43 +0000 |
---|---|---|
committer | Seth Cantrell <seth.cantrell@gmail.com> | 2012-11-03 23:56:43 +0000 |
commit | 40f87b1d53acff6b2c885062f5b59c327d8295f7 (patch) | |
tree | 5b4f7ee367ce5132cd4a2b0f9fdfc61c13520576 /clang | |
parent | 2954ceab8254fe9809257d386f4715ac2d03bd13 (diff) | |
download | bcm5719-llvm-40f87b1d53acff6b2c885062f5b59c327d8295f7.tar.gz bcm5719-llvm-40f87b1d53acff6b2c885062f5b59c327d8295f7.zip |
only truncate source lines in text diagnostics when
the ellipsis is shorter than the text it replaces
llvm-svn: 167364
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Frontend/TextDiagnostic.cpp | 4 | ||||
-rw-r--r-- | clang/test/Misc/unnecessary-elipses.cpp | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp index ca55197f90e..35dabad6065 100644 --- a/clang/lib/Frontend/TextDiagnostic.cpp +++ b/clang/lib/Frontend/TextDiagnostic.cpp @@ -494,7 +494,7 @@ static void selectInterestingSourceRegion(std::string &SourceLine, // 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 @@ static void selectInterestingSourceRegion(std::string &SourceLine, 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()) diff --git a/clang/test/Misc/unnecessary-elipses.cpp b/clang/test/Misc/unnecessary-elipses.cpp new file mode 100644 index 00000000000..2ee725869b5 --- /dev/null +++ b/clang/test/Misc/unnecessary-elipses.cpp @@ -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 |