[Object] Move isNotObjectErrorInvalidFileType out of header.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269848 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Lang Hames 2016-05-17 21:38:53 +00:00
parent 9c81a3f598
commit 47ad42e0ee
2 changed files with 25 additions and 30 deletions

View File

@ -72,6 +72,13 @@ private:
std::string Msg;
};
/// isNotObjectErrorInvalidFileType() is used when looping through the children
/// of an archive after calling getAsBinary() on the child and it returns an
/// llvm::Error. In the cases we want to loop through the children and ignore the
/// non-objects in the archive this is used to test the error to see if an
/// error() function needs to called on the llvm::Error.
Error isNotObjectErrorInvalidFileType(llvm::Error Err);
} // end namespace object.
} // end namespace llvm.
@ -81,34 +88,4 @@ template <>
struct is_error_code_enum<llvm::object::object_error> : std::true_type {};
}
namespace llvm {
namespace object {
// isNotObjectErrorInvalidFileType() is used when looping through the children
// of an archive after calling getAsBinary() on the child and it returns an
// llvm::Error. In the cases we want to loop through the children and ignore the
// non-objects in the archive this is used to test the error to see if an
// error() function needs to called on the llvm::Error.
static inline llvm::Error isNotObjectErrorInvalidFileType(llvm::Error Err) {
if (auto Err2 =
handleErrors(std::move(Err),
[](std::unique_ptr<ECError> M) {
// Try to handle 'M'. If successful, return a success value from
// the handler.
if (M->convertToErrorCode() == object_error::invalid_file_type)
return Error::success();
// We failed to handle 'M' - return it from the handler.
// This value will be passed back from catchErrors and
// wind up in Err2, where it will be returned from this function.
return Error(std::move(M));
}))
return Err2;
return Err;
}
} // end namespace object.
} // end namespace llvm.
#endif

View File

@ -71,3 +71,21 @@ static ManagedStatic<_object_error_category> error_category;
const std::error_category &object::object_category() {
return *error_category;
}
llvm::Error llvm::object::isNotObjectErrorInvalidFileType(llvm::Error Err) {
if (auto Err2 =
handleErrors(std::move(Err),
[](std::unique_ptr<ECError> M) {
// Try to handle 'M'. If successful, return a success value from
// the handler.
if (M->convertToErrorCode() == object_error::invalid_file_type)
return Error::success();
// We failed to handle 'M' - return it from the handler.
// This value will be passed back from catchErrors and
// wind up in Err2, where it will be returned from this function.
return Error(std::move(M));
}))
return Err2;
return Err;
}