No public description PiperOrigin-RevId: 955392305
diff --git a/common/BUILD b/common/BUILD index fc9c809..bbdb792 100644 --- a/common/BUILD +++ b/common/BUILD
@@ -189,7 +189,10 @@ cc_library( name = "status_macros", - hdrs = ["status_macros.h"], + hdrs = [ + "fuzztest_status_macros.h", + "status_macros.h", + ], deps = [ ":logging", "@abseil-cpp//absl/base:core_headers",
diff --git a/common/fuzztest_status_macros.h b/common/fuzztest_status_macros.h new file mode 100644 index 0000000..b88f0f1 --- /dev/null +++ b/common/fuzztest_status_macros.h
@@ -0,0 +1,48 @@ +// Copyright 2026 The FuzzTest Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef FUZZTEST_COMMON_FUZZTEST_STATUS_MACROS_H_ +#define FUZZTEST_COMMON_FUZZTEST_STATUS_MACROS_H_ + +#include "absl/base/optimization.h" + +// If `status_expr` (an expression of type `absl::Status`) is not OK then return +// it from the current function. Otherwise, do nothing. +#define FUZZTEST_RETURN_IF_NOT_OK(status_expr) \ + do { \ + const absl::Status status_value = (status_expr); \ + if (ABSL_PREDICT_FALSE(!status_value.ok())) { \ + return status_value; \ + } \ + } while (false) + +// Internal helpers for concatenating macro values. +#define FUZZTEST_STATUS_MACROS_IMPL_CONCAT_IMPL_(x, y) x##y +#define FUZZTEST_STATUS_MACROS_IMPL_CONCAT_(x, y) \ + FUZZTEST_STATUS_MACROS_IMPL_CONCAT_IMPL_(x, y) + +// Assigns `dest` to the value contained within the `absl::StatusOr<T> src` if +// `src.ok()`, otherwise, returns `src.status()` from the current function. +#define FUZZTEST_ASSIGN_OR_RETURN_IF_NOT_OK(dest, src) \ + FUZZTEST_ASSIGN_OR_RETURN_IF_NOT_OK_IMPL_( \ + FUZZTEST_STATUS_MACROS_IMPL_CONCAT_(value_or_, __LINE__), dest, src) + +#define FUZZTEST_ASSIGN_OR_RETURN_IF_NOT_OK_IMPL_(value_or, dest, src) \ + auto value_or = (src); \ + if (ABSL_PREDICT_FALSE(!value_or.ok())) { \ + return std::move(value_or).status(); \ + } \ + dest = std::move(value_or).value() + +#endif // FUZZTEST_COMMON_FUZZTEST_STATUS_MACROS_H_
diff --git a/common/status_macros.h b/common/status_macros.h index e3e26c5..469adf6 100644 --- a/common/status_macros.h +++ b/common/status_macros.h
@@ -21,33 +21,13 @@ #include "absl/base/attributes.h" #include "absl/base/optimization.h" +#include "./common/fuzztest_status_macros.h" #include "./common/logging.h" -// If `status_expr` (an expression of type `absl::Status`) is not OK then return -// it from the current function. Otherwise, do nothing. -#define RETURN_IF_NOT_OK(status_expr) \ - do { \ - const absl::Status status_value = (status_expr); \ - if (ABSL_PREDICT_FALSE(!status_value.ok())) { \ - return status_value; \ - } \ - } while (false) +#define RETURN_IF_NOT_OK(status_expr) FUZZTEST_RETURN_IF_NOT_OK(status_expr) -// Assigns `dest` to the value contained within the `absl::StatusOr<T> src` if -// `src.ok()`, otherwise, returns `src.status()` from the current function. #define ASSIGN_OR_RETURN_IF_NOT_OK(dest, src) \ - ASSIGN_OR_RETURN_IF_NOT_OK_IMPL_( \ - CHECKS_INTERNAL_CONCAT_(value_or_, __LINE__), dest, src) -#define ASSIGN_OR_RETURN_IF_NOT_OK_IMPL_(value_or, dest, src) \ - auto value_or = (src); \ - if (ABSL_PREDICT_FALSE(!value_or.ok())) { \ - return std::move(value_or).status(); \ - } \ - dest = std::move(value_or).value() - -// Internal helper for concatenating macro values. -#define CHECKS_INTERNAL_CONCAT_IMPL_(x, y) x##y -#define CHECKS_INTERNAL_CONCAT_(x, y) CHECKS_INTERNAL_CONCAT_IMPL_(x, y) + FUZZTEST_ASSIGN_OR_RETURN_IF_NOT_OK(dest, src) namespace fuzztest::internal { template <typename T>