From 40d8e971a32a23856ce1ab0106ae75cf4b92ca9d Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 26 Apr 2012 21:39:46 +0000 Subject: [PATCH] Revert r154981, because it caused PR12674. Add a test for PR12674. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155666 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/TextDiagnostic.cpp | 12 ++++-------- test/Misc/diag-trailing-null-bytes.cpp | 10 ++++++++++ test/Misc/wnull-character.cpp | Bin 143 -> 0 bytes 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 test/Misc/diag-trailing-null-bytes.cpp delete mode 100644 test/Misc/wnull-character.cpp diff --git a/lib/Frontend/TextDiagnostic.cpp b/lib/Frontend/TextDiagnostic.cpp index 65fb1ae13f..b86ecf823e 100644 --- a/lib/Frontend/TextDiagnostic.cpp +++ b/lib/Frontend/TextDiagnostic.cpp @@ -182,7 +182,7 @@ void expandTabs(std::string &SourceLine, unsigned TabStop) { /// (\u3042 is represented in UTF-8 by three bytes and takes two columns to /// display) void byteToColumn(StringRef SourceLine, unsigned TabStop, - SmallVectorImpl &out) { + SmallVectorImpl &out) { out.clear(); if (SourceLine.empty()) { @@ -840,13 +840,10 @@ void TextDiagnostic::emitSnippetAndCaret( // Get information about the buffer it points into. bool Invalid = false; - StringRef BufData = SM.getBufferData(FID, &Invalid); + const char *BufStart = SM.getBufferData(FID, &Invalid).data(); if (Invalid) return; - const char *BufStart = BufData.data(); - const char *BufEnd = BufStart + BufData.size(); - unsigned LineNo = SM.getLineNumber(FID, FileOffset); unsigned ColNo = SM.getColumnNumber(FID, FileOffset); unsigned CaretEndColNo @@ -860,7 +857,7 @@ void TextDiagnostic::emitSnippetAndCaret( // Compute the line end. Scan forward from the error position to the end of // the line. const char *LineEnd = TokPtr; - while (*LineEnd != '\n' && *LineEnd != '\r' && LineEnd!=BufEnd) + while (*LineEnd != '\n' && *LineEnd != '\r' && *LineEnd != '\0') ++LineEnd; // FIXME: This shouldn't be necessary, but the CaretEndColNo can extend past @@ -952,8 +949,7 @@ void TextDiagnostic::emitSnippet(StringRef line) = printableTextForNextCharacter(line, &i, DiagOpts.TabStop); bool was_printable = res.second; - if (DiagOpts.ShowColors - && was_printable==print_reversed) { + if (DiagOpts.ShowColors && was_printable == print_reversed) { if (print_reversed) OS.reverseColor(); OS << to_print; diff --git a/test/Misc/diag-trailing-null-bytes.cpp b/test/Misc/diag-trailing-null-bytes.cpp new file mode 100644 index 0000000000..91b159ca25 --- /dev/null +++ b/test/Misc/diag-trailing-null-bytes.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s +// CHECK: {{ERR_DNS_SERVER_REQUIRES_TCP$}} + +// http://llvm.org/PR12674 +#define NET_ERROR(label, value) ERR_ ## label = value, + +NET_ERROR(DNS_SERVER_REQUIRES_TCP, -801) + +#undef NET_ERROR + diff --git a/test/Misc/wnull-character.cpp b/test/Misc/wnull-character.cpp deleted file mode 100644 index a618da272a13f98e9ebb3100bed68e19daab51cb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 143 zcmWm6K?{N~7>DuB`xJi!I}~Ht(aeh!LD3e4b4HNqC>2v<^D1}>n&5@GR z{@D;^kdHWe)?e9sH$vY1$2m!z4w~2mq!HV4nc;_{b*AbJy&xk8ODu=ZvWag^W@17q jRHs9A&T&a}QLi^sWt)g$o;3{WePpZ#>}RlOlb!ej-GwXN -- 2.40.0