From 25ac11b03dda1464e4feccbd5554f550f7ae57df Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Tue, 3 Mar 2026 01:00:16 -0800 Subject: [PATCH] Ignore anonymous namespaces in the snapshot (#55844) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55844 Changelog: [Internal] Updates the C++ API snapshot generator not to include anonymous namespaces in the snapshot since those have internal linkage. Reviewed By: cipolleschi Differential Revision: D94901508 fbshipit-source-id: f025f69e4d9cc6cc42fa99974d596eb223e8da1c --- scripts/cxx-api/parser/main.py | 5 ++++ .../snapshot.api | 3 +++ .../should_ignore_anonymous_namespace/test.h | 24 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 scripts/cxx-api/tests/snapshots/should_ignore_anonymous_namespace/snapshot.api create mode 100644 scripts/cxx-api/tests/snapshots/should_ignore_anonymous_namespace/test.h diff --git a/scripts/cxx-api/parser/main.py b/scripts/cxx-api/parser/main.py index 915e345edab..69ff461bfdf 100644 --- a/scripts/cxx-api/parser/main.py +++ b/scripts/cxx-api/parser/main.py @@ -526,6 +526,11 @@ def build_snapshot(xml_dir: str) -> Snapshot: f"Unknown class visibility: {visibility} in {compound_object.location.file}" ) elif compound_object.kind == "namespace": + # Skip anonymous namespaces (internal linkage, not public API). + # Doxygen encodes them with a '@' prefix in the compound name. + if "@" in compound_object.compoundname: + continue + namespace_scope = snapshot.create_or_get_namespace( compound_object.compoundname ) diff --git a/scripts/cxx-api/tests/snapshots/should_ignore_anonymous_namespace/snapshot.api b/scripts/cxx-api/tests/snapshots/should_ignore_anonymous_namespace/snapshot.api new file mode 100644 index 00000000000..7db6e6e5741 --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_ignore_anonymous_namespace/snapshot.api @@ -0,0 +1,3 @@ +class test::Clss { + public void hello(); +} diff --git a/scripts/cxx-api/tests/snapshots/should_ignore_anonymous_namespace/test.h b/scripts/cxx-api/tests/snapshots/should_ignore_anonymous_namespace/test.h new file mode 100644 index 00000000000..e0f5c94535f --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_ignore_anonymous_namespace/test.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +namespace { +enum class InternalEnum { + A, + B, +}; +} // namespace + +namespace test { + +class Clss { + public: + void hello(); +}; + +} // namespace test