1FILECHECK(1)                         LLVM                         FILECHECK(1)
2
3
4

NAME

6       FileCheck - Flexible pattern matching file verifier
7

SYNOPSIS

9       FileCheck match-filename [--check-prefix=XXX] [--strict-whitespace]
10

DESCRIPTION

12       FileCheck  reads  two files (one from standard input, and one specified
13       on the command line) and uses one to verify the other.   This  behavior
14       is  particularly  useful  for the testsuite, which wants to verify that
15       the output of some tool (e.g. llc) contains  the  expected  information
16       (for  example,  a  movsd from esp or whatever is interesting).  This is
17       similar to using grep, but it is optimized for matching  multiple  dif‐
18       ferent inputs in one file in a specific order.
19
20       The  match-filename  file specifies the file that contains the patterns
21       to match.  The file to verify is read from standard  input  unless  the
22       --input-file option is used.
23

OPTIONS

25       Options  are  parsed  from  the environment variable FILECHECK_OPTS and
26       from the command line.
27
28       -help  Print a summary of command line options.
29
30       --check-prefix prefix
31              FileCheck searches the contents of match-filename  for  patterns
32              to   match.   By  default,  these  patterns  are  prefixed  with
33              "CHECK:".  If you'd like to use a different prefix (e.g. because
34              the  same  input  file  is  checking  multiple different tool or
35              options), the --check-prefix argument allows you to specify  one
36              or  more  prefixes  to  match.  Multiple prefixes are useful for
37              tests which might change for different  run  options,  but  most
38              lines remain the same.
39
40       --check-prefixes prefix1,prefix2,...
41              An  alias  of --check-prefix that allows multiple prefixes to be
42              specified as a comma separated list.
43
44       --input-file filename
45              File to check (defaults to stdin).
46
47       --match-full-lines
48              By default, FileCheck allows matches of anywhere on a line. This
49              option  will  require  all  positive  matches to cover an entire
50              line.  Leading  and  trailing  whitespace  is  ignored,   unless
51              --strict-whitespace  is  also specified. (Note: negative matches
52              from CHECK-NOT are not affected by this option!)
53
54              Passing this option is equivalent to inserting {{^ *}} or  {{^}}
55              before, and {{ *$}} or {{$}} after every positive check pattern.
56
57       --strict-whitespace
58              By  default, FileCheck canonicalizes input horizontal whitespace
59              (spaces and tabs) which causes it to ignore these differences (a
60              space  will match a tab).  The --strict-whitespace argument dis‐
61              ables this behavior. End-of-line sequences are canonicalized  to
62              UNIX-style \n in all modes.
63
64       --ignore-case
65              By  default, FileCheck uses case-sensitive matching. This option
66              causes FileCheck to use case-insensitive matching.
67
68       --implicit-check-not check-pattern
69              Adds implicit negative checks for the specified patterns between
70              positive  checks. The option allows writing stricter tests with‐
71              out stuffing them with CHECK-NOTs.
72
73              For example, "--implicit-check-not warning:" can be useful  when
74              testing diagnostic messages from tools that don't have an option
75              similar to clang -verify. With this option FileCheck will verify
76              that  input  does not contain warnings not covered by any CHECK:
77              patterns.
78
79       --dump-input <mode>
80              Dump input to stderr, adding annotations representing  currently
81              enabled  diagnostics.   Do  this  either 'always', on 'fail', or
82              'never'.  Specify 'help' to explain the dump format and quit.
83
84       --dump-input-on-failure
85              When the check fails, dump all  of  the  original  input.   This
86              option is deprecated in favor of --dump-input=fail.
87
88       --enable-var-scope
89              Enables scope for regex variables.
90
91              Variables with names that start with $ are considered global and
92              remain set throughout the file.
93
94              All  other  variables  get  undefined  after  each   encountered
95              CHECK-LABEL.
96
97       -D<VAR=VALUE>
98              Sets  a filecheck pattern variable VAR with value VALUE that can
99              be used in CHECK: lines.
100
101       -D#<NUMVAR>=<NUMERIC EXPRESSION>
102              Sets a filecheck numeric variable NUMVAR to the result of evalu‐
103              ating <NUMERIC EXPRESSION> that can be used in CHECK: lines. See
104              section FileCheck Numeric Variables and Expressions for  details
105              on supported numeric expressions.
106
107       -version
108              Show the version number of this program.
109
110       -v     Print    good    directive   pattern   matches.    However,   if
111              -input-dump=fail or -input-dump=always,  add  those  matches  as
112              input annotations instead.
113
114       -vv    Print  information  helpful  in  diagnosing  internal  FileCheck
115              issues,  such  as  discarded  overlapping  CHECK-DAG:   matches,
116              implicit  EOF  pattern  matches, and CHECK-NOT: patterns that do
117              not have matches.  Implies -v.  However, if -input-dump=fail  or
118              -input-dump=always,  just  add that information as input annota‐
119              tions instead.
120
121       --allow-deprecated-dag-overlap
122              Enable overlapping among  matches  in  a  group  of  consecutive
123              CHECK-DAG:  directives.   This  option is deprecated and is only
124              provided for convenience as old tests are migrated  to  the  new
125              non-overlapping CHECK-DAG: implementation.
126
127       --color
128              Use colors in output (autodetected by default).
129

