[PATCH] D21522: Document multi-line pattern matching in FileCheck

Wolfgang Pieb via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 20 11:16:53 PDT 2016


wolfgangp created this revision.
wolfgangp added a subscriber: llvm-commits.

It recently came to my attention that multi-line pattern matching can be done in FileCheck by using the character class [[:space:]]. I propose the following patch to the FileCheck documentation:

http://reviews.llvm.org/D21522

Files:
  docs/CommandGuide/FileCheck.rst

Index: docs/CommandGuide/FileCheck.rst
===================================================================
--- docs/CommandGuide/FileCheck.rst
+++ docs/CommandGuide/FileCheck.rst
@@ -461,3 +461,22 @@
    // CHECK-NEXT: {{^     ;}}
    int a
 
+Matching Newline Characters
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+To match newline characters in regular expressions the character class
+``[[:space:]]`` can be used. For example, the following pattern:
+
+.. code-block:: c++
+
+   // CHECK: DW_AT_location [DW_FORM_sec_offset] ([[DLOC:0x[0-9a-f]+]]){{[[:space:]].*}}"intd"
+
+matches output of the form (from llvm-dwarfdump):
+
+.. code-block:: llvm
+
+       DW_AT_location [DW_FORM_sec_offset]   (0x00000233)
+       DW_AT_name [DW_FORM_strp]  ( .debug_str[0x000000c9] = "intd")
+
+letting us set the :program:`FileCheck` variable ``DLOC`` to the desired value 
+``0x00000233``, extracted from the line immediately preceding "``intd``".


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21522.61271.patch
Type: text/x-patch
Size: 928 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160620/47737e17/attachment.bin>


More information about the llvm-commits mailing list