llvm.org GIT mirror llvm / 0fc7137
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 Michael Liao 7 years ago
2 changed file(s) with 16 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: FileCheck -input-file %s %s 2>&1 | FileCheck -check-prefix DIAG %s
1
2 CHECK-NOT: test
3
4 DIAG: CHECK-NOT: pattern specified here
5 DIAG-NEXT: CHECK-NOT: test
6 DIAG-NEXT: {{^ \^}}
8383 public:
8484
8585 Pattern(bool matchEOF = false) : MatchEOF(matchEOF) { }
86
87 /// getLoc - Return the location in source code.
88 SMLoc getLoc() const { return PatternLoc; }
8689
8790 /// ParsePattern - Parse the given string into the Pattern. SM provides the
8891 /// SourceMgr used for error reports, and LineNumber is the line number in
580583 /// NotStrings - These are all of the strings that are disallowed from
581584 /// occurring between this match string and the previous one (or start of
582585 /// file).
583 std::vector<std::pair > NotStrings;
586 std::vector<Pattern> NotStrings;
584587
585588 CheckString(const Pattern &P, SMLoc L, bool isCheckNext)
586589 : Pat(P), Loc(L), IsCheckNext(isCheckNext) {}
648651
649652 // Find all instances of CheckPrefix followed by : in the file.
650653 StringRef Buffer = F->getBuffer();
651 std::vector<std::pair > NotMatches;
654 std::vector<Pattern> NotMatches;
652655
653656 // LineNumber keeps track of the line on which CheckPrefix instances are
654657 // found.
715718
716719 // Handle CHECK-NOT.
717720 if (IsCheckNot) {
718 NotMatches.push_back(std::make_pair(SMLoc::getFromPointer(Buffer.data()),
719 P));
721 NotMatches.push_back(P);
720722 continue;
721723 }
722724
876878 for (unsigned ChunkNo = 0, e = CheckStr.NotStrings.size();
877879 ChunkNo != e; ++ChunkNo) {
878880 size_t MatchLen = 0;
879 size_t Pos = CheckStr.NotStrings[ChunkNo].second.Match(SkippedRegion,
880 MatchLen,
881 VariableTable);
881 size_t Pos = CheckStr.NotStrings[ChunkNo].Match(SkippedRegion, MatchLen,
882 VariableTable);
882883 if (Pos == StringRef::npos) continue;
883884
884885 SM.PrintMessage(SMLoc::getFromPointer(LastMatch+Pos), SourceMgr::DK_Error,
885886 CheckPrefix+"-NOT: string occurred!");
886 SM.PrintMessage(CheckStr.NotStrings[ChunkNo].first, SourceMgr::DK_Note,
887 SM.PrintMessage(CheckStr.NotStrings[ChunkNo].getLoc(), SourceMgr::DK_Note,
887888 CheckPrefix+"-NOT: pattern specified here");
888889 return 1;
889890 }