diff --git a/third_party/fuchsia/generate_fuchsia_patch.py b/third_party/fuchsia/generate_fuchsia_patch.py index 0fb361f776..3006d81ac2 100755 --- a/third_party/fuchsia/generate_fuchsia_patch.py +++ b/third_party/fuchsia/generate_fuchsia_patch.py @@ -142,11 +142,36 @@ def _patch_invoke(file: Path, text: str) -> str: ) +def _ignore_errors(file: Path, text: str) -> str: + # Only patch result.h for now + if file.name != 'result.h': + return text + + text = _add_include_before_namespace(text, 'pw_preprocessor/compiler.h') + + # Push the diagnostics before the namespace. + new_lines = ['', 'PW_MODIFY_DIAGNOSTICS_PUSH();'] + for clang_diag in ['-Wshadow-field-in-constructor']: + new_lines.append( + f'PW_MODIFY_DIAGNOSTIC_CLANG(ignored, "{clang_diag}");' + ) + new_lines.append('') + new_lines.append('') + + text = text.replace('\nnamespace ', '\n'.join(new_lines) + 'namespace ', 1) + + # Pop the diagnostics before the include guard's #endif + split_text = text.rsplit('\n#endif', 1) + text = '\nPW_MODIFY_DIAGNOSTICS_POP();\n\n#endif'.join(split_text) + return text + + def _patch(file: Path) -> str | None: text = file.read_text() updated = _patch_assert(text) updated = _patch_constinit(updated) updated = _patch_invoke(file, updated) + updated = _ignore_errors(file, updated) return None if text == updated else updated diff --git a/third_party/fuchsia/pigweed_adaptations.patch b/third_party/fuchsia/pigweed_adaptations.patch index fd6bcd58c6..4b9e6f6593 100644 --- a/third_party/fuchsia/pigweed_adaptations.patch +++ b/third_party/fuchsia/pigweed_adaptations.patch @@ -1,4 +1,4 @@ -# Copyright 2023 The Pigweed Authors +# Copyright 2024 The Pigweed 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 @@ -42,7 +42,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/internal/funct static const target_ops ops; -@@ -507,7 +509,8 @@ class function_base void copy_shared_target_to(SharedFunction& copy) { copy.destroy_target(); @@ -61,7 +61,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/internal/funct shared_target_type::copy_shared_ptr(base::bits(), copy.bits()); copy.set_ops(base::ops()); } -@@ -567,7 +570,7 @@ class function_base::ops.target_type_id(nullptr, &target_type::ops) != base::target_type_id()) { @@ -70,6 +70,37 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/internal/funct } } }; +diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/internal/result.h b/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/internal/result.h +--- a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/internal/result.h ++++ b/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/internal/result.h +@@ -14,6 +14,11 @@ + #include + #include + ++#include "pw_preprocessor/compiler.h" ++ ++PW_MODIFY_DIAGNOSTICS_PUSH(); ++PW_MODIFY_DIAGNOSTIC_CLANG(ignored, "-Wshadow-field-in-constructor"); ++ + namespace fit { + + // Forward declarations. +@@ -60,7 +65,7 @@ struct template_matcher { + }; + + template class U, typename = bool> +-struct is_match : decltype(template_matcher::match(std::declval())) {}; ++struct is_match : decltype(template_matcher::match(std::declval())){}; + + template class U> + struct is_match>> : std::false_type {}; +@@ -441,4 +446,6 @@ using storage = storage_type, E, Ts...>; + } // namespace internal + } // namespace fit + ++PW_MODIFY_DIAGNOSTICS_POP(); ++ + #endif // LIB_FIT_INTERNAL_RESULT_H_ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/nullable.h b/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/nullable.h --- a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/nullable.h +++ b/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/nullable.h @@ -115,16 +146,20 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/nullable.h b/t diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h --- a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h +++ b/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h -@@ -55,6 +55,8 @@ +@@ -55,6 +55,12 @@ // // fit::result with a different "success" vluae type (or // // fit::result). +#include "pw_assert/assert.h" ++#include "pw_preprocessor/compiler.h" ++ ++PW_MODIFY_DIAGNOSTICS_PUSH(); ++PW_MODIFY_DIAGNOSTIC_CLANG(ignored, "-Wshadow-field-in-constructor"); + namespace fit { // Convenience type to indicate failure without elaboration. -@@ -286,25 +288,25 @@ class [[nodiscard]] result { +@@ -286,25 +292,25 @@ class [[nodiscard]] result { if (is_error()) { return storage_.error_or_value.error; } @@ -154,7 +189,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Moves the underlying error and returns it as an instance of fit::error, simplifying -@@ -315,7 +317,7 @@ class [[nodiscard]] result { +@@ -315,7 +321,7 @@ class [[nodiscard]] result { if (is_error()) { return error(std::move(storage_.error_or_value.error)); } @@ -163,7 +198,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Accessors for the underlying value. -@@ -325,25 +327,25 @@ class [[nodiscard]] result { +@@ -325,25 +331,25 @@ class [[nodiscard]] result { if (is_ok()) { return storage_.error_or_value.value; } @@ -193,7 +228,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Moves the underlying value and returns it as an instance of fit::success, simplifying -@@ -354,7 +356,7 @@ class [[nodiscard]] result { +@@ -354,7 +360,7 @@ class [[nodiscard]] result { if (is_ok()) { return success(std::move(storage_.error_or_value.value)); } @@ -202,7 +237,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Contingent accessors for the underlying value. -@@ -383,13 +385,13 @@ class [[nodiscard]] result { +@@ -383,13 +389,13 @@ class [[nodiscard]] result { if (is_ok()) { return ::fit::internal::arrow_operator::forward(storage_.error_or_value.value); } @@ -218,7 +253,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Accessors for the underlying value. This is a syntax sugar for value(). -@@ -412,7 +414,7 @@ class [[nodiscard]] result { +@@ -412,7 +418,7 @@ class [[nodiscard]] result { storage_.error_or_value.error += std::move(error.value_); return *this; } @@ -227,7 +262,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Maps a result to a result by transforming the error through -@@ -523,25 +525,25 @@ class [[nodiscard]] result { +@@ -523,25 +529,25 @@ class [[nodiscard]] result { if (is_error()) { return storage_.error_or_value.error; } @@ -257,7 +292,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Moves the underlying error and returns it as an instance of fit::error, simplifying -@@ -552,7 +554,7 @@ class [[nodiscard]] result { +@@ -552,7 +558,7 @@ class [[nodiscard]] result { if (is_error()) { return error(std::move(storage_.error_or_value.error)); } @@ -266,7 +301,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Augments the error value of the result with the given value. The operator E::operator+=(F) must -@@ -566,7 +568,7 @@ class [[nodiscard]] result { +@@ -566,7 +572,7 @@ class [[nodiscard]] result { storage_.error_or_value.error += std::move(error.value_); return *this; } @@ -275,6 +310,13 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Maps a result to a result by transforming the error through +@@ -801,4 +807,6 @@ constexpr bool operator>=(const T& lhs, const result& rhs) { + + } // namespace fit + ++PW_MODIFY_DIAGNOSTICS_POP(); ++ + #endif // LIB_FIT_RESULT_H_ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/test/function_tests.cc b/third_party/fuchsia/repo/sdk/lib/fit/test/function_tests.cc --- a/third_party/fuchsia/repo/sdk/lib/fit/test/function_tests.cc +++ b/third_party/fuchsia/repo/sdk/lib/fit/test/function_tests.cc