[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:48:17 PDT 2019
plotfi updated this revision to Diff 192731.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59964/new/
https://reviews.llvm.org/D59964
Files:
test/tools/yaml2obj/empty.yaml
tools/yaml2obj/yaml2obj.cpp
Index: tools/yaml2obj/yaml2obj.cpp
===================================================================
--- tools/yaml2obj/yaml2obj.cpp
+++ tools/yaml2obj/yaml2obj.cpp
@@ -86,7 +86,11 @@
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: test/tools/yaml2obj/empty.yaml
===================================================================
--- /dev/null
+++ 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.192731.patch
Type: text/x-patch
Size: 931 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190328/db806e88/attachment.bin>
More information about the llvm-commits
mailing list