llvm.org GIT mirror llvm / 0ab53c7
FileCheck: fix matching of one check-prefix is a prefix of another Summary: Fix a case when "FileCheck --check-prefix=CHECK --check-prefix=CHECKER" would silently ignore check-lines of the form: CHECKER: foo Reviewers: dsanders Reviewed By: dsanders CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2168 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194577 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Samsonov 5 years ago
2 changed file(s) with 20 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
0 // RUN: FileCheck -check-prefix=CHECKER -check-prefix=CHECK -input-file %s %s
1 // RUN: FileCheck -check-prefix=CHECK -check-prefix=CHECKER -input-file %s %s
2
3 foo
4 ; CHECKER: fo{{o}}
784784 // We only want to find the first match to avoid skipping some.
785785 if (PrefixLoc > FirstLoc)
786786 continue;
787 // If one matching check-prefix is a prefix of another, choose the
788 // longer one.
789 if (PrefixLoc == FirstLoc && Prefix.size() < FirstPrefix.size())
790 continue;
787791
788792 StringRef Rest = Buffer.drop_front(PrefixLoc);
789793 // Make sure we have actually found the prefix, and not a word containing
792796 if (PrefixLoc != 0 && IsPartOfWord(Buffer[PrefixLoc - 1]))
793797 continue;
794798
795 Check::CheckType Ty = FindCheckType(Rest, Prefix);
796
797799 FirstLoc = PrefixLoc;
798 FirstTy = Ty;
799 // We've found the first matching check prefix. If it is invalid, we should
800 // continue the search after it.
801 FirstPrefix = (Ty == Check::CheckNone) ? "" : Prefix;
802 }
803
804 if (FirstPrefix.empty()) {
800 FirstTy = FindCheckType(Rest, Prefix);
801 FirstPrefix = Prefix;
802 }
803
804 // If the first prefix is invalid, we should continue the search after it.
805 if (FirstTy == Check::CheckNone) {
805806 CheckLoc = SearchLoc;
806 } else {
807 CheckTy = FirstTy;
808 CheckLoc = FirstLoc;
809 }
810
807 return "";
808 }
809
810 CheckTy = FirstTy;
811 CheckLoc = FirstLoc;
811812 return FirstPrefix;
812813 }
813814