[PATCH] D59964: [yaml2obj] Fixing opening empty yaml files.

Puyan Lotfi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 28 15:54:07 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL357219: [yaml2obj] Fixing opening empty yaml files. (authored by zer0, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59964?vs=192731&id=192733#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59964/new/

https://reviews.llvm.org/D59964

Files:
  llvm/trunk/test/tools/yaml2obj/empty.yaml
  llvm/trunk/tools/yaml2obj/yaml2obj.cpp


Index: llvm/trunk/tools/yaml2obj/yaml2obj.cpp
===================================================================
--- llvm/trunk/tools/yaml2obj/yaml2obj.cpp
+++ llvm/trunk/tools/yaml2obj/yaml2obj.cpp
@@ -86,7 +86,10 @@
   if (!Buf)
     return 1;
 
-  yaml::Input YIn(Buf.get()->getBuffer());
+  StringRef Buffer = Buf.get()->getBuffer();
+  if (Buffer.trim().size() == 0)
+    error("yaml2obj: Error opening '" + Input + "': Empty File.");
+  yaml::Input YIn(Buffer);
 
   int Res = convertYAML(YIn, Out->os());
   if (Res == 0)
Index: llvm/trunk/test/tools/yaml2obj/empty.yaml
===================================================================
--- llvm/trunk/test/tools/yaml2obj/empty.yaml
+++ llvm/trunk/test/tools/yaml2obj/empty.yaml
@@ -0,0 +1,5 @@
+# RUN: echo "" | not yaml2obj 2>&1 | FileCheck %s
+# RUN: echo -n "" | not yaml2obj 2>&1 | FileCheck %s
+# RUN: echo " " | not yaml2obj 2>&1 | FileCheck %s
+# RUN: echo "  " | not yaml2obj 2>&1 | FileCheck %s
+# CHECK: yaml2obj: Error opening '-': Empty File.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59964.192733.patch
Type: text/x-patch
Size: 1016 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190328/76065ba3/attachment.bin>


More information about the llvm-commits mailing list