[PATCH] FileCheck: fix a bug with multiple --check-prefix options.
Alexey Samsonov
samsonov at google.com
Wed Nov 13 02:30:49 PST 2013
Hi arsenm, dsanders,
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.
http://llvm-reviews.chandlerc.com/D2166
Files:
test/FileCheck/check-multiple-prefixes-nomatch.txt
utils/FileCheck/FileCheck.cpp
Index: test/FileCheck/check-multiple-prefixes-nomatch.txt
===================================================================
--- /dev/null
+++ test/FileCheck/check-multiple-prefixes-nomatch.txt
@@ -0,0 +1,10 @@
+; RUN: not FileCheck -input-file %s %s -check-prefix=FOO -check-prefix=BAR 2>&1 | FileCheck %s
+
+BAR
+bar
+foo
+; BAR: ba{{z}}
+; FOO: foo
+
+; CHECK: error: expected string not found in input
+; CHECK-NEXT: {{B}}AR: ba{{[{][{]z[}][}]}}
Index: utils/FileCheck/FileCheck.cpp
===================================================================
--- utils/FileCheck/FileCheck.cpp
+++ utils/FileCheck/FileCheck.cpp
@@ -794,12 +794,12 @@
continue;
Check::CheckType Ty = FindCheckType(Rest, Prefix);
- if (Ty == Check::CheckNone)
- continue;
FirstLoc = PrefixLoc;
FirstTy = Ty;
- FirstPrefix = Prefix;
+ // We've found the first matching check prefix. If it is invalid, we should
+ // continue the search after it.
+ FirstPrefix = (Ty == Check::CheckNone) ? "" : Prefix;
}
if (FirstPrefix.empty()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2166.1.patch
Type: text/x-patch
Size: 1061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131113/369b5b9a/attachment.bin>
More information about the llvm-commits
mailing list