diff options
author | James Henderson <jh7370@my.bristol.ac.uk> | 2018-06-26 15:15:45 +0000 |
---|---|---|
committer | James Henderson <jh7370@my.bristol.ac.uk> | 2018-06-26 15:15:45 +0000 |
commit | 5507f6688def557aca3dbbf7cf53cdf6a13ad8f8 (patch) | |
tree | cab9ecb080d36f4f73dda00e4da645fa30eb73dd /llvm/docs/CommandGuide | |
parent | 2f93fd1f50116cf4c17a491ef94869c784b47a96 (diff) | |
download | bcm5719-llvm-5507f6688def557aca3dbbf7cf53cdf6a13ad8f8.tar.gz bcm5719-llvm-5507f6688def557aca3dbbf7cf53cdf6a13ad8f8.zip |
[FileCheck] Add CHECK-EMPTY directive for checking for blank lines
Prior to this change, there was no clean way of getting FileCheck to
check that a line is completely empty. The expected way of using
"CHECK: {{^$}}" does not work because the '^' matches the end of the
previous match (this behaviour may be desirable in certain instances).
For the same reason, "CHECK-NEXT: {{^$}}" will fail when the previous
match was at the end of the line, as the pattern will match there.
Using the recommended [[:space:]] to match an explicit new line could
also match a space, and thus is not always desired. Literal '\n'
matches also do not work. A workaround was suggested in the review, but
it is a little clunky.
This change adds a new directive that behaves the same as CHECK-NEXT,
except that it only matches against empty lines (nothing, not even
whitespace, is allowed). As with CHECK-NEXT, it will fail if more than
one newline occurs before the next blank line. Example usage:
; test.txt
foo
bar
; CHECK: foo
; CHECK-EMPTY:
; CHECK-NEXT: bar
Differential Revision: https://reviews.llvm.org/D28896
Reviewed by: probinson
llvm-svn: 335613
Diffstat (limited to 'llvm/docs/CommandGuide')
-rw-r--r-- | llvm/docs/CommandGuide/FileCheck.rst | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/docs/CommandGuide/FileCheck.rst b/llvm/docs/CommandGuide/FileCheck.rst index 9078f65e01c..e169ea5c132 100644 --- a/llvm/docs/CommandGuide/FileCheck.rst +++ b/llvm/docs/CommandGuide/FileCheck.rst @@ -241,6 +241,25 @@ For example, the following works like you'd expect: it and the previous directive. A "``CHECK-SAME:``" cannot be the first directive in a file. +The "CHECK-EMPTY:" directive +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you need to check that the next line has nothing on it, not even whitespace, +you can use the "``CHECK-EMPTY:``" directive. + +.. code-block:: llvm + + foo + + bar + ; CHECK: foo + ; CHECK-EMPTY: + ; CHECK-NEXT: bar + +Just like "``CHECK-NEXT:``" the directive will fail if there is more than one +newline before it finds the next blank line, and it cannot be the first +directive in a file. + The "CHECK-NOT:" directive ~~~~~~~~~~~~~~~~~~~~~~~~~~ |