ErrorOr<MemoryBufferRef> IRObjectFile::findBitcodeInObject(const ObjectFile &Obj) { for (const SectionRef &Sec : Obj.sections()) { if (Sec.isBitcode()) { StringRef SecContents; if (std::error_code EC = Sec.getContents(SecContents)) return EC; return MemoryBufferRef(SecContents, Obj.getFileName()); } } return object_error::bitcode_section_not_found; }
Expected<MemoryBufferRef> IRObjectFile::findBitcodeInObject(const ObjectFile &Obj) { for (const SectionRef &Sec : Obj.sections()) { if (Sec.isBitcode()) { StringRef SecContents; if (std::error_code EC = Sec.getContents(SecContents)) return errorCodeToError(EC); if (SecContents.size() <= 1) return errorCodeToError(object_error::bitcode_section_not_found); return MemoryBufferRef(SecContents, Obj.getFileName()); } } return errorCodeToError(object_error::bitcode_section_not_found); }