summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/FileCheck/check-multiple-prefixes-nomatch.txt10
-rw-r--r--utils/FileCheck/FileCheck.cpp6
2 files changed, 13 insertions, 3 deletions
diff --git a/test/FileCheck/check-multiple-prefixes-nomatch.txt b/test/FileCheck/check-multiple-prefixes-nomatch.txt
new file mode 100644
index 0000000000..9d3835985f
--- /dev/null
+++ b/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: fo{{o}}
+
+; CHECK: {{error: expected string not found in input}}
+; CHECK-NEXT: {{B}}AR: ba{{[{][{]z[}][}]}}
diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp
index c9eb8a650c..d5f760246d 100644
--- a/utils/FileCheck/FileCheck.cpp
+++ b/utils/FileCheck/FileCheck.cpp
@@ -794,12 +794,12 @@ static StringRef FindFirstCandidateMatch(StringRef &Buffer,
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()) {