Index: lib/Support/FileCheck.cpp =================================================================== --- lib/Support/FileCheck.cpp +++ lib/Support/FileCheck.cpp @@ -1114,12 +1114,6 @@ Twine(Pat.getCheckTy() == Check::CheckEmpty ? "-EMPTY" : "-NEXT"); // Count the number of newlines between the previous match and this one. - assert(Buffer.data() != - SM.getMemoryBuffer(SM.FindBufferContainingLoc( - SMLoc::getFromPointer(Buffer.data()))) - ->getBufferStart() && - "CHECK-NEXT and CHECK-EMPTY can't be the first check in a file"); - const char *FirstNewLine = nullptr; unsigned NumNewLines = CountNumNewlinesBetween(Buffer, FirstNewLine); @@ -1155,12 +1149,6 @@ return false; // Count the number of newlines between the previous match and this one. - assert(Buffer.data() != - SM.getMemoryBuffer(SM.FindBufferContainingLoc( - SMLoc::getFromPointer(Buffer.data()))) - ->getBufferStart() && - "CHECK-SAME can't be the first check in a file"); - const char *FirstNewLine = nullptr; unsigned NumNewLines = CountNumNewlinesBetween(Buffer, FirstNewLine); Index: test/FileCheck/empty-regex-match-at-start.txt =================================================================== --- test/FileCheck/empty-regex-match-at-start.txt +++ test/FileCheck/empty-regex-match-at-start.txt @@ -0,0 +1,16 @@ +some text +more text + +; RUN: FileCheck %s --check-prefix=NEXT --input-file=%s +; NEXT: {{^}} +; NEXT-NEXT: more text + +; RUN: FileCheck %s --check-prefix=SAME --input-file=%s +; SAME: {{^}} +; SAME-SAME: some text + +; RUN: echo "" > %t +; RUN: echo "" >> %t +; RUN: FileCheck %s --check-prefix=EMPTY --input-file=%t +; EMPTY: {{^}} +; EMPTY-EMPTY: