Skip to content

Commit b29ba25

Browse files
committed
fix: inherit-base skips special functions
#fix
1 parent 65cdf3e commit b29ba25

File tree

6 files changed

+2360
-8
lines changed

6 files changed

+2360
-8
lines changed

src/lib/Metadata/Finalizers/BaseMembersFinalizer.cpp

+13-8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "BaseMembersFinalizer.hpp"
1212
#include <mrdocs/Support/Report.hpp>
13+
#include <mrdocs/Support/Algorithm.hpp>
1314

1415
namespace clang::mrdocs {
1516

@@ -101,12 +102,19 @@ inheritBaseMembers(
101102
for (SymbolID const& otherID: base)
102103
{
103104
// Find the info from the base class
104-
auto idIt = std::ranges::find(derived, otherID);
105-
MRDOCS_CHECK_OR_CONTINUE(idIt == derived.end());
105+
MRDOCS_CHECK_OR_CONTINUE(!contains(derived, otherID));
106106
Info* otherInfoPtr = corpus_.find(otherID);
107107
MRDOCS_CHECK_OR_CONTINUE(otherInfoPtr);
108108
Info& otherInfo = *otherInfoPtr;
109109

110+
// Check if we're not attempt to copy a special member function
111+
if (auto const* funcPtr = static_cast<FunctionInfo const*>(otherInfoPtr))
112+
{
113+
MRDOCS_CHECK_OR_CONTINUE(!is_one_of(
114+
funcPtr->Class,
115+
{ FunctionClass::Constructor, FunctionClass::Destructor }));
116+
}
117+
110118
// Check if derived class has a member that shadows the base member
111119
auto shadowIt = std::ranges::find_if(
112120
derived,
@@ -126,12 +134,9 @@ inheritBaseMembers(
126134
std::tie(func.Name, func.Params, func.Template) ==
127135
std::tie(otherFunc.Name, otherFunc.Params, func.Template);
128136
}
129-
else
130-
{
131-
// For other kinds of members, it's a shadow if the names
132-
// are the same
133-
return info.Name == otherInfo.Name;
134-
}
137+
// For other kinds of members, it's a shadow if the names
138+
// are the same
139+
return info.Name == otherInfo.Name;
135140
});
136141
MRDOCS_CHECK_OR_CONTINUE(shadowIt == derived.end());
137142

0 commit comments

Comments
 (0)