Skip to content

Commit 4e1a877

Browse files
j-piaseckimeta-codesync[bot]
authored andcommitted
Requalify incorrect references produced by doxygen (#56058)
Summary: Pull Request resolved: #56058 Changelog: [Internal] Doxygen may incorrectly resolve reference to a friend declaration or inherited constructor instead of the actual friend or the base class. This diff updates the qualification algorithm to try to requalify cases like these. Reviewed By: cipolleschi Differential Revision: D96129278 fbshipit-source-id: fba4c78c74d43870a2a14f5eedce061ba6f2793d
1 parent d177839 commit 4e1a877

5 files changed

Lines changed: 76 additions & 9 deletions

File tree

scripts/cxx-api/parser/scope.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -409,16 +409,18 @@ def qualify_name(self, name: str | None) -> str | None:
409409
if anchor_prefix:
410410
return f"{anchor_prefix}::{suffix}"
411411
return suffix
412-
elif any(
413-
isinstance(m, FriendMember) and m.name == base_name
414-
for m in current_scope._members
415-
):
416-
# The name matches a friend declaration, not a real member.
417-
# Re-qualify from the remaining segments so the type resolves
418-
# to its actual definition rather than the friend's owning class.
419-
remaining = "::".join(path[i:])
420-
return self.qualify_name(remaining)
421412
else:
413+
# Segment not found as an inner scope or a real member of
414+
# the current scope. When inside a struct-like scope this
415+
# typically means Doxygen's refid-based qualification
416+
# incorrectly placed a type under a compound that does not
417+
# actually contain it — for example a friend declaration or
418+
# an inherited constructor reported as a member ref. Try
419+
# to re-qualify from the remaining unmatched segments so the
420+
# type resolves against the broader scope hierarchy.
421+
if isinstance(current_scope.kind, StructLikeScopeKind):
422+
remaining = "::".join(path[i:])
423+
return self.qualify_name(remaining)
422424
return None
423425

424426
# Return qualified name with preserved template arguments
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class test::Derived : public test::Base<int> {
2+
public Derived(int value);
3+
public using BaseAlias = test::Base<int>;
4+
}
5+
6+
template <typename T>
7+
class test::Base {
8+
public Base(int value);
9+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
class Base {
14+
public:
15+
Base(int value);
16+
};
17+
18+
class Derived : public Base<int> {
19+
public:
20+
using BaseAlias = Base<int>;
21+
using Base::Base;
22+
};
23+
24+
} // namespace test
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class test::ProviderRegistry {
2+
}
3+
4+
class test::Registry {
5+
public Registry(const test::ProviderRegistry& provider);
6+
public bool hasItem(int handle) const;
7+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
class ProviderRegistry;
13+
14+
class Registry {
15+
public:
16+
Registry(const ProviderRegistry &provider);
17+
bool hasItem(int handle) const;
18+
19+
private:
20+
friend class ProviderRegistry;
21+
};
22+
23+
class ProviderRegistry {};
24+
25+
} // namespace test

0 commit comments

Comments
 (0)