llvm.org GIT mirror llvm / 7df6641
FileCheck: fix a bug with multiple --check-prefix options. Summary: This fixes a subtle bug in new FileCheck feature added in r194343. When we search for the first satisfying check-prefix, we should actually return the first encounter of some check-prefix as a substring, even if it's not a part of valid check-line. Otherwise "FileCheck --check-prefix=FOO --check-prefix=BAR" with check file: FOO not a vaild check-line FOO: foo BAR: bar incorrectly accepted file: fog bar as it skipped the first two encounters of FOO, matching only BAR: line. Reviewers: arsenm, dsanders Reviewed By: dsanders CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2166 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194565 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Samsonov 5 years ago
2 changed file(s) with 13 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: not FileCheck -input-file %s %s -check-prefix=FOO -check-prefix=BAR 2>&1 | FileCheck %s
1
2 BAR
3 bar
4 foo
5 ; BAR: ba{{z}}
6 ; FOO: fo{{o}}
7
8 ; CHECK: {{error: expected string not found in input}}
9 ; CHECK-NEXT: {{B}}AR: ba{{[{][{]z[}][}]}}
793793 continue;
794794
795795 Check::CheckType Ty = FindCheckType(Rest, Prefix);
796 if (Ty == Check::CheckNone)
797 continue;
798796
799797 FirstLoc = PrefixLoc;
800798 FirstTy = Ty;
801 FirstPrefix = Prefix;
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;
802802 }
803803
804804 if (FirstPrefix.empty()) {