Skip to content

Commit 015cd13

Browse files
j-piaseckimeta-codesync[bot]
authored andcommitted
Deduplicate base classes from Doxygen using declaration (#56218)
Summary: Pull Request resolved: #56218 Changelog: [Internal] When a class inherits constructors via `using Base::Base;`, Doxygen incorrectly emits duplicate `basecompoundref` entries for the same base class. This caused base classes like `ConverterBase` to appear twice in the snapshot output. This diff deduplicates base classes by name in `get_base_classes()`. Reviewed By: cipolleschi Differential Revision: D98118659 fbshipit-source-id: c81f663480fda48c89e6dd625a504a78eb9d7c41
1 parent 31f262e commit 015cd13

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

scripts/cxx-api/parser/builders.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,14 @@ def get_base_classes(
166166
) -> list:
167167
"""
168168
Get the base classes of a compound object.
169+
170+
Deduplicates base classes by name. Doxygen can emit duplicate
171+
``basecompoundref`` entries when a class inherits constructors via
172+
``using Base::Base;`` — the using-declaration is incorrectly reported
173+
as an additional base class reference.
169174
"""
170175
base_classes = []
176+
seen_names: set[str] = set()
171177
if compound_object.basecompoundref:
172178
for base in compound_object.basecompoundref:
173179
# base is a compoundRefType with:
@@ -184,6 +190,10 @@ def get_base_classes(
184190
# Ignore private base classes
185191
continue
186192

193+
if base_name in seen_names:
194+
continue
195+
seen_names.add(base_name)
196+
187197
base_classes.append(
188198
base_class(
189199
base_name,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
struct test::Converter<int> : public test::ConverterBase<int> {
2+
public void doSomething();
3+
}
4+
5+
template <typename T>
6+
struct test::Converter {
7+
}
8+
9+
template <typename T>
10+
struct test::ConverterBase {
11+
public ConverterBase() = default;
12+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
namespace test {
11+
12+
template <typename T>
13+
struct ConverterBase {
14+
ConverterBase() = default;
15+
};
16+
17+
template <typename T>
18+
struct Converter {};
19+
20+
template <>
21+
struct Converter<int> : public ConverterBase<int> {
22+
using ConverterBase<int>::ConverterBase;
23+
void doSomething();
24+
};
25+
26+
} // namespace test

0 commit comments

Comments
 (0)