bool LTOModule::isBitcodeFile(const void *Mem, size_t Length) {
Expected<MemoryBufferRef> BCData = IRObjectFile::findBitcodeInMemBuffer(
MemoryBufferRef(StringRef((const char *)Mem, Length), "<mem>"));
- return bool(BCData);
+ if (!BCData) {
+ consumeError(BCData.takeError());
+ return false;
+ }
+ return true;
}
bool LTOModule::isBitcodeFile(StringRef Path) {
Expected<MemoryBufferRef> BCData = IRObjectFile::findBitcodeInMemBuffer(
BufferOrErr.get()->getMemBufferRef());
- return bool(BCData);
+ if (!BCData) {
+ consumeError(BCData.takeError());
+ return false;
+ }
+ return true;
}
bool LTOModule::isThinLTO() {
StringRef TriplePrefix) {
Expected<MemoryBufferRef> BCOrErr =
IRObjectFile::findBitcodeInMemBuffer(Buffer->getMemBufferRef());
- if (!BCOrErr)
+ if (!BCOrErr) {
+ consumeError(BCOrErr.takeError());
return false;
+ }
LLVMContext Context;
ErrorOr<std::string> TripleOrErr =
expectedToErrorOrAndEmitErrors(Context, getBitcodeTargetTriple(*BCOrErr));
std::string LTOModule::getProducerString(MemoryBuffer *Buffer) {
Expected<MemoryBufferRef> BCOrErr =
IRObjectFile::findBitcodeInMemBuffer(Buffer->getMemBufferRef());
- if (!BCOrErr)
+ if (!BCOrErr) {
+ consumeError(BCOrErr.takeError());
return "";
+ }
LLVMContext Context;
ErrorOr<std::string> ProducerOrErr = expectedToErrorOrAndEmitErrors(
Context, getBitcodeProducerString(*BCOrErr));
--- /dev/null
+; libLTO.dylib shouldn't assert on invalid inputs.
+; RUN: llvm-mc -triple=arm64-apple-ios7.0.0 -filetype=obj -o %t.o
+; RUN: llvm-ar r %t.a %t.o
+; RUN: %ld64 -lto_library %llvmshlibdir/libLTO.dylib -arch x86_64 -dylib -mllvm -O0 -o %t.dylib %t.a