[FileCheck] Report captured variables
authorJoel E. Denny <jdenny.ornl@gmail.com>
Tue, 28 Jul 2020 22:09:47 +0000 (18:09 -0400)
committerJoel E. Denny <jdenny.ornl@gmail.com>
Tue, 28 Jul 2020 23:15:18 +0000 (19:15 -0400)
commit9f86b8ec41f04fa6f087264008317515a612a922
treed2b6438292e52c2eb206645c241c68cb41e2cd5e
parentd680711b94e94e9387076a0daf2a329e304e6751
[FileCheck] Report captured variables

Report captured variables in input dumps and traces.  For example:

```
$ cat check
CHECK: hello [[WHAT:[a-z]+]]
CHECK: goodbye [[WHAT]]

$ FileCheck -dump-input=always -vv check < input |& tail -8
<<<<<<
           1: hello world
check:1'0     ^~~~~~~~~~~
check:1'1           ^~~~~ captured var "WHAT"
           2: goodbye world
check:2'0     ^~~~~~~~~~~~~
check:2'1                   with "WHAT" equal to "world"
>>>>>>

$ FileCheck -dump-input=never -vv check < input
check2:1:8: remark: CHECK: expected string found in input
CHECK: hello [[WHAT:[a-z]+]]
       ^
<stdin>:1:1: note: found here
hello world
^~~~~~~~~~~
<stdin>:1:7: note: captured var "WHAT"
hello world
      ^~~~~
check2:2:8: remark: CHECK: expected string found in input
CHECK: goodbye [[WHAT]]
       ^
<stdin>:2:1: note: found here
goodbye world
^~~~~~~~~~~~~
<stdin>:2:1: note: with "WHAT" equal to "world"
goodbye world
^
```

Reviewed By: thopre

Differential Revision: https://reviews.llvm.org/D83651
llvm/lib/Support/FileCheck.cpp
llvm/lib/Support/FileCheckImpl.h
llvm/test/FileCheck/dump-input-annotations.txt
llvm/test/FileCheck/verbose.txt
llvm/unittests/Support/FileCheckTest.cpp