Skip to content

Commit

Permalink
Status tweaks to reduce binary size.
Browse files Browse the repository at this point in the history
  • Loading branch information
benvanik committed Aug 17, 2020
1 parent 5c11733 commit 10b2711
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 0 additions & 1 deletion iree/base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":api_hdrs",
":api_util",
":tracing",
],
)
Expand Down
1 change: 0 additions & 1 deletion iree/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ iree_cc_library(
"api_time.cc"
DEPS
::api_hdrs
::api_util
::tracing
PUBLIC
)
Expand Down
4 changes: 4 additions & 0 deletions iree/base/internal/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ class SourceLocation {

// If a function takes an `iree::SourceLocation` parameter, pass this as the
// argument.
#if IREE_STATUS_FEATURES == 0
#define IREE_LOC ::iree::SourceLocation(0, NULL)
#else
#define IREE_LOC ::iree::SourceLocation(__LINE__, __FILE__)
#endif // IREE_STATUS_FEATURES == 0

enum class StatusCode : uint32_t {
kOk = IREE_STATUS_OK,
Expand Down
8 changes: 8 additions & 0 deletions iree/base/internal/status_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,21 @@ inline StatusBuilder& StatusBuilder::operator=(const StatusBuilder& sb) {
return *this;
}

// Disable << streaming when status messages are disabled.
#if (IREE_STATUS_FEATURES & IREE_STATUS_FEATURE_ANNOTATIONS) == 0
template <typename T>
StatusBuilder& StatusBuilder::operator<<(const T& value) & {
return *this;
}
#else
template <typename T>
StatusBuilder& StatusBuilder::operator<<(const T& value) & {
if (status_.ok()) return *this;
if (rep_ == nullptr) rep_ = std::make_unique<Rep>();
rep_->stream << value;
return *this;
}
#endif // (IREE_STATUS_FEATURES & IREE_STATUS_FEATURE_ANNOTATIONS) == 0

template <typename T>
StatusBuilder&& StatusBuilder::operator<<(const T& value) && {
Expand Down

0 comments on commit 10b2711

Please sign in to comment.