EXIT STATUS

131       If  FileCheck  verifies that the file matches the expected contents, it
132       exits with 0.  Otherwise, if not, or if an error occurs, it  will  exit
133       with a non-zero value.
134

TUTORIAL

136       FileCheck  is  typically used from LLVM regression tests, being invoked
137       on the RUN line of the test.  A simple example of using FileCheck  from
138       a RUN line looks like this:
139
140          ; RUN: llvm-as < %s | llc -march=x86-64 | FileCheck %s
141
142       This  syntax  says  to  pipe the current file ("%s") into llvm-as, pipe
143       that into llc, then pipe the output of llc into FileCheck.  This  means
144       that  FileCheck  will  be verifying its standard input (the llc output)
145       against the filename argument specified (the original .ll  file  speci‐
146       fied  by  "%s").   To see how this works, let's look at the rest of the
147       .ll file (after the RUN line):
148
149          define void @sub1(i32* %p, i32 %v) {
150          entry:
151          ; CHECK: sub1:
152          ; CHECK: subl
153                  %0 = tail call i32 @llvm.atomic.load.sub.i32.p0i32(i32* %p, i32 %v)
154                  ret void
155          }
156
157          define void @inc4(i64* %p) {
158          entry:
159          ; CHECK: inc4:
160          ; CHECK: incq
161                  %0 = tail call i64 @llvm.atomic.load.add.i64.p0i64(i64* %p, i64 1)
162                  ret void
163          }
164
165       Here you can see some "CHECK:" lines specified in  comments.   Now  you
166       can  see  how the file is piped into llvm-as, then llc, and the machine
167       code output is what we are verifying.   FileCheck  checks  the  machine
168       code output to verify that it matches what the "CHECK:" lines specify.
169
170       The syntax of the "CHECK:" lines is very simple: they are fixed strings
171       that must occur in order.  FileCheck defaults  to  ignoring  horizontal
172       whitespace  differences  (e.g.  a  space is allowed to match a tab) but
173       otherwise, the contents of the "CHECK:" line is required to match  some
174       thing in the test file exactly.
175
176       One  nice  thing  about  FileCheck (compared to grep) is that it allows
177       merging test cases together into logical groups.  For example,  because
178       the  test above is checking for the "sub1:" and "inc4:" labels, it will
179       not match unless there is a "subl" in  between  those  labels.   If  it
180       existed  somewhere  else in the file, that would not count: "grep subl"
181       matches if "subl" exists anywhere in the file.
182
183   The FileCheck -check-prefix option
184       The FileCheck -check-prefix option allows multiple test  configurations
185       to  be driven from one .ll file.  This is useful in many circumstances,
186       for example, testing different architectural variants with llc.  Here's
187       a simple example:
188
189          ; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin9 -mattr=sse41 \
190          ; RUN:              | FileCheck %s -check-prefix=X32
191          ; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin9 -mattr=sse41 \
192          ; RUN:              | FileCheck %s -check-prefix=X64
193
194          define <4 x i32> @pinsrd_1(i32 %s, <4 x i32> %tmp) nounwind {
195                  %tmp1 = insertelement <4 x i32>; %tmp, i32 %s, i32 1
196                  ret <4 x i32> %tmp1
197          ; X32: pinsrd_1:
198          ; X32:    pinsrd $1, 4(%esp), %xmm0
199
200          ; X64: pinsrd_1:
201          ; X64:    pinsrd $1, %edi, %xmm0
202          }
203
204       In  this  case,  we're testing that we get the expected code generation
205       with both 32-bit and 64-bit code generation.
206
207   The CHECK-NEXT: directive
208       Sometimes you want to match lines and would like to verify that matches
209       happen  on  exactly  consecutive  lines  with no other lines in between
210       them.  In this case, you can use "CHECK:" and "CHECK-NEXT:"  directives
211       to  specify  this.   If  you  specified a custom check prefix, just use
212       "<PREFIX>-NEXT:".  For example, something  like  this  works  as  you'd
213       expect:
214
215          define void @t2(<2 x double>* %r, <2 x double>* %A, double %B) {
216               %tmp3 = load <2 x double>* %A, align 16
217               %tmp7 = insertelement <2 x double> undef, double %B, i32 0
218               %tmp9 = shufflevector <2 x double> %tmp3,
219                                      <2 x double> %tmp7,
220                                      <2 x i32> < i32 0, i32 2 >
221               store <2 x double> %tmp9, <2 x double>* %r, align 16
222               ret void
223
224          ; CHECK:          t2:
225          ; CHECK:             movl    8(%esp), %eax
226          ; CHECK-NEXT:        movapd  (%eax), %xmm0
227          ; CHECK-NEXT:        movhpd  12(%esp), %xmm0
228          ; CHECK-NEXT:        movl    4(%esp), %eax
229          ; CHECK-NEXT:        movapd  %xmm0, (%eax)
230          ; CHECK-NEXT:        ret
231          }
232
233       "CHECK-NEXT:"  directives  reject the input unless there is exactly one
234       newline between it and the previous directive.  A "CHECK-NEXT:"  cannot
235       be the first directive in a file.
236
237   The CHECK-SAME: directive
238       Sometimes you want to match lines and would like to verify that matches
239       happen on the same line as the previous match.  In this case,  you  can
240       use  "CHECK:"  and  "CHECK-SAME:"  directives  to specify this.  If you
241       specified a custom check prefix, just use "<PREFIX>-SAME:".
242
243       "CHECK-SAME:" is particularly powerful in conjunction with "CHECK-NOT:"
244       (described below).
245
246       For example, the following works like you'd expect:
247
248          !0 = !DILocation(line: 5, scope: !1, inlinedAt: !2)
249
250          ; CHECK:       !DILocation(line: 5,
251          ; CHECK-NOT:               column:
252          ; CHECK-SAME:              scope: ![[SCOPE:[0-9]+]]
253
254       "CHECK-SAME:"  directives  reject  the  input if there are any newlines
255       between it and the previous directive.  A "CHECK-SAME:" cannot  be  the
256       first directive in a file.
257
258   The CHECK-EMPTY: directive
259       If  you  need  to  check that the next line has nothing on it, not even
260       whitespace, you can use the "CHECK-EMPTY:" directive.
261
262          declare void @foo()
263
264          declare void @bar()
265          ; CHECK: foo
266          ; CHECK-EMPTY:
267          ; CHECK-NEXT: bar
268
269       Just like "CHECK-NEXT:" the directive will fail if there is  more  than
270       one  newline  before it finds the next blank line, and it cannot be the
271       first directive in a file.
272
273   The CHECK-NOT: directive
274       The "CHECK-NOT:" directive is used to  verify  that  a  string  doesn't
275       occur between two matches (or before the first match, or after the last
276       match).  For example, to verify that a load is removed by a transforma‐
277       tion, a test like this can be used:
278
279          define i8 @coerce_offset0(i32 %V, i32* %P) {
280            store i32 %V, i32* %P
281
282            %P2 = bitcast i32* %P to i8*
283            %P3 = getelementptr i8* %P2, i32 2
284
285            %A = load i8* %P3
286            ret i8 %A
287          ; CHECK: @coerce_offset0
288          ; CHECK-NOT: load
289          ; CHECK: ret i8
290          }
291
292   The CHECK-COUNT: directive
293       If you need to match multiple lines with the same pattern over and over
294       again you can repeat a plain CHECK: as many times as  needed.  If  that
295       looks    too   boring   you   can   instead   use   a   counted   check
296       "CHECK-COUNT-<num>:", where <num> is a positive decimal number. It will
297       match  the  pattern  exactly  <num>  times, no more and no less. If you
298       specified a custom check prefix, just use  "<PREFIX>-COUNT-<num>:"  for
299       the same effect.  Here is a simple example:
300
301          Loop at depth 1
302          Loop at depth 1
303          Loop at depth 1
304          Loop at depth 1
305            Loop at depth 2
306              Loop at depth 3
307
308          ; CHECK-COUNT-6: Loop at depth {{[0-9]+}}
309          ; CHECK-NOT:     Loop at depth {{[0-9]+}}
310
311   The CHECK-DAG: directive
312       If  it's  necessary  to  match  strings  that don't occur in a strictly
313       sequential order, "CHECK-DAG:" could be used to verify them between two
314       matches (or before the first match, or after the last match). For exam‐
315       ple, clang emits vtable globals in reverse order. Using CHECK-DAG:,  we
316       can keep the checks in the natural order:
317
318          // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
319
320          struct Foo { virtual void method(); };
321          Foo f;  // emit vtable
322          // CHECK-DAG: @_ZTV3Foo =
323
324          struct Bar { virtual void method(); };
325          Bar b;
326          // CHECK-DAG: @_ZTV3Bar =
327
328       CHECK-NOT:  directives  could  be  mixed  with CHECK-DAG: directives to
329       exclude strings between the surrounding  CHECK-DAG:  directives.  As  a
330       result, the surrounding CHECK-DAG: directives cannot be reordered, i.e.
331       all occurrences matching CHECK-DAG: before  CHECK-NOT:  must  not  fall
332       behind occurrences matching CHECK-DAG: after CHECK-NOT:. For example,
333
334          ; CHECK-DAG: BEFORE
335          ; CHECK-NOT: NOT
336          ; CHECK-DAG: AFTER
337
338       This case will reject input strings where BEFORE occurs after AFTER.
339
340       With  captured variables, CHECK-DAG: is able to match valid topological
341       orderings of a DAG with edges from the definition of a variable to  its
342       use.   It's  useful, e.g., when your test cases need to match different
343       output sequences from the instruction scheduler. For example,
344
345          ; CHECK-DAG: add [[REG1:r[0-9]+]], r1, r2
346          ; CHECK-DAG: add [[REG2:r[0-9]+]], r3, r4
347          ; CHECK:     mul r5, [[REG1]], [[REG2]]
348
349       In this case, any order of that two add instructions will be allowed.
350
351       If you are defining and using variables in the same  CHECK-DAG:  block,
352       be aware that the definition rule can match after its use.
353
354       So, for instance, the code below will pass:
355
356          ; CHECK-DAG: vmov.32 [[REG2:d[0-9]+]][0]
357          ; CHECK-DAG: vmov.32 [[REG2]][1]
358          vmov.32 d0[1]
359          vmov.32 d0[0]
360
361       While this other code, will not:
362
363          ; CHECK-DAG: vmov.32 [[REG2:d[0-9]+]][0]
364          ; CHECK-DAG: vmov.32 [[REG2]][1]
365          vmov.32 d1[1]
366          vmov.32 d0[0]
367
368       While this can be very useful, it's also dangerous, because in the case
369       of register sequence, you must have a strong order (read before  write,
370       copy  before  use,  etc).  If  the  definition your test is looking for
371       doesn't match (because of a bug in the compiler), it may match  further
372       away from the use, and mask real bugs away.
373
374       In  those  cases, to enforce the order, use a non-DAG directive between
375       DAG-blocks.
376
377       A CHECK-DAG: directive skips matches that overlap the  matches  of  any
378       preceding CHECK-DAG: directives in the same CHECK-DAG: block.  Not only
379       is this non-overlapping behavior consistent with other directives,  but
380       it's  also  necessary to handle sets of non-unique strings or patterns.
381       For example, the following directives look for  unordered  log  entries
382       for two tasks in a parallel program, such as the OpenMP runtime:
383
384          // CHECK-DAG: [[THREAD_ID:[0-9]+]]: task_begin
385          // CHECK-DAG: [[THREAD_ID]]: task_end
386          //
387          // CHECK-DAG: [[THREAD_ID:[0-9]+]]: task_begin
388          // CHECK-DAG: [[THREAD_ID]]: task_end
389
390       The  second  pair of directives is guaranteed not to match the same log
391       entries as the first pair even though the patterns  are  identical  and
392       even  if the text of the log entries is identical because the thread ID
393       manages to be reused.
394
395   The CHECK-LABEL: directive
396       Sometimes in a file containing  multiple  tests  divided  into  logical
397       blocks,  one  or  more  CHECK:  directives may inadvertently succeed by
398       matching lines in a later block. While an error will usually eventually
399       be  generated,  the check flagged as causing the error may not actually
400       bear any relationship to the actual source of the problem.
401
402       In  order  to  produce  better  error  messages  in  these  cases,  the
403       "CHECK-LABEL:"  directive  can  be used. It is treated identically to a
404       normal CHECK  directive  except  that  FileCheck  makes  an  additional
405       assumption  that a line matched by the directive cannot also be matched
406       by any other check present in match-filename; this is  intended  to  be
407       used for lines containing labels or other unique identifiers. Conceptu‐
408       ally, the presence of CHECK-LABEL divides the input stream  into  sepa‐
409       rate  blocks,  each  of  which is processed independently, preventing a
410       CHECK: directive in one block matching a line  in  another  block.   If
411       --enable-var-scope is in effect, all local variables are cleared at the
412       beginning of the block.
413
414       For example,
415
416          define %struct.C* @C_ctor_base(%struct.C* %this, i32 %x) {
417          entry:
418          ; CHECK-LABEL: C_ctor_base:
419          ; CHECK: mov [[SAVETHIS:r[0-9]+]], r0
420          ; CHECK: bl A_ctor_base
421          ; CHECK: mov r0, [[SAVETHIS]]
422            %0 = bitcast %struct.C* %this to %struct.A*
423            %call = tail call %struct.A* @A_ctor_base(%struct.A* %0)
424            %1 = bitcast %struct.C* %this to %struct.B*
425            %call2 = tail call %struct.B* @B_ctor_base(%struct.B* %1, i32 %x)
426            ret %struct.C* %this
427          }
428
429          define %struct.D* @D_ctor_base(%struct.D* %this, i32 %x) {
430          entry:
431          ; CHECK-LABEL: D_ctor_base:
432
433       The use of CHECK-LABEL: directives in this case ensures that the  three
434       CHECK:  directives  only  accept lines corresponding to the body of the
435       @C_ctor_base function, even if the patterns match lines found later  in
436       the  file.  Furthermore,  if one of these three CHECK: directives fail,
437       FileCheck will recover by continuing to the next block, allowing multi‐
438       ple test failures to be detected in a single invocation.
439
440       There  is  no  requirement that CHECK-LABEL: directives contain strings
441       that correspond to actual syntactic labels in a source or  output  lan‐
442       guage:  they must simply uniquely match a single line in the file being
443       verified.
444
445       CHECK-LABEL: directives cannot contain variable definitions or uses.
446
447   FileCheck Regex Matching Syntax
448       All FileCheck directives take a pattern to match.   For  most  uses  of
449       FileCheck,  fixed  string  matching  is perfectly sufficient.  For some
450       things, a more flexible form of matching is desired.  To support  this,
451       FileCheck  allows  you  to  specify  regular  expressions  in  matching
452       strings, surrounded by double braces: {{yourregex}}.  FileCheck  imple‐
453       ments  a  POSIX  regular expression matcher; it supports Extended POSIX
454       regular expressions (ERE). Because we want to use fixed string matching
455       for  a  majority  of what we do, FileCheck has been designed to support
456       mixing and matching fixed string  matching  with  regular  expressions.
457       This allows you to write things like this:
458
459          ; CHECK: movhpd      {{[0-9]+}}(%esp), {{%xmm[0-7]}}
460
461       In this case, any offset from the ESP register will be allowed, and any
462       xmm register will be allowed.
463
464       Because regular expressions are enclosed with double braces,  they  are
465       visually  distinct,  and you don't need to use escape characters within
466       the double braces like you would in C.  In the rare case that you  want
467       to match double braces explicitly from the input, you can use something
468       ugly like {{[}][}]}} as your pattern.  Or if you are using the  repeti‐
469       tion  count  syntax, for example [[:xdigit:]]{8} to match exactly 8 hex
470       digits,   you   would   need   to    add    parentheses    like    this
471       {{([[:xdigit:]]{8})}}  to avoid confusion with FileCheck's closing dou‐
472       ble-brace.
473
474   FileCheck String Substitution Blocks
475       It is often useful to match a pattern and then verify  that  it  occurs
476       again  later  in  the  file.   For codegen tests, this can be useful to
477       allow any register, but verify that that register is used  consistently
478       later.   To do this, FileCheck supports string substitution blocks that
479       allow string variables to be defined  and  substituted  into  patterns.
480       Here is a simple example:
481
482          ; CHECK: test5:
483          ; CHECK:    notw     [[REGISTER:%[a-z]+]]
484          ; CHECK:    andw     {{.*}}[[REGISTER]]
485
486       The  first  check line matches a regex %[a-z]+ and captures it into the
487       string variable REGISTER.  The second line verifies that whatever is in
488       REGISTER  occurs  later  in  the file after an "andw". FileCheck string
489       substitution blocks are always contained in [[  ]]  pairs,  and  string
490       variable names can be formed with the regex [a-zA-Z_][a-zA-Z0-9_]*.  If
491       a colon follows the name, then it is a definition of the variable; oth‐
492       erwise, it is a substitution.
493
494       FileCheck  variables  can  be defined multiple times, and substitutions
495       always get the latest value.  Variables can also be  substituted  later
496       on the same line they were defined on. For example:
497
498          ; CHECK: op [[REG:r[0-9]+]], [[REG]]
499
500       Can  be  useful if you want the operands of op to be the same register,
501       and don't care exactly which register it is.
502
503       If --enable-var-scope is in effect, variables  with  names  that  start
504       with  $  are  considered  to be global. All others variables are local.
505       All local variables get undefined at the beginning of each  CHECK-LABEL
506       block. Global variables are not affected by CHECK-LABEL.  This makes it
507       easier to ensure that individual tests are not  affected  by  variables
508       set in preceding tests.
509
510   FileCheck Numeric Substitution Blocks
511       FileCheck also supports numeric substitution blocks that allow defining
512       numeric variables and  checking  for  numeric  values  that  satisfy  a
513       numeric  expression  constraint  based on those variables via a numeric
514       substitution. This allows CHECK: directives to verify a  numeric  rela‐
515       tion between two numbers, such as the need for consecutive registers to
516       be used.
517
518       The syntax to define a numeric variable is [[#<NUMVAR>:]]  where  <NUM‐
519       VAR>  is  the  name  of  the numeric variable to define to the matching
520       value.
521
522       For example:
523
524          ; CHECK: mov r[[#REG:]], 42
525
526       would match mov r5, 42 and set REG to the value 5.
527
528       The syntax of a numeric substitution is [[#<expr>]] where <expr> is  an
529       expression. An expression is recursively defined as:
530
531       · a numeric operand, or
532
533       · an expression followed by an operator and a numeric operand.
534
535       A numeric operand is a previously defined numeric variable, or an inte‐
536       ger literal. The supported operators are + and -. Spaces  are  accepted
537       before, after and between any of these elements.
538
539       For example:
540
541          ; CHECK: load r[[#REG:]], [r0]
542          ; CHECK: load r[[#REG+1]], [r1]
543
544       The above example would match the text:
545
546          load r5, [r0]
547          load r6, [r1]
548
549       but would not match the text:
550
551          load r5, [r0]
552          load r7, [r1]
553
554       due to 7 being unequal to 5 + 1.
555
556       The  syntax  also  supports  an empty expression, equivalent to writing
557       {{[0-9]+}}, for cases where the input must contain a numeric value  but
558       the value itself does not matter:
559
560          ; CHECK-NOT: mov r0, r[[#]]
561
562       to check that a value is synthesized rather than moved around.
563
564       A  numeric  variable  can  also  be  defined to the result of a numeric
565       expression, in which case the numeric expression is checked and if ver‐
566       ified  the  variable  is  assigned to the value. The unified syntax for
567       both defining numeric variables and checking a  numeric  expression  is
568       thus [[#<NUMVAR>: <expr>]] with each element as described previously.
569
570       The  --enable-var-scope option has the same effect on numeric variables
571       as on string variables.
572
573       Important note: In its current implementation, an expression cannot use
574       a numeric variable defined earlier in the same CHECK directive.
575
576   FileCheck Pseudo Numeric Variables
577       Sometimes there's a need to verify output that contains line numbers of
578       the match file, e.g. when testing compiler  diagnostics.   This  intro‐
579       duces  a  certain  fragility  of  the match file structure, as "CHECK:"
580       lines contain absolute line numbers in the same file, which have to  be
581       updated whenever line numbers change due to text addition or deletion.
582
583       To support this case, FileCheck expressions understand the @LINE pseudo
584       numeric variable which evaluates to the line number of the  CHECK  pat‐
585       tern where it is found.
586
587       This  way  match  patterns  can be put near the relevant test lines and
588       include relative line number references, for example:
589
590          // CHECK: test.cpp:[[# @LINE + 4]]:6: error: expected ';' after top level declarator
591          // CHECK-NEXT: {{^int a}}
592          // CHECK-NEXT: {{^     \^}}
593          // CHECK-NEXT: {{^     ;}}
594          int a
595
596       To support legacy uses of @LINE as a special string variable, FileCheck
597       also accepts the following uses of @LINE with string substitution block
598       syntax: [[@LINE]], [[@LINE+<offset>]]  and  [[@LINE-<offset>]]  without
599       any spaces inside the brackets and where offset is an integer.
600
601   Matching Newline Characters
602       To  match newline characters in regular expressions the character class
603       [[:space:]] can be used. For example, the following pattern:
604
605          // CHECK: DW_AT_location [DW_FORM_sec_offset] ([[DLOC:0x[0-9a-f]+]]){{[[:space:]].*}}"intd"
606
607       matches output of the form (from llvm-dwarfdump):
608
609          DW_AT_location [DW_FORM_sec_offset]   (0x00000233)
610          DW_AT_name [DW_FORM_strp]  ( .debug_str[0x000000c9] = "intd")
611
612       letting us set  the  FileCheck  variable  DLOC  to  the  desired  value
613       0x00000233, extracted from the line immediately preceding "intd".
614

AUTHOR

616       Maintained by the LLVM Team (https://llvm.org/).
617
619       2003-2020, LLVM Project
620
621
622
623
62410                                2020-08-04                      FILECHECK(1)
Impressum