mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
Remove SMLoc paired with CHECK-NOT patterns. Not functionality change.
Pattern has source location by itself. After adding a trivial method to retrieve it, it's unnecessary to pair a source location for CHECK-NOT patterns. One thing revised after this is the diagnostic info is more accurate by pointing to the start of the CHECK-NOT pattern instead of the end of the CHECK-NOT pattern. E.g. diagnostic message previously looks like <stdin>:1:1: error: CHECK-NOT: string occurred! test ^ test.txt:1:16: note: CHECK-NOT: pattern specified here CHECK-NOT: test ^ is changed to <stdin>:1:1: error: CHECK-NOT: string occurred! test ^ test.txt:1:12: note: CHECK-NOT: pattern specified here CHECK-NOT: test ^ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180578 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7f8300b8f3
commit
0fc7137f2f
7
test/FileCheck/check-not-diaginfo.txt
Normal file
7
test/FileCheck/check-not-diaginfo.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
; RUN: FileCheck -input-file %s %s 2>&1 | FileCheck -check-prefix DIAG %s
|
||||||
|
|
||||||
|
CHECK-NOT: test
|
||||||
|
|
||||||
|
DIAG: CHECK-NOT: pattern specified here
|
||||||
|
DIAG-NEXT: CHECK-NOT: test
|
||||||
|
DIAG-NEXT: {{^ \^}}
|
@ -85,6 +85,9 @@ public:
|
|||||||
|
|
||||||
Pattern(bool matchEOF = false) : MatchEOF(matchEOF) { }
|
Pattern(bool matchEOF = false) : MatchEOF(matchEOF) { }
|
||||||
|
|
||||||
|
/// getLoc - Return the location in source code.
|
||||||
|
SMLoc getLoc() const { return PatternLoc; }
|
||||||
|
|
||||||
/// ParsePattern - Parse the given string into the Pattern. SM provides the
|
/// ParsePattern - Parse the given string into the Pattern. SM provides the
|
||||||
/// SourceMgr used for error reports, and LineNumber is the line number in
|
/// SourceMgr used for error reports, and LineNumber is the line number in
|
||||||
/// the input file from which the pattern string was read.
|
/// the input file from which the pattern string was read.
|
||||||
@ -581,7 +584,7 @@ struct CheckString {
|
|||||||
/// NotStrings - These are all of the strings that are disallowed from
|
/// NotStrings - These are all of the strings that are disallowed from
|
||||||
/// occurring between this match string and the previous one (or start of
|
/// occurring between this match string and the previous one (or start of
|
||||||
/// file).
|
/// file).
|
||||||
std::vector<std::pair<SMLoc, Pattern> > NotStrings;
|
std::vector<Pattern> NotStrings;
|
||||||
|
|
||||||
CheckString(const Pattern &P, SMLoc L, bool isCheckNext)
|
CheckString(const Pattern &P, SMLoc L, bool isCheckNext)
|
||||||
: Pat(P), Loc(L), IsCheckNext(isCheckNext) {}
|
: Pat(P), Loc(L), IsCheckNext(isCheckNext) {}
|
||||||
@ -649,7 +652,7 @@ static bool ReadCheckFile(SourceMgr &SM,
|
|||||||
|
|
||||||
// Find all instances of CheckPrefix followed by : in the file.
|
// Find all instances of CheckPrefix followed by : in the file.
|
||||||
StringRef Buffer = F->getBuffer();
|
StringRef Buffer = F->getBuffer();
|
||||||
std::vector<std::pair<SMLoc, Pattern> > NotMatches;
|
std::vector<Pattern> NotMatches;
|
||||||
|
|
||||||
// LineNumber keeps track of the line on which CheckPrefix instances are
|
// LineNumber keeps track of the line on which CheckPrefix instances are
|
||||||
// found.
|
// found.
|
||||||
@ -716,8 +719,7 @@ static bool ReadCheckFile(SourceMgr &SM,
|
|||||||
|
|
||||||
// Handle CHECK-NOT.
|
// Handle CHECK-NOT.
|
||||||
if (IsCheckNot) {
|
if (IsCheckNot) {
|
||||||
NotMatches.push_back(std::make_pair(SMLoc::getFromPointer(Buffer.data()),
|
NotMatches.push_back(P);
|
||||||
P));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -877,14 +879,13 @@ int main(int argc, char **argv) {
|
|||||||
for (unsigned ChunkNo = 0, e = CheckStr.NotStrings.size();
|
for (unsigned ChunkNo = 0, e = CheckStr.NotStrings.size();
|
||||||
ChunkNo != e; ++ChunkNo) {
|
ChunkNo != e; ++ChunkNo) {
|
||||||
size_t MatchLen = 0;
|
size_t MatchLen = 0;
|
||||||
size_t Pos = CheckStr.NotStrings[ChunkNo].second.Match(SkippedRegion,
|
size_t Pos = CheckStr.NotStrings[ChunkNo].Match(SkippedRegion, MatchLen,
|
||||||
MatchLen,
|
VariableTable);
|
||||||
VariableTable);
|
|
||||||
if (Pos == StringRef::npos) continue;
|
if (Pos == StringRef::npos) continue;
|
||||||
|
|
||||||
SM.PrintMessage(SMLoc::getFromPointer(LastMatch+Pos), SourceMgr::DK_Error,
|
SM.PrintMessage(SMLoc::getFromPointer(LastMatch+Pos), SourceMgr::DK_Error,
|
||||||
CheckPrefix+"-NOT: string occurred!");
|
CheckPrefix+"-NOT: string occurred!");
|
||||||
SM.PrintMessage(CheckStr.NotStrings[ChunkNo].first, SourceMgr::DK_Note,
|
SM.PrintMessage(CheckStr.NotStrings[ChunkNo].getLoc(), SourceMgr::DK_Note,
|
||||||
CheckPrefix+"-NOT: pattern specified here");
|
CheckPrefix+"-NOT: pattern specified here");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user