llvm.org GIT mirror llvm / 9583b2c
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205725 91177308-0d34-0410-b5e6-96231b3b80d8 Richard Smith 6 years ago
1 changed file(s) with 9 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
964964
965965 /// CountNumNewlinesBetween - Count the number of newlines in the specified
966966 /// range.
967 static unsigned CountNumNewlinesBetween(StringRef Range) {
967 static unsigned CountNumNewlinesBetween(StringRef Range,
968 const char *&FirstNewLine) {
968969 unsigned NumNewLines = 0;
969970 while (1) {
970971 // Scan for newline.
979980 (Range[0] != Range[1]))
980981 Range = Range.substr(1);
981982 Range = Range.substr(1);
983
984 if (NumNewLines == 1)
985 FirstNewLine = Range.begin();
982986 }
983987 }
984988
10381042 SMLoc::getFromPointer(Buffer.data())))->getBufferStart() &&
10391043 "CHECK-NEXT can't be the first check in a file");
10401044
1041 unsigned NumNewLines = CountNumNewlinesBetween(Buffer);
1045 const char *FirstNewLine = 0;
1046 unsigned NumNewLines = CountNumNewlinesBetween(Buffer, FirstNewLine);
10421047
10431048 if (NumNewLines == 0) {
10441049 SM.PrintMessage(Loc, SourceMgr::DK_Error, Prefix +
10571062 SourceMgr::DK_Note, "'next' match was here");
10581063 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), SourceMgr::DK_Note,
10591064 "previous match ended here");
1065 SM.PrintMessage(SMLoc::getFromPointer(FirstNewLine), SourceMgr::DK_Note,
1066 "non-matching line after previous match is here");
10601067 return true;
10611068 }
10621069