[cfe-commits] r54365 - in /cfe/trunk: Driver/TextDiagnosticPrinter.cpp test/Sema/text-diag.c
Nuno Lopes
nunoplopes at sapo.pt
Tue Aug 5 12:40:21 PDT 2008
Author: nlopes
Date: Tue Aug 5 14:40:20 2008
New Revision: 54365
URL: http://llvm.org/viewvc/llvm-project?rev=54365&view=rev
Log:
fix crash when printing diagnostics with tokens that span through more than one line
Added:
cfe/trunk/test/Sema/text-diag.c
Modified:
cfe/trunk/Driver/TextDiagnosticPrinter.cpp
Modified: cfe/trunk/Driver/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnosticPrinter.cpp?rev=54365&r1=54364&r2=54365&view=diff
==============================================================================
--- cfe/trunk/Driver/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/Driver/TextDiagnosticPrinter.cpp Tue Aug 5 14:40:20 2008
@@ -49,7 +49,7 @@
SourceManager& SourceMgr,
unsigned LineNo, unsigned FileID,
std::string &CaratLine,
- const std::string &SourceLine) {
+ const std::string &SourceLine) {
assert(CaratLine.size() == SourceLine.size() &&
"Expect a correspondence between source and carat line!");
if (!R.isValid()) return;
@@ -91,13 +91,16 @@
}
// Pick the last non-whitespace column.
- while (EndColNo-1 &&
- (SourceLine[EndColNo-1] == ' ' || SourceLine[EndColNo-1] == '\t'))
- --EndColNo;
+ if (EndColNo <= SourceLine.size())
+ while (EndColNo-1 &&
+ (SourceLine[EndColNo-1] == ' ' || SourceLine[EndColNo-1] == '\t'))
+ --EndColNo;
+ else
+ EndColNo = SourceLine.size();
// Fill the range with ~'s.
assert(StartColNo <= EndColNo && "Invalid range!");
- for (unsigned i = StartColNo; i != EndColNo; ++i)
+ for (unsigned i = StartColNo; i < EndColNo; ++i)
CaratLine[i] = '~';
}
Added: cfe/trunk/test/Sema/text-diag.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/text-diag.c?rev=54365&view=auto
==============================================================================
--- cfe/trunk/test/Sema/text-diag.c (added)
+++ cfe/trunk/test/Sema/text-diag.c Tue Aug 5 14:40:20 2008
@@ -0,0 +1,4 @@
+// RUN: clang -fsyntax-only %s
+unsigned char *foo = "texto\
+que continua\
+e continua";
More information about the cfe-commits
mailing list