diff options
author | Kai Nacke <kai.nacke@redstar.de> | 2019-10-11 11:59:14 +0000 |
---|---|---|
committer | Kai Nacke <kai.nacke@redstar.de> | 2019-10-11 11:59:14 +0000 |
commit | 5b5b2fd2b8b4fe66d1e57065ab0aef22b16e4a13 (patch) | |
tree | a9dbb8b8302a33a151a759cea9a7226da310c657 /llvm/lib/Support/FileCheck.cpp | |
parent | 807dbee36679a8e43b25c3fcfd38e750fd4e943d (diff) | |
download | bcm5719-llvm-5b5b2fd2b8b4fe66d1e57065ab0aef22b16e4a13.tar.gz bcm5719-llvm-5b5b2fd2b8b4fe66d1e57065ab0aef22b16e4a13.zip |
[FileCheck] Implement --ignore-case option.
The FileCheck utility is enhanced to support a `--ignore-case`
option. This is useful in cases where the output of Unix tools
differs in case (e.g. case not specified by Posix).
Reviewers: Bigcheese, jakehehrlich, rupprecht, espindola, alexshap, jhenderson, MaskRay
Differential Revision: https://reviews.llvm.org/D68146
llvm-svn: 374538
Diffstat (limited to 'llvm/lib/Support/FileCheck.cpp')
-rw-r--r-- | llvm/lib/Support/FileCheck.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Support/FileCheck.cpp b/llvm/lib/Support/FileCheck.cpp index c3f537b3524..841e406a7b6 100644 --- a/llvm/lib/Support/FileCheck.cpp +++ b/llvm/lib/Support/FileCheck.cpp @@ -320,6 +320,7 @@ bool FileCheckPattern::parsePattern(StringRef PatternStr, StringRef Prefix, SourceMgr &SM, const FileCheckRequest &Req) { bool MatchFullLinesHere = Req.MatchFullLines && CheckTy != Check::CheckNot; + IgnoreCase = Req.IgnoreCase; PatternLoc = SMLoc::getFromPointer(PatternStr.data()); @@ -619,7 +620,8 @@ Expected<size_t> FileCheckPattern::match(StringRef Buffer, size_t &MatchLen, // If this is a fixed string pattern, just match it now. if (!FixedStr.empty()) { MatchLen = FixedStr.size(); - size_t Pos = Buffer.find(FixedStr); + size_t Pos = IgnoreCase ? Buffer.find_lower(FixedStr) + : Buffer.find(FixedStr); if (Pos == StringRef::npos) return make_error<FileCheckNotFoundError>(); return Pos; @@ -657,7 +659,10 @@ Expected<size_t> FileCheckPattern::match(StringRef Buffer, size_t &MatchLen, } SmallVector<StringRef, 4> MatchInfo; - if (!Regex(RegExToMatch, Regex::Newline).match(Buffer, &MatchInfo)) + unsigned int Flags = Regex::Newline; + if (IgnoreCase) + Flags |= Regex::IgnoreCase; + if (!Regex(RegExToMatch, Flags).match(Buffer, &MatchInfo)) return make_error<FileCheckNotFoundError>(); // Successful regex match. |