summaryrefslogtreecommitdiff
path: root/docs
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
commit70a870add82dab944b98ee1840fafff33795fc95 (patch)
treeeb880778e614c2a5bdcacec1f89813dc956c99e0 /docs
parent7454fc2e87ef5638f3644b86a4350a44513e5185 (diff)
downloadllvm-70a870add82dab944b98ee1840fafff33795fc95.tar.gz
llvm-70a870add82dab944b98ee1840fafff33795fc95.tar.bz2
llvm-70a870add82dab944b98ee1840fafff33795fc95.tar.xz
Support for [[@LINE]], [[@LINE+<offset>]], [[@LINE-<offset>]] expressions in
FileCheck. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167978 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs')
-rw-r--r--docs/CommandGuide/FileCheck.rst27
1 files changed, 27 insertions, 0 deletions
diff --git a/docs/CommandGuide/FileCheck.rst b/docs/CommandGuide/FileCheck.rst
index 049e10bbcf..ba2fe4ad9c 100644
--- a/docs/CommandGuide/FileCheck.rst
+++ b/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
+