Index: llvm/trunk/test/FileCheck/check-empty2.txt =================================================================== --- llvm/trunk/test/FileCheck/check-empty2.txt +++ llvm/trunk/test/FileCheck/check-empty2.txt @@ -0,0 +1,4 @@ +; Check that tool does not crash when there is no any data +; in file after -check-prefix=PREFIX option. + +; RUN: not FileCheck -input-file %s %s -check-prefix=A \ No newline at end of file Index: llvm/trunk/utils/FileCheck/FileCheck.cpp =================================================================== --- llvm/trunk/utils/FileCheck/FileCheck.cpp +++ llvm/trunk/utils/FileCheck/FileCheck.cpp @@ -718,6 +718,9 @@ } static Check::CheckType FindCheckType(StringRef Buffer, StringRef Prefix) { + if (Buffer.size() <= Prefix.size()) + return Check::CheckNone; + char NextChar = Buffer[Prefix.size()]; // Verify that the : is present after the prefix.