Skip to content

chore: remove always-defined FIREBASE_USE_MOVE_OPERATORS and FIREBASE_USE_STD_FUNCTION macros - #1995

Merged
AustinBenoit merged 4 commits into
mainfrom
cleanup/remove-always-defined-macros
Dec 2, 2026
Merged

AustinBenoit merged 4 commits into
mainfrom
cleanup/remove-always-defined-macros

Conversation

@AustinBenoit

@AustinBenoit AustinBenoit commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follow-up cleanup from #1958.

Removes the now unconditionally defined FIREBASE_USE_MOVE_OPERATORS and FIREBASE_USE_STD_FUNCTION macros from app/src/include/firebase/internal/common.h and unwraps all 90 #if/#ifdef guards across 72 files in app, auth, database, functions, and storage.

Companion Unity SWIG PR (hiding move constructors/assignment operators in Unity .i files instead of adding #ifndef SWIG to C++ headers): firebase/firebase-unity-sdk#1580

Summary of Changes

  • Macro Removal (app/src/include/firebase/internal/common.h):
    • Removed #define FIREBASE_USE_MOVE_OPERATORS, #define FIREBASE_USE_STD_FUNCTION, and the follow-up TODO comment.
    • Retained #include <utility> in common.h for transitive compatibility.
  • Mechanical Guard Unwrapping (72 files across app/, auth/, database/, functions/, storage/):
    • Removed all #if defined(FIREBASE_USE_MOVE_OPERATORS), #ifdef FIREBASE_USE_MOVE_OPERATORS, #if defined(FIREBASE_USE_STD_FUNCTION), #ifdef FIREBASE_USE_STD_FUNCTION, and || defined(DOXYGEN) guards and matching #endif directives with no logic changes.
    • Moved unwrapped <functional> / <utility> includes into standard Google C++ include order (callback.h, future.h, future_impl.h, transaction.h) and added direct #include <utility> in jobject_reference.cc, callable_result.h, intrusive_list.h, and intrusive_list_test.cc.
  • Doxygen Comment Fixes (Newly Exposed by Guard Removal):
    • Updated FutureBase::operator=(FutureBase&&) doc comment in app/src/include/firebase/future.h (previously copy-pasted as "Copy an untyped future.") and converted MutableData::operator=(MutableData&&) comment in database/src/include/firebase/database/mutable_data.h from // to /// so generated_docs_check stays clean.

Testing

Tested Locally (Linux x64 Workstation)

  • Macro Audit: Confirmed git grep "FIREBASE_USE_MOVE_OPERATORS\|FIREBASE_USE_STD_FUNCTION" returns 0 matches across firebase-cpp-sdk (and 0 matches in firebase-unity-sdk).
  • Desktop CMake Build & Unit Tests: Built all non-Firestore desktop targets and unit tests (-DFIREBASE_CPP_BUILD_TESTS=ON -DFIREBASE_INCLUDE_FIRESTORE=OFF -DFIREBASE_USE_BORINGSSL=OFF); all 98/98 ctest suites passed (including all 11 affected suites re-run after final edits).
  • Public Header Compilation: Compiled all modified public headers with g++ and clang++-19 (-fsyntax-only -Wall -Wextra -Werror) across -std=c++17, -std=c++20, -std=c++23, and -DINTERNAL_EXPERIMENTAL with 0 warnings/errors.
  • Android NDK Cross-Compile (Syntax Check): Cross-compiled all 16 modified Android and common .cc files with aarch64-linux-android21-clang++ -std=c++17 on both NDK 23.2.8568313 and NDK 28.2.13676358 with 0 errors.
  • Downstream Unity SWIG Differential Check: Verified with SWIG 4.4.1 against chore(swig): ignore C++ move constructors and assignment operators in .i files firebase-unity-sdk#1580 across all 10 firebase-unity-sdk .i modules — 0 functional C# diffs.
  • Formatting, Doxygen & Copyright: 0 Doxygen warnings across all modified public headers (docs/Doxyfile), bash scripts/gha/check_copyright.sh -g passed, and GitHub Actions file_format_check / generated_docs_check / Desktop / Android / iOS builds passed.

Not Tested Locally (Covered by GitHub Actions CI)

  • Full native builds on Windows (MSVC), macOS, iOS/tvOS (Xcode), full Gradle Android AAR packaging, Firestore desktop build, and live Integration tests against Firebase backends are validated by GitHub Actions CI.

Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

Notes

  • Bug fixes and feature changes require an update to the Release Notes section of release_build_files/readme.md.
  • Read the contribution guidelines CONTRIBUTING.md.
  • Changes to the public API require an internal API review. If you'd like to help us make Firebase APIs better, please propose your change in a feature request so that we can discuss it together.

…_USE_STD_FUNCTION macros

- Remove FIREBASE_USE_MOVE_OPERATORS and FIREBASE_USE_STD_FUNCTION definitions and follow-up TODO from app/src/include/firebase/internal/common.h (following #1958).
- Unwrap all 90 #if/#ifdef guards across 72 files in app, auth, database, functions, and storage, keeping #ifndef SWIG on SWIG-parsed public headers so Unity SWIG output is unchanged.
- Fix include ordering for unwrapped <functional>/<utility> headers and add missing #include <utility> in intrusive_list.h, intrusive_list_test.cc, jobject_reference.cc, and callable_result.h.
- Fix newly Doxygen-exposed move-assignment comments in future.h and mutable_data.h.
- Fix newly activated intrusive_list/intrusive_list_node move-assignment safety (self-move guard, clear() before overwrite, direct move-ctor member initialization) with regression tests.
@AustinBenoit AustinBenoit added skip-release-notes Skip release notes check tests-requested: full Trigger a FULL set of integration tests (uses expanded test matrix). labels Nov 26, 2026
@github-actions github-actions Bot added tests: in-progress This PR's integration tests are in progress. and removed tests-requested: full Trigger a FULL set of integration tests (uses expanded test matrix). labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

❌  Integration test FAILED

Requested by @AustinBenoit on commit cdd475e
Last updated: Wed Dec 2 08:56 PST 2026
View integration test log & download artifacts

Failures Configs
firestore [TEST] [FAILURE] [Android] [1/3 os: ubuntu] [1/2 android_device: emulator_ftl_target]
(20 failed tests)  FirestoreTest.TestDocumentSnapshotEventsForAdd
  FirestoreTest.TestQuerySnapshotEventsForAdd
  FirestoreTest.TestQuerySnapshotEventsForChange
  NumericTransformsTest.CreateDocumentWithIncrement
  NumericTransformsTest.IntegerIncrementWithExistingDouble
  NumericTransformsTest.IntegerIncrementWithExistingInteger
  NumericTransformsTest.MergeOnNonExistingDocumentWithIncrement
  NumericTransformsTest.MultipleDoubleIncrements
  QueryTest.TestCanListenForTheSameQueryWithDifferentOptions
  ServerTimestampTest.TestServerTimestampsCanRetainPreviousValueThroughConsecutiveUpdates
  ServerTimestampTest.TestServerTimestampsCanReturnPreviousValueOfDifferentType
  ServerTimestampTest.TestServerTimestampsUsesPreviousValueFromLocalMutation
  ServerTimestampTest.TestServerTimestampsWorkViaTransactionSet
  ServerTimestampTest.TestServerTimestampsWorkViaTransactionUpdate
  ServerTimestampTest.TestServerTimestampsWorkViaUpdate
  SmokeTest.TestObservesNewDocument
  ValidationTest.QueriesCannotBeSortedByAnUncommittedServerTimestamp
  WriteBatchTest.TestBatchesCommitAtomicallyRaisingCorrectEvents
  WriteBatchTest.TestCanWriteTheSameDocumentMultipleTimes
  WriteBatchTest.TestWriteTheSameServerTimestampAcrossWrites
[TEST] [FLAKINESS] [iOS] [macos] [1/2 ios_device: ios_target]
(13 failed tests)  ArrayTransformTest.AppendObjectToArrayViaUpdate
  ArrayTransformTest.RemoveFromArrayViaUpdate
  FirestoreTest.TestDocumentSnapshotEventsForAdd
  NumericTransformsTest.CreateDocumentWithIncrement
  NumericTransformsTest.DoubleIncrementWithExistingString
  NumericTransformsTest.IncrementTwiceInABatch
  NumericTransformsTest.IntegerIncrementWithExistingDouble
  NumericTransformsTest.MergeOnNonExistingDocumentWithIncrement
  QueryTest.TestCanListenForTheSameQueryWithDifferentOptions
  ServerTimestampTest.TestServerTimestampsCanReturnEstimatedValue
  ServerTimestampTest.TestServerTimestampsCanReturnPreviousValue
  ServerTimestampTest.TestServerTimestampsWorkViaTransactionUpdate
  ValidationTest.QueriesCannotBeSortedByAnUncommittedServerTimestamp

Add flaky tests to go/fpl-cpp-flake-tracker

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the obsolete FIREBASE_USE_MOVE_OPERATORS and FIREBASE_USE_STD_FUNCTION preprocessor guards across the codebase, enabling move semantics and std::function support unconditionally. It also refactors the move constructor and move assignment operator of intrusive_list to handle self-assignment and cleanups. Feedback on these changes highlights two critical issues in app/src/intrusive_list.h: first, moving an empty or unlinked node can leave dangling pointers pointing to the moved-from node; second, moving an empty intrusive_list can cause the sentinel node to point to the destroyed list's sentinel. Code suggestions are provided to resolve both issues.

Comment thread app/src/intrusive_list.h Resolved
Comment thread app/src/intrusive_list.h Resolved
@github-actions github-actions Bot added the tests: failed This PR's integration tests failed. label Nov 27, 2026
@firebase-workflow-trigger firebase-workflow-trigger Bot removed the tests: in-progress This PR's integration tests are in progress. label Nov 27, 2026
@AustinBenoit AustinBenoit added the tests-requested: full Trigger a FULL set of integration tests (uses expanded test matrix). label Nov 27, 2026
@github-actions github-actions Bot added tests: in-progress This PR's integration tests are in progress. tests: failed This PR's integration tests failed. and removed tests-requested: full Trigger a FULL set of integration tests (uses expanded test matrix). tests: failed This PR's integration tests failed. labels Nov 27, 2026
@firebase-workflow-trigger firebase-workflow-trigger Bot removed the tests: in-progress This PR's integration tests are in progress. label Nov 27, 2026
@AustinBenoit AustinBenoit added tests-requested: full Trigger a FULL set of integration tests (uses expanded test matrix). and removed tests: failed This PR's integration tests failed. labels Dec 2, 2026
@github-actions github-actions Bot added tests: in-progress This PR's integration tests are in progress. and removed tests-requested: full Trigger a FULL set of integration tests (uses expanded test matrix). labels Dec 2, 2026
Comment thread app/src/intrusive_list.h
: data_(&data_, &data_), node_offset_(offset_of_node(node_member)) {}

#if defined(FIREBASE_USE_MOVE_OPERATORS)
intrusive_list(this_type&& other) noexcept { *this = std::move(other); }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Lint warning: Single-parameter constructors should be marked explicit.

@@ -82,9 +81,7 @@ class HttpsCallableResult {
// Only functions are allowed to construct results.
friend class ::firebase::functions::internal::HttpsCallableReferenceInternal;
HttpsCallableResult(const Variant& data) : data_(data) {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Lint warning: Single-parameter constructors should be marked explicit.

friend class ::firebase::functions::internal::HttpsCallableReferenceInternal;
HttpsCallableResult(const Variant& data) : data_(data) {}
#if defined(FIREBASE_USE_MOVE_OPERATORS)
HttpsCallableResult(Variant&& data) : data_(std::move(data)) {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Lint warning: Single-parameter constructors should be marked explicit.

@github-actions github-actions Bot added the tests: succeeded This PR's integration tests succeeded. label Dec 2, 2026
@firebase-workflow-trigger firebase-workflow-trigger Bot removed the tests: in-progress This PR's integration tests are in progress. label Dec 2, 2026
@AustinBenoit
AustinBenoit merged commit cdd475e into main Dec 2, 2026
43 of 44 checks passed
@github-actions github-actions Bot added the tests: in-progress This PR's integration tests are in progress. label Dec 2, 2026
@github-actions github-actions Bot added tests: failed This PR's integration tests failed. and removed tests: succeeded This PR's integration tests succeeded. labels Dec 2, 2026
@firebase-workflow-trigger firebase-workflow-trigger Bot removed the tests: in-progress This PR's integration tests are in progress. label Dec 2, 2026
AustinBenoit added a commit to firebase/firebase-unity-sdk that referenced this pull request Dec 2, 2026
…files (#1580)

Prepares Unity SWIG bindings for firebase/firebase-cpp-sdk#1995 removing the
always-defined FIREBASE_USE_MOVE_OPERATORS and FIREBASE_USE_STD_FUNCTION macros
from C++ headers:

- database/src/swig/database.i: ignore MutableData::MutableData so the move-only
  constructor does not leak into InternalMutableData.cs when unwrapped in C++.
- app/src/swig/future.i: ignore FutureBase::FutureBase(FutureBase&&) to match
  existing FutureBase::operator= ignore.
- storage/src/swig/storage.i: broaden copy-only operator=(const T&) ignores on
  StorageReference, Metadata, and Controller to unqualified operator=, and
  ignore StorageListResult::operator=.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-release-notes Skip release notes check tests: failed This PR's integration tests failed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants