[PATCH] D42057: [FileCheck] - Do not crash on empty document when parsing --check-prefix.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 15 03:09:40 PST 2018


grimar updated this revision to Diff 129825.
grimar added a comment.

- Added patch context.


https://reviews.llvm.org/D42057

Files:
  test/FileCheck/check-empty2.txt
  utils/FileCheck/FileCheck.cpp


Index: utils/FileCheck/FileCheck.cpp
===================================================================
--- utils/FileCheck/FileCheck.cpp
+++ 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.
Index: test/FileCheck/check-empty2.txt
===================================================================
--- test/FileCheck/check-empty2.txt
+++ test/FileCheck/check-empty2.txt
@@ -0,0 +1,3 @@
+; Check that tool does not crash for empty file.
+
+; RUN: not FileCheck -input-file %s %s -check-prefix=A
\ No newline at end of file


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42057.129825.patch
Type: text/x-patch
Size: 774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180115/5d27566f/attachment.bin>


More information about the llvm-commits mailing list