Skip to content

Commit d6b2970

Browse files
committed
detect base member qualified overloads
#fix
1 parent b1d3f24 commit d6b2970

File tree

7 files changed

+265
-3
lines changed

7 files changed

+265
-3
lines changed

include/mrdocs/Metadata/Info/Function.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ tag_invoke(
267267
v = dom::LazyObject(I, domCorpus);
268268
}
269269

270+
/** Determine if one function would override the other
271+
*/
272+
MRDOCS_DECL
273+
bool
274+
overrides(FunctionInfo const& base, FunctionInfo const& derived);
275+
270276
} // clang::mrdocs
271277

272278
#endif

src/lib/Metadata/Finalizers/BaseMembersFinalizer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ inheritBaseMembers(
129129
// are the same
130130
auto const& otherFunc = static_cast<FunctionInfo const&>(otherInfo);
131131
auto const& func = static_cast<FunctionInfo const&>(info);
132-
return
133-
std::tie(func.Name, func.Params, func.Template) ==
134-
std::tie(otherFunc.Name, otherFunc.Params, func.Template);
132+
return overrides(func, otherFunc);
135133
}
136134
// For other kinds of members, it's a shadow if the names
137135
// are the same

src/lib/Metadata/Info/Function.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,22 @@ merge(FunctionInfo& I, FunctionInfo&& Other)
356356
}
357357
}
358358

359+
MRDOCS_DECL
360+
bool
361+
overrides(FunctionInfo const& base, FunctionInfo const& derived)
362+
{
363+
auto toOverrideTuple = [](FunctionInfo const& f) {
364+
return std::forward_as_tuple(
365+
f.Name,
366+
f.Params,
367+
f.Template,
368+
f.IsVariadic,
369+
f.IsConst,
370+
f.RefQualifier
371+
);
372+
};
373+
return toOverrideTuple(base) == toOverrideTuple(derived);
374+
}
359375

