Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLVM 4.0] rustllvm archive support #38196

Merged
merged 1 commit into from
Dec 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/rustllvm/ArchiveWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,20 @@ LLVMRustArchiveIteratorFree(LLVMRustArchiveIteratorRef rai) {

extern "C" const char*
LLVMRustArchiveChildName(LLVMRustArchiveChildConstRef child, size_t *size) {
#if LLVM_VERSION_GE(4, 0)
Expected<StringRef> name_or_err = child->getName();
if (!name_or_err) {
// rustc_llvm currently doesn't use this error string, but it might be useful
// in the future, and in the mean time this tells LLVM that the error was
// not ignored and that it shouldn't abort the process.
LLVMRustSetLastError(toString(name_or_err.takeError()).c_str());
return NULL;
}
#else
ErrorOr<StringRef> name_or_err = child->getName();
if (name_or_err.getError())
return NULL;
#endif
StringRef name = name_or_err.get();
*size = name.size();
return name.data();
Expand All @@ -174,11 +185,19 @@ LLVMRustArchiveChildName(LLVMRustArchiveChildConstRef child, size_t *size) {
extern "C" const char*
LLVMRustArchiveChildData(LLVMRustArchiveChildRef child, size_t *size) {
StringRef buf;
#if LLVM_VERSION_GE(4, 0)
Expected<StringRef> buf_or_err = child->getBuffer();
if (!buf_or_err) {
LLVMRustSetLastError(toString(buf_or_err.takeError()).c_str());
return NULL;
}
#else
ErrorOr<StringRef> buf_or_err = child->getBuffer();
if (buf_or_err.getError()) {
LLVMRustSetLastError(buf_or_err.getError().message().c_str());
return NULL;
}
#endif
buf = buf_or_err.get();
*size = buf.size();
return buf.data();
Expand Down