提交 8ba61d6b 编写于 作者: J Justin Lebar 提交者: TensorFlower Gardener

Make tensorflow::Status TF_MUST_USE_RESULT, and alias xla::Status to tensorflow::Status.

To make this work, we have to add a few IgnoreError() calls to
TensorFlow.
Change: 150080076
上级 dfa7d2d2
...@@ -21,29 +21,7 @@ limitations under the License. ...@@ -21,29 +21,7 @@ limitations under the License.
namespace xla { namespace xla {
#if defined(__clang__) using tensorflow::Status;
// Only clang supports warn_unused_result as a type annotation.
class TF_MUST_USE_RESULT Status;
#endif
// Simple wrapper around tensorflow::Status that has the MUST_USE_RESULT
// annotation above. When tensorflow::Status adopts this annotation, this can
// simply become a "using tensorflow::Status".
class Status : public tensorflow::Status {
public:
static Status OK() { return tensorflow::Status::OK(); }
// Note: implicit constructor.
Status(tensorflow::Status other) : tensorflow::Status(other) {}
Status() : tensorflow::Status() {}
Status(tensorflow::error::Code code, tensorflow::StringPiece msg)
: tensorflow::Status(code, msg) {}
// Ignores any errors. This method is a nop that can be used to suppress
// compiler errors when a Status value is intentially ignored.
void IgnoreError() const {}
};
} // namespace xla } // namespace xla
......
...@@ -105,7 +105,6 @@ class StatusOr { ...@@ -105,7 +105,6 @@ class StatusOr {
// In optimized builds, passing Status::OK here will have the effect // In optimized builds, passing Status::OK here will have the effect
// of passing tensorflow::error::INTERNAL as a fallback. // of passing tensorflow::error::INTERNAL as a fallback.
StatusOr(Status status); // NOLINT StatusOr(Status status); // NOLINT
StatusOr(tensorflow::Status status); // NOLINT
// Construct a new StatusOr with the given value. If T is a plain pointer, // Construct a new StatusOr with the given value. If T is a plain pointer,
// value must not be NULL. After calling this constructor, calls to // value must not be NULL. After calling this constructor, calls to
...@@ -196,8 +195,6 @@ class StatusOr<T, false> : public StatusOr<T, true> { ...@@ -196,8 +195,6 @@ class StatusOr<T, false> : public StatusOr<T, true> {
: StatusOr<T, true>::StatusOr(std::move(value)) {} : StatusOr<T, true>::StatusOr(std::move(value)) {}
StatusOr(Status status) // NOLINT StatusOr(Status status) // NOLINT
: StatusOr<T, true>::StatusOr(std::move(status)) {} : StatusOr<T, true>::StatusOr(std::move(status)) {}
StatusOr(tensorflow::Status status) // NOLINT
: StatusOr<T, true>::StatusOr(std::move(status)) {}
template <typename U> template <typename U>
StatusOr(StatusOr<U>&& other) // NOLINT StatusOr(StatusOr<U>&& other) // NOLINT
: StatusOr<T, true>::StatusOr(std::move(other)) {} : StatusOr<T, true>::StatusOr(std::move(other)) {}
...@@ -245,14 +242,6 @@ inline StatusOr<T, CopyConstructible>::StatusOr(Status status) ...@@ -245,14 +242,6 @@ inline StatusOr<T, CopyConstructible>::StatusOr(Status status)
} }
} }
template <typename T, bool CopyConstructible>
inline StatusOr<T, CopyConstructible>::StatusOr(tensorflow::Status status)
: status_(status) {
if (status_.ok()) {
status_ = internal::StatusOrHelper::HandleInvalidStatusCtorArg();
}
}
template <typename T, bool CopyConstructible> template <typename T, bool CopyConstructible>
inline StatusOr<T, CopyConstructible>::StatusOr(const T& value) inline StatusOr<T, CopyConstructible>::StatusOr(const T& value)
: value_(value) { : value_(value) {
......
...@@ -22,9 +22,15 @@ limitations under the License. ...@@ -22,9 +22,15 @@ limitations under the License.
#include "tensorflow/core/lib/core/error_codes.pb.h" #include "tensorflow/core/lib/core/error_codes.pb.h"
#include "tensorflow/core/lib/core/stringpiece.h" #include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
namespace tensorflow { namespace tensorflow {
#if defined(__clang__)
// Only clang supports warn_unused_result as a type annotation.
class TF_MUST_USE_RESULT Status;
#endif
/// @ingroup core /// @ingroup core
/// Denotes success or failure of a call in Tensorflow. /// Denotes success or failure of a call in Tensorflow.
class Status { class Status {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册