fix crash when printing diagnostics with tokens that span through more than one line

llvm-svn: 54365
This commit is contained in:
Nuno Lopes 2008-08-05 19:40:20 +00:00
parent 2c674f6dbb
commit d86aa9340d
2 changed files with 12 additions and 5 deletions

View File

@ -91,13 +91,16 @@ void TextDiagnosticPrinter::HighlightRange(const SourceRange &R,
}
// Pick the last non-whitespace column.
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] = '~';
}

View File

@ -0,0 +1,4 @@
// RUN: clang -fsyntax-only %s
unsigned char *foo = "texto\
que continua\
e continua";