[llvm-dev] FileCheck: combining -DAG and -NOT

David Blaikie via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 7 20:42:50 PST 2016


I'd probably have expected the behavior it has - that -DAG and -NOT are not
ordered with respect to each other, and form a bag of things ordered with
respect to enclosing CHECK:s.

If you want to try turning it into an error, you could find all the places
we do use interspersed -DAG and -NOT and have a discussion about whether
they're more buggy than they are useful/correct.

On Mon, Mar 7, 2016 at 5:39 PM, Robinson, Paul via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> If you look at the FileCheck documentation page:
> http://llvm.org/docs/CommandGuide/FileCheck.html
> you'll find this intriguing example of combining -DAG with -NOT
> (slightly amended to avoid some potential confusion):
>
> ; CHECK-DAG: BEFORE
> ; CHECK-NOT: BETWEEN
> ; CHECK-DAG: AFTER
>
> The page says this will reject the sequence "AFTER BEFORE", which is
> correct.  It's intuitively obvious that it will also reject the text
> "BEFORE BETWEEN AFTER" as well.
>
> Pop Quiz:  Will it accept or reject "BEFORE AFTER BETWEEN"?
> No, don't go try it, that's cheating; what do you *think* will happen?
> Take a minute, I won't mind.
> ---
>
> So, here's the story.
>
> Normally a -NOT line will scan the text between the points where the
> preceding and following CHECK lines match.  By that mental model, you'd
> expect the first -DAG to find BEFORE, the second -DAG to find AFTER, and
> then -NOT would verify the absence of "BETWEEN" between those two points.
> All very intuitive, and I've certainly seen tests written to expect that.
>
> However, things get a little funky when you have -NOT followed by -DAG.
> What's the endpoint of the -NOT search?  The thing that follows isn't
> a CHECK, it's a CHECK-DAG, except that -NOT is already kind of DAG-ish
> so you have two DAG-ish groups staring at each other wondering who will
> go first.
>
> In this case, turns out, it's the -NOT who blinks first.  The endpoint
> of the search is implicitly the end-of-input.  The Pop Quiz answer is:
> *Rejected.*  The BETWEEN occurs after BEFORE, and before the end-of-input.
>
> Here's the real question:  *Should* FileCheck run the second -DAG group
> before it runs the -NOT group?  Then the range for the -NOT would be
> bounded by the matching points for the surrounding -DAG lines, which
> probably matches what basically everybody expects to happen.
>
> Or, leave things as they are, and add a cautionary tale to the FileCheck
> documentation page?  Given there's an actual documentation example, it
> would seem inappropriate to make it an *error* if a -NOT is followed
> by a -DAG!
>
> Thanks,
> --paulr
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160307/6848136f/attachment.html>


More information about the llvm-dev mailing list