diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-11-13 14:12:52 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-11-13 14:12:52 +0000 |
commit | a7181a1b351c93fe39fe925301af9808332f531f (patch) | |
tree | 01c86aa929ab70480edd16f5066f349c74dc0e2d /llvm/utils/FileCheck/FileCheck.cpp | |
parent | 393e3088a1fab513490cbb759a312a0ee94a5be9 (diff) | |
download | llvm-a7181a1b351c93fe39fe925301af9808332f531f.zip llvm-a7181a1b351c93fe39fe925301af9808332f531f.tar.gz llvm-a7181a1b351c93fe39fe925301af9808332f531f.tar.bz2 |
FileCheck: fix matching of one check-prefix is a prefix of another
Summary:
Fix a case when "FileCheck --check-prefix=CHECK --check-prefix=CHECKER"
would silently ignore check-lines of the form:
CHECKER: foo
Reviewers: dsanders
Reviewed By: dsanders
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2168
llvm-svn: 194577
Diffstat (limited to 'llvm/utils/FileCheck/FileCheck.cpp')
-rw-r--r-- | llvm/utils/FileCheck/FileCheck.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp index d5f7602..f2510d7 100644 --- a/llvm/utils/FileCheck/FileCheck.cpp +++ b/llvm/utils/FileCheck/FileCheck.cpp @@ -785,6 +785,10 @@ static StringRef FindFirstCandidateMatch(StringRef &Buffer, // We only want to find the first match to avoid skipping some. if (PrefixLoc > FirstLoc) continue; + // If one matching check-prefix is a prefix of another, choose the + // longer one. + if (PrefixLoc == FirstLoc && Prefix.size() < FirstPrefix.size()) + continue; StringRef Rest = Buffer.drop_front(PrefixLoc); // Make sure we have actually found the prefix, and not a word containing @@ -793,22 +797,19 @@ static StringRef FindFirstCandidateMatch(StringRef &Buffer, if (PrefixLoc != 0 && IsPartOfWord(Buffer[PrefixLoc - 1])) continue; - Check::CheckType Ty = FindCheckType(Rest, Prefix); - FirstLoc = PrefixLoc; - FirstTy = Ty; - // We've found the first matching check prefix. If it is invalid, we should - // continue the search after it. - FirstPrefix = (Ty == Check::CheckNone) ? "" : Prefix; + FirstTy = FindCheckType(Rest, Prefix); + FirstPrefix = Prefix; } - if (FirstPrefix.empty()) { + // If the first prefix is invalid, we should continue the search after it. + if (FirstTy == Check::CheckNone) { CheckLoc = SearchLoc; - } else { - CheckTy = FirstTy; - CheckLoc = FirstLoc; + return ""; } + CheckTy = FirstTy; + CheckLoc = FirstLoc; return FirstPrefix; } |