[PATCH] D29122: [FileCheck] Add ability to match newline characters

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 04:32:57 PST 2017


jhenderson created this revision.

Currently there is no way using FileCheck to match an explicit newline character. Using, for example, the pattern "{{\n}}" matches an 'n' character, not '\n' (nor for that matter the string "\n"). The current suggested method of using [[:space:]] matches all forms of whitespace, so may not be always suitable.

This change coverts the pattern "\n" into a single '\n' character for use by the regex matcher, within regular expression patterns, if the new switch "--match-new-line-characters" is specified. Backslashes preceding 'n' characters can be escaped using double backslashes, if necessary.

I considered putting this change in without the switch. However, in that case FileCheck's behaviour when presented with the string "a\nnewline" would be different to grep's, which matches "annewline" in this case. I'm not sure that this is desirable.


https://reviews.llvm.org/D29122

Files:
  docs/CommandGuide/FileCheck.rst
  test/FileCheck/explicit-newlines.txt
  utils/FileCheck/FileCheck.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29122.85720.patch
Type: text/x-patch
Size: 4511 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170125/f45626c4/attachment.bin>


More information about the llvm-commits mailing list