[PATCH] D47106: [FileCheck] Make CHECK-DAG non-overlapping

Paul Robinson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 23 07:50:26 PDT 2018


probinson added inline comments.


================
Comment at: utils/FileCheck/FileCheck.cpp:1245
       // All subsequent CHECK-DAGs should be matched from the farthest
-      // position of all precedent CHECK-DAGs (including this one.)
+      // position of all precedent CHECK-DAGs (not including this one).
       StartPos = LastPos;
----------------
jdenny wrote:
> Speaking of the reordering check, we should discuss this comment change.
> 
> I made this change to reflect the implementation, but now I'm wondering if the comment described the desired behavior and the implementation was wrong.  I'm not really sure.  Moreover, this comment change does not reflect any change made by this patch, so perhaps it should be in a separate patch.
> 
> The implementation works as follows (with or without this patch as there's no overlapping here).  Using the X-Y model from earlier, the implementation seeks non-initial members of Y from the end of X rather than the start of Y.  For example, the following succeeds even though the second member of Y matches before the first member of Y:
> 
> 
> ```
> X:
> abc
> 
> Y:
> ghi
> def
> foo
> jkl
> 
> X:
> CHECK-DAG: {{^}}abc
> 
> CHECK-NOT: {{^}}foo
> 
> Y:
> CHECK-DAG: {{^}}def
> CHECK-DAG: {{^}}ghi
> CHECK-DAG: {{^}}jkl
> ```
> 
> To make things more confusing, if I move the occurrence of foo right before the occurrence of def, the CHECK-NOT fails.  That is, the CHECK-NOTs are sought before the first member of Y, but the other members of Y are sought both before and after Y.  It might be more intuitive if the first member of Y marks the beginning of Y (as the comment originally claimed) so that CHECK-NOTs are sought strictly between all of X and all of Y.
My understanding of putting NOT between DAGs is this:
```
X:
abc
Y:
ghi
def
foo
jkl

X:
CHECK-DAG: b
CHECK-DAG: a

CHECK-NOT: foo

Y:
CHECK-DAG: def
CHECK-DAG: ghi
```
First the X group of DAGs runs, over the entire input text.  The farthest-forward match (here 'b') is remembered.
Then the Y group of DAGs runs, from the farthest-forward X match (i.e., after 'b') to the end of the input text.  The earliest match (here 'ghi') is remembered.
Finally the NOT runs, in the range from the end of the X matches (after 'b') to the beginning of the earliest Y match (before 'ghi').

The X matches and the Y matches can never overlap, even though they are both DAG groups they are separated by the NOT.  Therefore the search range of the Y group is constrained to start after the latest match of the X group.

Is that not what happens?  Even with overlapping DAG matches enabled?  Your explanation made it sound as if you expected the order of DAG directives in Y to make a difference to the NOT directive, when I think it should not.


https://reviews.llvm.org/D47106





More information about the llvm-commits mailing list