[llvm] r195248 - FileCheck: fix a bug with multiple --check-prefix options. Similar to r194565

Daniel Sanders daniel.sanders at imgtec.com
Wed Nov 20 05:25:05 PST 2013


Author: dsanders
Date: Wed Nov 20 07:25:05 2013
New Revision: 195248

URL: http://llvm.org/viewvc/llvm-project?rev=195248&view=rev
Log:
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

Added:
    llvm/trunk/test/FileCheck/check-multiple-prefixes-nomatch-2.txt
Modified:
    llvm/trunk/utils/FileCheck/FileCheck.cpp

Added: llvm/trunk/test/FileCheck/check-multiple-prefixes-nomatch-2.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FileCheck/check-multiple-prefixes-nomatch-2.txt?rev=195248&view=auto
==============================================================================
--- llvm/trunk/test/FileCheck/check-multiple-prefixes-nomatch-2.txt (added)
+++ llvm/trunk/test/FileCheck/check-multiple-prefixes-nomatch-2.txt Wed Nov 20 07:25:05 2013
@@ -0,0 +1,10 @@
+; RUN: not FileCheck -input-file %s %s -check-prefix=FOO -check-prefix=BAR 2>&1 | FileCheck %s
+
+fog
+bar
+; _FOO not a valid check-line
+; FOO: fo{{o}}
+; BAR: ba{{r}}
+
+; CHECK: {{error: expected string not found in input}}
+; CHECK-NEXT: {{F}}OO: fo{{[{][{]o[}][}]}}

Modified: llvm/trunk/utils/FileCheck/FileCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/FileCheck/FileCheck.cpp?rev=195248&r1=195247&r2=195248&view=diff
==============================================================================
--- llvm/trunk/utils/FileCheck/FileCheck.cpp (original)
+++ llvm/trunk/utils/FileCheck/FileCheck.cpp Wed Nov 20 07:25:05 2013
@@ -795,10 +795,11 @@ static StringRef FindFirstCandidateMatch
     // it. This should also prevent matching the wrong prefix when one is a
     // substring of another.
     if (PrefixLoc != 0 && IsPartOfWord(Buffer[PrefixLoc - 1]))
-      continue;
+      FirstTy = Check::CheckNone;
+    else
+      FirstTy = FindCheckType(Rest, Prefix);
 
     FirstLoc = PrefixLoc;
-    FirstTy = FindCheckType(Rest, Prefix);
     FirstPrefix = Prefix;
   }
 





More information about the llvm-commits mailing list