mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
When a CHECK-NEXT fails because there was no match on the next line, include
the non-matching next line in the diagnostic to make the problem more obvious. llvm-svn: 205725
This commit is contained in:
parent
518774e8c9
commit
ddbef6c19b
@ -965,7 +965,8 @@ static void PrintCheckFailed(const SourceMgr &SM, const CheckString &CheckStr,
|
|||||||
|
|
||||||
/// CountNumNewlinesBetween - Count the number of newlines in the specified
|
/// CountNumNewlinesBetween - Count the number of newlines in the specified
|
||||||
/// range.
|
/// range.
|
||||||
static unsigned CountNumNewlinesBetween(StringRef Range) {
|
static unsigned CountNumNewlinesBetween(StringRef Range,
|
||||||
|
const char *&FirstNewLine) {
|
||||||
unsigned NumNewLines = 0;
|
unsigned NumNewLines = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
// Scan for newline.
|
// Scan for newline.
|
||||||
@ -980,6 +981,9 @@ static unsigned CountNumNewlinesBetween(StringRef Range) {
|
|||||||
(Range[0] != Range[1]))
|
(Range[0] != Range[1]))
|
||||||
Range = Range.substr(1);
|
Range = Range.substr(1);
|
||||||
Range = Range.substr(1);
|
Range = Range.substr(1);
|
||||||
|
|
||||||
|
if (NumNewLines == 1)
|
||||||
|
FirstNewLine = Range.begin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1039,7 +1043,8 @@ bool CheckString::CheckNext(const SourceMgr &SM, StringRef Buffer) const {
|
|||||||
SMLoc::getFromPointer(Buffer.data())))->getBufferStart() &&
|
SMLoc::getFromPointer(Buffer.data())))->getBufferStart() &&
|
||||||
"CHECK-NEXT can't be the first check in a file");
|
"CHECK-NEXT can't be the first check in a file");
|
||||||
|
|
||||||
unsigned NumNewLines = CountNumNewlinesBetween(Buffer);
|
const char *FirstNewLine = 0;
|
||||||
|
unsigned NumNewLines = CountNumNewlinesBetween(Buffer, FirstNewLine);
|
||||||
|
|
||||||
if (NumNewLines == 0) {
|
if (NumNewLines == 0) {
|
||||||
SM.PrintMessage(Loc, SourceMgr::DK_Error, Prefix +
|
SM.PrintMessage(Loc, SourceMgr::DK_Error, Prefix +
|
||||||
@ -1058,6 +1063,8 @@ bool CheckString::CheckNext(const SourceMgr &SM, StringRef Buffer) const {
|
|||||||
SourceMgr::DK_Note, "'next' match was here");
|
SourceMgr::DK_Note, "'next' match was here");
|
||||||
SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), SourceMgr::DK_Note,
|
SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), SourceMgr::DK_Note,
|
||||||
"previous match ended here");
|
"previous match ended here");
|
||||||
|
SM.PrintMessage(SMLoc::getFromPointer(FirstNewLine), SourceMgr::DK_Note,
|
||||||
|
"non-matching line after previous match is here");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user