llvm.org GIT mirror llvm / e4e260e
FileCheck: fix a bug with multiple --check-prefix options. Similar to r194565 Summary: Directives are being ignored, when they occur between a partial-word false match and any match on another prefix. For example, with FOO and BAR prefixes: _FOO FOO: foo BAR: bar FileCheck incorrectly matches: fog bar This happens because FOO falsely matched as a partial word at '_FOO' and was ignored while BAR matched at 'BAR:'. The match of BAR is incorrectly returned as the 'first match' causing the FOO directive to be discarded. Fixed this the same way as r194565 (D2166) did for a similar test case. The partial-word false match should be counted as a match for the purposes of finding the first match of a prefix, but should be returned as a false match using CheckTy::CheckNone so that it isn't treated as a directive. Fixes PR17995 Reviewers: samsonov, arsenm Reviewed By: samsonov CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2228 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195248 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Sanders 5 years ago
2 changed file(s) with 13 addition(s) and 2 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 fog
3 bar
4 ; _FOO not a valid check-line
5 ; FOO: fo{{o}}
6 ; BAR: ba{{r}}
7
8 ; CHECK: {{error: expected string not found in input}}
9 ; CHECK-NEXT: {{F}}OO: fo{{[{][{]o[}][}]}}
794794 // it. This should also prevent matching the wrong prefix when one is a
795795 // substring of another.
796796 if (PrefixLoc != 0 && IsPartOfWord(Buffer[PrefixLoc - 1]))
797 continue;
797 FirstTy = Check::CheckNone;
798 else
799 FirstTy = FindCheckType(Rest, Prefix);
798800
799801 FirstLoc = PrefixLoc;
800 FirstTy = FindCheckType(Rest, Prefix);
801802 FirstPrefix = Prefix;
802803 }
803804