[PATCH] D58784: [FileCheck]Remove assertions that prevent matching an empty string at file start before CHECK-NEXT/SAME
Joel E. Denny via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 28 18:55:05 PST 2019
jdenny added a comment.
In D58784#1414493 <https://reviews.llvm.org/D58784#1414493>, @probinson wrote:
> > The following appears to be equivalent to what an initial CHECK-EMPTY should do:
> >
> > CHECK: {{^}}
> > CHECK-SAME: {{^$}}
>
> Yep. So if we allow an initial CHECK-SAME, defining the search range as starting at the beginning of the input, then an initial `CHECK-SAME: stuff` verifies that `stuff` appears on the first line, and `CHECK-SAME: {{^$}}` verifies the first line is empty. That seems pretty intuitive to me.
I see what you mean, but see below.
> Am I reading the docs rightly, it looks like `CHECK-EMPTY` is exactly `CHECK-NEXT: {{^$}}` isn't it? Did we have some other rationale for adding EMPTY, which now escapes me?
They're not the same. If the previous match occurs at the end of the line, your CHECK-NEXT will match at the end of that line and then complain it's not on the next line. CHECK-EMPTY skips a newline before looking for an empty line.
>> Also, an initial CHECK-SAME has no clear meaning to me.)
>
> See above.
Here's how I see it, but I realize it's subjective. If we say that an initial CHECK-SAME matches the first line, then, to be consistent with the relationship CHECK-SAME and CHECK-NEXT have everywhere else, an initial CHECK-NEXT should skip a new line and thus match the second line. That means that, in order to match consecutive lines starting with the first line, we have:
CHECK-SAME: first line
CHECK-NEXT: second line
CHECK-NEXT: third line
But the following seems more intuitive to me:
CHECK-NEXT: first line
CHECK-NEXT: second line
CHECK-NEXT: third line
To say it more abstractly:
- CHECK-NEXT means match on the next line after the previous match.
- CHECK-SAME means match on the same line as the previous match.
If there is no previous match because this is the first directive, then that translates to:
- CHECK-NEXT means match on the next line after no match yet, and that intuitively sounds like the first line to me.
- CHECK-SAME means match on the same line as no match yet, but that sounds impossible to me.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58784/new/
https://reviews.llvm.org/D58784
More information about the llvm-commits
mailing list