Skip to content

Commit

Permalink
Fixed bug for archives
Browse files Browse the repository at this point in the history
  • Loading branch information
JDevlieghere committed Oct 7, 2016
1 parent 366c1f3 commit cce7854
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions lib/src/BitcodeRetriever.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "llvm/Object/MachOUniversal.h"

#include <algorithm>
#include <iostream>
#include <memory>
#include <string>

Expand Down Expand Up @@ -55,9 +56,8 @@ std::vector<std::unique_ptr<BitcodeContainer>> BitcodeRetriever::GetBitcodeConta
bitcodeContainers.push_back(std::move(container));
}
continue;
} else {
// Calling operator bool() is not sufficient.
machOObject.takeError();
} else if (auto e = machOObject.takeError()) {
llvm::consumeError(std::move(e));
}

Expected<std::unique_ptr<Archive>> archive = object.getAsArchive();
Expand All @@ -67,9 +67,8 @@ std::vector<std::unique_ptr<BitcodeContainer>> BitcodeRetriever::GetBitcodeConta
bitcodeContainers.reserve(bitcodeContainers.size() + containers.size());
std::move(std::begin(containers), std::end(containers), std::back_inserter(bitcodeContainers));
continue;
} else {
// Calling operator bool() is not sufficient.
archive.takeError();
} else if (auto e = archive.takeError()) {
llvm::consumeError(std::move(e));
}

throw EbcError("Unrecognized MachO universal binary");
Expand Down Expand Up @@ -99,6 +98,10 @@ std::vector<std::unique_ptr<BitcodeContainer>> BitcodeRetriever::GetBitcodeConta
Error err;
auto children = archive.children(err);

if (err) {
throw EbcError("Couldn't get children from archive " + archive.getFileName().str());
}

auto bitcodeContainers = std::vector<std::unique_ptr<BitcodeContainer>>();
for (const auto &child : children) {
auto childOrErr = child.getAsBinary();
Expand Down
2 changes: 1 addition & 1 deletion tool/ebcutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int main(int argc, char* argv[]) {
TCLAP::ValueArg<std::string> prefixArg("p", "prefix", "Prefix for bitcode files", false, "", "string");
cmd.add(prefixArg);

TCLAP::UnlabeledValueArg<std::string> fileArg("File", "Library or object file", false, "", "file");
TCLAP::UnlabeledValueArg<std::string> fileArg("File", "Library or object file", true, "", "file");
cmd.add(fileArg);

cmd.parse(argc, argv);
Expand Down

0 comments on commit cce7854

Please sign in to comment.