From 8ba61d6be3d6ccdde9a04c888dd3954164522d4a Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Tue, 14 Mar 2017 09:02:24 -0800 Subject: [PATCH] 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 --- tensorflow/compiler/xla/status.h | 24 +----------------------- tensorflow/compiler/xla/statusor.h | 11 ----------- tensorflow/core/lib/core/status.h | 6 ++++++ 3 files changed, 7 insertions(+), 34 deletions(-) diff --git a/tensorflow/compiler/xla/status.h b/tensorflow/compiler/xla/status.h index 562b2aa16d5..4eb3bf37664 100644 --- a/tensorflow/compiler/xla/status.h +++ b/tensorflow/compiler/xla/status.h @@ -21,29 +21,7 @@ limitations under the License. namespace xla { -#if defined(__clang__) -// 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 {} -}; +using tensorflow::Status; } // namespace xla diff --git a/tensorflow/compiler/xla/statusor.h b/tensorflow/compiler/xla/statusor.h index 8046a2216fe..d8cd736238c 100644 --- a/tensorflow/compiler/xla/statusor.h +++ b/tensorflow/compiler/xla/statusor.h @@ -105,7 +105,6 @@ class StatusOr { // In optimized builds, passing Status::OK here will have the effect // of passing tensorflow::error::INTERNAL as a fallback. StatusOr(Status status); // NOLINT - StatusOr(tensorflow::Status status); // NOLINT // 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 @@ -196,8 +195,6 @@ class StatusOr : public StatusOr { : StatusOr::StatusOr(std::move(value)) {} StatusOr(Status status) // NOLINT : StatusOr::StatusOr(std::move(status)) {} - StatusOr(tensorflow::Status status) // NOLINT - : StatusOr::StatusOr(std::move(status)) {} template StatusOr(StatusOr&& other) // NOLINT : StatusOr::StatusOr(std::move(other)) {} @@ -245,14 +242,6 @@ inline StatusOr::StatusOr(Status status) } } -template -inline StatusOr::StatusOr(tensorflow::Status status) - : status_(status) { - if (status_.ok()) { - status_ = internal::StatusOrHelper::HandleInvalidStatusCtorArg(); - } -} - template inline StatusOr::StatusOr(const T& value) : value_(value) { diff --git a/tensorflow/core/lib/core/status.h b/tensorflow/core/lib/core/status.h index 32b738ba1fa..e345a5dfb76 100644 --- a/tensorflow/core/lib/core/status.h +++ b/tensorflow/core/lib/core/status.h @@ -22,9 +22,15 @@ limitations under the License. #include "tensorflow/core/lib/core/error_codes.pb.h" #include "tensorflow/core/lib/core/stringpiece.h" #include "tensorflow/core/platform/logging.h" +#include "tensorflow/core/platform/macros.h" namespace tensorflow { +#if defined(__clang__) +// Only clang supports warn_unused_result as a type annotation. +class TF_MUST_USE_RESULT Status; +#endif + /// @ingroup core /// Denotes success or failure of a call in Tensorflow. class Status { -- GitLab