Index: llvm/include/llvm/Support/FileCheck.h =================================================================== --- llvm/include/llvm/Support/FileCheck.h +++ llvm/include/llvm/Support/FileCheck.h @@ -147,18 +147,18 @@ /// same mark in annotated input dumps or else printing of the annotation key /// will malfunction. enum MatchType { - // TODO: More members will appear with later patches in this series. MatchFinalAndExpected, //< the final match for an expected pattern MatchTypeFirst = MatchFinalAndExpected, MatchFinalButExcluded, //< the final match for an excluded pattern MatchFinalButIllegal, //< the final but illegal match for an expected pattern MatchDiscard, //< a discarded match for an expected pattern + MatchNoneAndExcluded, //< no match for an excluded pattern MatchNoneButExpected, //< no match for an expected pattern MatchFuzzy, //< a fuzzy match (because no perfect match) MatchTypeCount, } MatchTy; - /// The match range if MatchTy is not MatchNoneButExpected, or the search - /// range otherwise. + /// The match range if MatchTy is not MatchNoneAndExcluded or + /// MatchNoneButExpected, or the search range otherwise. unsigned InputStartLine, InputStartCol, InputEndLine, InputEndCol; FileCheckDiag(const SourceMgr &SM, const Check::FileCheckType &CheckTy, SMLoc CheckLoc, MatchType MatchTy, SMRange InputRange); Index: llvm/lib/Support/FileCheck.cpp =================================================================== --- llvm/lib/Support/FileCheck.cpp +++ llvm/lib/Support/FileCheck.cpp @@ -417,9 +417,7 @@ SMLoc Start = SMLoc::getFromPointer(Buffer.data() + Pos); SMLoc End = SMLoc::getFromPointer(Buffer.data() + Pos + Len); SMRange Range(Start, End); - // TODO: The second condition will disappear when we extend this to handle - // more match types. - if (Diags && MatchTy != FileCheckDiag::MatchTypeCount) { + if (Diags) { if (AdjustPrevDiag) Diags->rbegin()->MatchTy = MatchTy; else @@ -939,12 +937,13 @@ Buffer = Buffer.substr(Buffer.find_first_not_of(" \t\n\r")); SMRange SearchRange = ProcessMatchResult( ExpectedMatch ? FileCheckDiag::MatchNoneButExpected - : FileCheckDiag::MatchTypeCount, + : FileCheckDiag::MatchNoneAndExcluded, SM, Loc, Pat.getCheckTy(), Buffer, 0, Buffer.size(), Diags); SM.PrintMessage(SearchRange.Start, SourceMgr::DK_Note, "scanning from here"); // Allow the pattern to print additional information if desired. Pat.PrintVariableUses(SM, Buffer, VariableTable); + if (ExpectedMatch) Pat.PrintFuzzyMatch(SM, Buffer, VariableTable, Diags); } @@ -1133,7 +1132,7 @@ if (Pos == StringRef::npos) { PrintNoMatch(false, SM, Prefix, Pat->getLoc(), *Pat, Buffer, - VariableTable, Req.VerboseVerbose, nullptr); + VariableTable, Req.VerboseVerbose, Diags); continue; } Index: llvm/test/FileCheck/dump-input-annotations.txt =================================================================== --- llvm/test/FileCheck/dump-input-annotations.txt +++ llvm/test/FileCheck/dump-input-annotations.txt @@ -218,7 +218,7 @@ ; EMP2-NOT: {{.}} ;-------------------------------------------------- -; CHECK-NOT (also: EOF pattern) +; CHECK-NOT (also: EOF pattern, and multiline range that ends before EOL) ;-------------------------------------------------- ; No match (success) and illegal match. @@ -239,9 +239,12 @@ ; NOT: <<<<<< ; NOT-NEXT: 1: hello +; NOT-VV-NEXT: not:1 X~~~~ ; NOT-NEXT: 2: world +; NOT-VV-NEXT: not:1 ~~~~~ ; NOT-NEXT: not:2 !~~~~ ; NOT-NEXT: 3: again +; NOT-VV-NEXT: not:1 ~~~~~ ; NOT-VV-NEXT: 4: ; NOT-VV-NEXT: eof:2 ^ ; NOT-NEXT: >>>>>> @@ -260,9 +263,12 @@ ; NOT2: <<<<<< ; NOT2-NEXT: 1: hello +; NOT2-VV-NEXT: not:1 X~~~~ ; NOT2-NEXT: 2: world +; NOT2-VV-NEXT: not:1 ~~~~~ ; NOT2-NEXT: not:2 !~~~~ ; NOT2-NEXT: 3: again +; NOT2-VV-NEXT: not:1 ~~ ; NOT2-V-NEXT: check:3 ^~~ ; NOT2-NEXT: >>>>>> ; NOT2-NOT: {{.}} Index: llvm/utils/FileCheck/FileCheck.cpp =================================================================== --- llvm/utils/FileCheck/FileCheck.cpp +++ llvm/utils/FileCheck/FileCheck.cpp @@ -151,6 +151,11 @@ MatchTypeStyle::VerboseVerbose, "a discarded match for an expected pattern (e.g., " "CHECK-DAG)"); + case FileCheckDiag::MatchNoneAndExcluded: + return MatchTypeStyle('X', true, raw_ostream::GREEN, + MatchTypeStyle::VerboseVerbose, + "the search range for an unmatched excluded " + "pattern (e.g., CHECK-NOT)"); case FileCheckDiag::MatchNoneButExpected: return MatchTypeStyle('X', true, raw_ostream::RED, MatchTypeStyle::Quiet, "the search range for an unmatched expected "