summaryrefslogtreecommitdiffstats
path: root/llvm/docs/CommandGuide
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2012-11-14 21:07:37 +0000
committerAlexander Kornienko <alexfh@google.com>2012-11-14 21:07:37 +0000
commit92987fb311b70f5264bd9384d02a8f79c5db000a (patch)
tree8d649859942d5a63565485db47a86e7e017a6293 /llvm/docs/CommandGuide
parentd17df318c03eb55cb63811038cf528a6c7609aed (diff)
downloadbcm5719-llvm-92987fb311b70f5264bd9384d02a8f79c5db000a.tar.gz
bcm5719-llvm-92987fb311b70f5264bd9384d02a8f79c5db000a.zip
Support for [[@LINE]], [[@LINE+<offset>]], [[@LINE-<offset>]] expressions in
FileCheck. llvm-svn: 167978
Diffstat (limited to 'llvm/docs/CommandGuide')
-rw-r--r--llvm/docs/CommandGuide/FileCheck.rst27
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/docs/CommandGuide/FileCheck.rst b/llvm/docs/CommandGuide/FileCheck.rst
index 049e10bbcf5..ba2fe4ad9c1 100644
--- a/llvm/docs/CommandGuide/FileCheck.rst
+++ b/llvm/docs/CommandGuide/FileCheck.rst
@@ -252,3 +252,30 @@ advantage of the fact that FileCheck is not actually line-oriented when it
matches, this allows you to define two separate "``CHECK``" lines that match on
the same line.
+
+FileCheck Expressions
+~~~~~~~~~~~~~~~~~~~~~
+
+
+Sometimes there's a need to verify output which refers line numbers of the match
+file, e.g. when testing compiler diagnostics. This introduces a certain
+fragility of the match file structure, as CHECK: lines contain absolute line
+numbers in the same file, which have to be updated whenever line numbers change
+due to text addition or deletion.
+
+To support this case, FileCheck allows using ``[[@LINE]]``,
+``[[@LINE+<offset>]]``, ``[[@LINE-<offset>]]`` expressions in patterns. These
+expressions expand to a number of the line where a pattern is located (with an
+optional integer offset).
+
+This way match patterns can be put near the relevant test lines and include
+relative line number references, for example:
+
+.. code-block:: c++
+
+ // CHECK: test.cpp:[[@LINE+4]]:6: error: expected ';' after top level declarator
+ // CHECK-NEXT: {{^int a}}
+ // CHECK-NEXT: {{^ \^}}
+ // CHECK-NEXT: {{^ ;}}
+ int a
+
OpenPOWER on IntegriCloud