mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
[yaml2obj] Fixing opening empty yaml files.
Essentially echo "" | yaml2obj crashes. This patch attempts to trim whitespace and determine if the yaml string in the file is empty or not. If the input is empty then it will not properly print out an error message and return an error code. Differential Revision: https://reviews.llvm.org/D59964 A test/tools/yaml2obj/empty.yaml M tools/yaml2obj/yaml2obj.cpp llvm-svn: 357219
This commit is contained in:
parent
9afdfb25b8
commit
06b7be771a
5
test/tools/yaml2obj/empty.yaml
Normal file
5
test/tools/yaml2obj/empty.yaml
Normal file
@ -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.
|
@ -86,7 +86,10 @@ int main(int argc, char **argv) {
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user