[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 08:45:52 PST 2018


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

- Updated comment.


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


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


More information about the llvm-commits mailing list