360376
} // clang::mrdocs
361377

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
= Reference
2+
:mrdocs:
3+
4+
[#index]
5+
== Global namespace
6+
7+
=== Types
8+
9+
[cols=1]
10+
|===
11+
| Name
12+
| <<C,`C`>>
13+
|===
14+
15+
[#C]
16+
== C
17+
18+
=== Synopsis
19+
20+
Declared in `&lt;const&hyphen;mutable&period;cpp&gt;`
21+
22+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
23+
----
24+
class C;
25+
----
26+
27+
=== Member Functions
28+
29+
[cols=2]
30+
|===
31+
| Name
32+
| Description
33+
| <<C-foo-01,`foo`>>
34+
|
35+
|===
36+
37+
[#C-foo-01]
38+
== <<C,C>>::foo
39+
40+
=== Synopses
41+
42+
Declared in `&lt;const&hyphen;mutable&period;cpp&gt;`
43+
44+
45+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
46+
----
47+
int&
48+
<<C-foo-0b,foo>>();
49+
----
50+
51+
[.small]#<<C-foo-0b,_» more&period;&period;&period;_>>#
52+
53+
54+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
55+
----
56+
int&
57+
<<C-foo-07,foo>>() const;
58+
----
59+
60+
[.small]#<<C-foo-07,_» more&period;&period;&period;_>>#
61+
62+
[#C-foo-0b]
63+
== <<C,C>>::foo
64+
65+
=== Synopsis
66+
67+
Declared in `&lt;const&hyphen;mutable&period;cpp&gt;`
68+
69+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
70+
----
71+
int&
72+
foo();
73+
----
74+
75+
[#C-foo-07]
76+
== <<C,C>>::foo
77+
78+
=== Synopsis
79+
80+
Declared in `&lt;const&hyphen;mutable&period;cpp&gt;`
81+
82+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
83+
----
84+
int&
85+
foo() const;
86+
----
87+
88+
89+
[.small]#Created with https://www.mrdocs.com[MrDocs]#
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class C {
2+
public:
3+
int& foo();
4+
int& foo() const;
5+
};
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<html lang="en">
2+
<head>
3+
<title>Reference</title>
4+
</head>
5+
<body>
6+
<div>
7+
<h1>Reference</h1>
8+
<div>
9+
<div>
10+
<h2 id="index">Global namespace</h2>
11+
</div>
12+
<h2>Types</h2>
13+
<table style="table-layout: fixed; width: 100%;">
14+
<thead>
15+
<tr>
16+
<th>Name</th>
17+
</tr>
18+
</thead>
19+
<tbody>
20+
<tr>
21+
<td><a href="#C"><code>C</code></a> </td></tr>
22+
</tbody>
23+
</table>
24+
25+
</div>
26+
<div>
27+
<div>
28+
<h2 id="C">C</h2>
29+
</div>
30+
<div>
31+
<h3>Synopsis</h3>
32+
<div>
33+
Declared in <code>&lt;const-mutable.cpp&gt;</code></div>
34+
<pre>
35+
<code class="source-code cpp">
36+
class C;
37+
</code>
38+
</pre>
39+
</div>
40+
<h2>Member Functions</h2>
41+
<table style="table-layout: fixed; width: 100%;">
42+
<thead>
43+
<tr>
44+
<th>Name</th>
45+
<th>Description</th>
46+
</tr>
47+
</thead>
48+
<tbody>
49+
<tr>
50+
<td><a href="#C-foo-01"><code>foo</code></a> </td><td><span></span></td></tr>
51+
</tbody>
52+
</table>
53+
54+
55+
56+
</div>
57+
<div>
58+
<div>
59+
<h2 id="C-foo-01"><a href="#C">C</a>::foo</h2>
60+
</div>
61+
<div>
62+
<h3>Synopses</h3>
63+
<div>
64+
Declared in <code>&lt;const-mutable.cpp&gt;</code></div>
65+
66+
<pre>
67+
<code class="source-code cpp">
68+
int&
69+
<a href="#C-foo-0b">foo</a>();
70+
</code>
71+
</pre><span class="small"><a href="#C-foo-0b"><em>» more...</em></a></span>
72+
73+
74+
<pre>
75+
<code class="source-code cpp">
76+
int&
77+
<a href="#C-foo-07">foo</a>() const;
78+
</code>
79+
</pre><span class="small"><a href="#C-foo-07"><em>» more...</em></a></span>
80+
81+
82+
</div>
83+
</div>
84+
<div>
85+
<div>
86+
<h2 id="C-foo-0b"><a href="#C">C</a>::foo</h2>
87+
</div>
88+
<div>
89+
<h3>Synopsis</h3>
90+
<div>
91+
Declared in <code>&lt;const-mutable.cpp&gt;</code></div>
92+
<pre>
93+
<code class="source-code cpp">
94+
int&
95+
foo();
96+
</code>
97+
</pre>
98+
</div>
99+
</div>
100+
<div>
101+
<div>
102+
<h2 id="C-foo-07"><a href="#C">C</a>::foo</h2>
103+
</div>
104+
<div>
105+
<h3>Synopsis</h3>
106+
<div>
107+
Declared in <code>&lt;const-mutable.cpp&gt;</code></div>
108+
<pre>
109+
<code class="source-code cpp">
110+
int&
111+
foo() const;
112+
</code>
113+
</pre>
114+
</div>
115+
</div>
116+
117+
</div>
118+
<div>
119+
<h4>Created with <a href="https://www.mrdocs.com">MrDocs</a></h4>
120+
</div>
121+
</body>
122+
</html>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<mrdocs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdocs/raw/develop/mrdocs.rnc">
4+
<namespace id="//////////////////////////8=">
5+
<class name="C" id="BrX2oZup9qgy4SfJloKCuUYZshA=">
6+
<file short-path="const-mutable.cpp" source-path="const-mutable.cpp" line="1" class="def"/>
7+
<function name="foo" id="umtiZdZUSDxw3juVm+S7M40tpXQ=">
8+
<file short-path="const-mutable.cpp" source-path="const-mutable.cpp" line="3"/>
9+
<return>
10+
<type class="lvalue-reference">
11+
<pointee-type name="int"/>
12+
</type>
13+
</return>
14+
</function>
15+
<function name="foo" id="c8FMK37zKpqJXH2ZioM0tYziY1g=">
16+
<file short-path="const-mutable.cpp" source-path="const-mutable.cpp" line="4"/>
17+
<attr id="is-const"/>
18+
<return>
19+
<type class="lvalue-reference">
20+
<pointee-type name="int"/>
21+
</type>
22+
</return>
23+
</function>
24+
</class>
25+
</namespace>
26+
</mrdocs>

0 commit comments

Comments
 (0)