[PATCH] D58784: [FileCheck]Remove assertions that prevent matching an empty string at file start before CHECK-NEXT/SAME

Paul Robinson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 28 17:42:30 PST 2019


probinson added a comment.

In D58784#1414321 <https://reviews.llvm.org/D58784#1414321>, @jdenny wrote:

> In D58784#1414106 <https://reviews.llvm.org/D58784#1414106>, @probinson wrote:
>
> > FTR, the `CHECK: {{^$}}` is ensuring the first line is empty? I see that CHECK-EMPTY isn't allowed as the first directive, unfortunately.
>
>
> This directive looks for the next empty line, even if that's not the first line.  Interestingly, when it's not the first directive, its search range starts after the previous match, so if the remainder of the previous match's line is empty (even if the full line is not empty), it'll match there.


Ah right.

> 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.

> Looking at the test suite, we also have what appears to be an equivalent to what an initial CHECK-NEXT should do (the "next" line is the first line in that case):
> 
>   CHECK: {{^}}
>   CHECK-SAME: some text
> 
> 
> Maybe we should just permit initial CHECK-NEXT and CHECK-EMPTY rather requiring people to use these hacks.

SGTM.

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?

> (Putting them after a CHECK-DAG is probably a mistake though.

Yep.

> Also, an initial CHECK-SAME has no clear meaning to me.)

See above.


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