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

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 28 07:21:12 PST 2019


jhenderson added a comment.

In D58784#1413769 <https://reviews.llvm.org/D58784#1413769>, @thopre wrote:

> I think the asserts should stay, they ensure that the call to CountNumNewlinesBetween is counting the newline in the right segment of text.


I'm not sure I follow how the asserts ensure this? All it shows is that the current buffer pointer is not the same as the start of the memory block it is in, i.e. that it has moved forwards.

> In any case I do not understand why the asserts search from the start of the buffer given that there is a CHECK before the CHECK-SAME and CHECK-NEXT in your examples. Could you detail a bit?

The `Buffer` contains the remainder of the text in the input following the previous match, or the entire text if it is the first match. For example, if the input string was `abc` and there was a `CHECK: a` first, `Buffer` contains `bc`, wheras `CHECK: b` would result in the `Buffer` just containing `c`. The problem is that the pattern `CHECK: {{^$}}` matches exactly 0 characters, thus the `Buffer` is the same before and after the match, and therefore the `Buffer` is still pointing at the start of the memory block.


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