diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -230,11 +230,12 @@ inputFiles.push_back(make(mbref)); break; case file_magic::tapi_file: { - llvm::Expected> result = - TextAPIReader::get(mbref); - if (!result) + Expected> result = TextAPIReader::get(mbref); + if (!result) { + error("could not load TAPI file at " + mbref.getBufferIdentifier() + + ": " + toString(result.takeError())); return; - + } inputFiles.push_back(make(**result)); break; } diff --git a/lld/test/MachO/invalid/invalid-stub.s b/lld/test/MachO/invalid/invalid-stub.s new file mode 100644 --- /dev/null +++ b/lld/test/MachO/invalid/invalid-stub.s @@ -0,0 +1,12 @@ +# REQUIRES: x86 +# RUN: mkdir -p %t +# RUN: echo "--- !tapi-tbd-v3" > %t/libinvalidYAML.tbd +# RUN: echo "invalid YAML" >> %t/libinvalidYAML.tbd +# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %s -o %t/test.o +# RUN: not lld -flavor darwinnew -Z -L%t -linvalidYAML %t/test.o -o %t/test -Z 2>&1 | FileCheck %s -DDIR=%t + +# CHECK: could not load TAPI file at [[DIR]]/libinvalidYAML.tbd: malformed file + +.globl _main +_main: + ret