Skip to content

Commit b76c8ba

Browse files
committed
refs match conversion operators
#feat
1 parent 0719850 commit b76c8ba

File tree

5 files changed

+151
-25
lines changed

5 files changed

+151
-25
lines changed

src/lib/Lib/CorpusImpl.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ lookupImpl(Self&& self, SymbolID const& contextId0, std::string_view name)
222222
{
223223
return Unexpected(formatError("Failed to parse '{}'\n {}", name, expRef.error().reason()));
224224
}
225-
ParsedRef const& ref = *expRef;
225+
ParsedRef const& ref = *std::move(expRef);
226226
Info const* res = lookupImpl(self, contextId, ref, name, false);
227227
if (!res)
228228
{
@@ -375,12 +375,19 @@ lookupImpl(
375375
auto matchRes = MatchLevel::None;
376376

377377
// Name match
378-
if constexpr (requires { { M.OverloadedOperator } -> std::same_as<OperatorKind>; })
378+
if constexpr (
379+
std::same_as<MInfoTy, FunctionInfo> ||
380+
std::same_as<MInfoTy, OverloadsInfo>)
379381
{
380-
if (component.Operator != OperatorKind::None)
382+
if (component.isOperator())
381383
{
382384
MRDOCS_CHECK_OR(M.OverloadedOperator == component.Operator, matchRes);
383385
}
386+
else if (component.isConversion())
387+
{
388+
MRDOCS_CHECK_OR(M.Class == FunctionClass::Conversion, matchRes);
389+
MRDOCS_CHECK_OR(component.ConversionType == M.ReturnType, matchRes);
390+
}
384391
else
385392
{
386393
MRDOCS_CHECK_OR(member.Name == component.Name, matchRes);

src/lib/Metadata/Name.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ writeTo(
4141

4242
std::strong_ordering
4343
NameInfo::
44-
operator<=>(NameInfo const& other) const = default;
44+
operator<=>(NameInfo const& other) const
45+
{
46+
return
47+
std::tie(Kind, Name, Prefix) <=>
48+
std::tie(other.Kind, other.Name, other.Prefix);
49+
}
4550

4651
std::strong_ordering
4752
operator<=>(Polymorphic<NameInfo> const& lhs, Polymorphic<NameInfo> const& rhs)

test-files/golden-tests/javadoc/copydoc/conversion.adoc

+34-10
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct A;
4747
| Convert A to a string
4848

4949
| <<A-2conversion-00,`operator string&lowbar;view&lowbar;type`>>
50-
| string&lowbar;type()
50+
| Convert A to a string
5151

5252
|===
5353

@@ -64,26 +64,27 @@ Convert a string to A
6464

6565
Declared in `&lt;conversion&period;cpp&gt;`
6666

67+
Convert a string to A
6768

6869

6970
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
7071
----
7172
<<A,A>>&
72-
<<A-operator_assign-00,operator&equals;>>(<<string_view_type,string&lowbar;view&lowbar;type>> const& other);
73+
<<A-operator_assign-08,operator&equals;>>(<<string_type,string&lowbar;type>> const& other);
7374
----
7475

75-
[.small]#<<A-operator_assign-00,_» more&period;&period;&period;_>>#
76+
[.small]#<<A-operator_assign-08,_» more&period;&period;&period;_>>#
7677

7778
Convert a string to A
7879

7980

8081
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
8182
----
8283
<<A,A>>&
83-
<<A-operator_assign-08,operator&equals;>>(<<string_type,string&lowbar;type>> const& other);
84+
<<A-operator_assign-00,operator&equals;>>(<<string_view_type,string&lowbar;view&lowbar;type>> const& other);
8485
----
8586

86-
[.small]#<<A-operator_assign-08,_» more&period;&period;&period;_>>#
87+
[.small]#<<A-operator_assign-00,_» more&period;&period;&period;_>>#
8788

8889
=== Return Value
8990

@@ -101,10 +102,12 @@ A representation of the string
101102

102103
|===
103104

104-
[#A-operator_assign-00]
105+
[#A-operator_assign-08]
105106
== <<A,A>>::operator&equals;
106107

107108

109+
Convert a string to A
110+
108111
=== Synopsis
109112

110113

@@ -113,10 +116,26 @@ Declared in `&lt;conversion&period;cpp&gt;`
113116
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
114117
----
115118
<<A,A>>&
116-
operator&equals;(<<string_view_type,string&lowbar;view&lowbar;type>> const& other);
119+
operator&equals;(<<string_type,string&lowbar;type>> const& other);
117120
----
118121

119-
[#A-operator_assign-08]
122+
=== Return Value
123+
124+
125+
A representation of the string
126+
127+
=== Parameters
128+
129+
130+
|===
131+
| Name | Description
132+
133+
| *other*
134+
| The string to convert
135+
136+
|===
137+
138+
[#A-operator_assign-00]
120139
== <<A,A>>::operator&equals;
121140

122141

@@ -130,7 +149,7 @@ Declared in `&lt;conversion&period;cpp&gt;`
130149
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
131150
----
132151
<<A,A>>&
133-
operator&equals;(<<string_type,string&lowbar;type>> const& other);
152+
operator&equals;(<<string_view_type,string&lowbar;view&lowbar;type>> const& other);
134153
----
135154

136155
=== Return Value
@@ -174,7 +193,7 @@ A string representation of A
174193
== <<A,A>>::operator <<string_view_type,string&lowbar;view&lowbar;type>>
175194

176195

177-
string&lowbar;type()
196+
Convert A to a string
178197

179198
=== Synopsis
180199

@@ -186,6 +205,11 @@ Declared in `&lt;conversion&period;cpp&gt;`
186205
operator <<string_view_type,string&lowbar;view&lowbar;type>>() const;
187206
----
188207

208+
=== Return Value
209+
210+
211+
A string representation of A
212+
189213
[#string_type]
190214
== string&lowbar;type
191215

test-files/golden-tests/javadoc/copydoc/conversion.html

+47-10
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ <h2>Member Functions</h2>
5757
<td><a href="#A-2conversion-02"><code>operator string_type</code></a> </td><td><span><span>Convert A to a string</span></span>
5858
</td>
5959
</tr><tr>
60-
<td><a href="#A-2conversion-00"><code>operator string_view_type</code></a> </td><td><span><span>string_type()</span></span>
60+
<td><a href="#A-2conversion-00"><code>operator string_view_type</code></a> </td><td><span><span>Convert A to a string</span></span>
6161
</td>
6262
</tr>
6363
</tbody>
@@ -78,14 +78,18 @@ <h2 id="A-operator_assign-0d"><a href="#A">A</a>::operator&#x3D;</h2>
7878
<h3>Synopses</h3>
7979
<div>
8080
Declared in <code>&lt;conversion.cpp&gt;</code></div>
81+
<p>
82+
<span><span>Convert a string to A</span></span>
83+
84+
</p>
8185

8286

8387
<pre>
8488
<code class="source-code cpp">
8589
<a href="#A">A</a>&
86-
<a href="#A-operator_assign-00">operator&#x3D;</a>(<a href="#string_view_type">string_view_type</a> const& other);
90+
<a href="#A-operator_assign-08">operator&#x3D;</a>(<a href="#string_type">string_type</a> const& other);
8791
</code>
88-
</pre><span class="small"><a href="#A-operator_assign-00"><em>» more...</em></a></span>
92+
</pre><span class="small"><a href="#A-operator_assign-08"><em>» more...</em></a></span>
8993

9094
<p>
9195
<span><span>Convert a string to A</span></span>
@@ -96,9 +100,9 @@ <h3>Synopses</h3>
96100
<pre>
97101
<code class="source-code cpp">
98102
<a href="#A">A</a>&
99-
<a href="#A-operator_assign-08">operator&#x3D;</a>(<a href="#string_type">string_type</a> const& other);
103+
<a href="#A-operator_assign-00">operator&#x3D;</a>(<a href="#string_view_type">string_view_type</a> const& other);
100104
</code>
101-
</pre><span class="small"><a href="#A-operator_assign-08"><em>» more...</em></a></span>
105+
</pre><span class="small"><a href="#A-operator_assign-00"><em>» more...</em></a></span>
102106

103107

104108
</div>
@@ -128,7 +132,12 @@ <h3>Parameters</h3>
128132
</div>
129133
<div>
130134
<div>
131-
<h2 id="A-operator_assign-00"><a href="#A">A</a>::operator&#x3D;</h2>
135+
<h2 id="A-operator_assign-08"><a href="#A">A</a>::operator&#x3D;</h2>
136+
<div>
137+
<span><span>Convert a string to A</span></span>
138+
139+
140+
</div>
132141
</div>
133142
<div>
134143
<h3>Synopsis</h3>
@@ -137,14 +146,37 @@ <h3>Synopsis</h3>
137146
<pre>
138147
<code class="source-code cpp">
139148
<a href="#A">A</a>&
140-
operator&#x3D;(<a href="#string_view_type">string_view_type</a> const& other);
149+
operator&#x3D;(<a href="#string_type">string_type</a> const& other);
141150
</code>
142151
</pre>
143152
</div>
153+
<div>
154+
<h3>Return Value</h3>
155+
<p><span>A representation of the string</span></p>
156+
157+
</div>
158+
<div>
159+
<h3>Parameters</h3>
160+
<table>
161+
<thead>
162+
<tr>
163+
<th>Name</th>
164+
<th>Description</th>
165+
</tr>
166+
</thead>
167+
<tbody>
168+
<tr>
169+
<td><strong>other</strong></td>
170+
<td><p><span>The string to convert</span></p>
171+
</td>
172+
</tr>
173+
</tbody>
174+
</table>
175+
</div>
144176
</div>
145177
<div>
146178
<div>
147-
<h2 id="A-operator_assign-08"><a href="#A">A</a>::operator&#x3D;</h2>
179+
<h2 id="A-operator_assign-00"><a href="#A">A</a>::operator&#x3D;</h2>
148180
<div>
149181
<span><span>Convert a string to A</span></span>
150182

@@ -158,7 +190,7 @@ <h3>Synopsis</h3>
158190
<pre>
159191
<code class="source-code cpp">
160192
<a href="#A">A</a>&
161-
operator&#x3D;(<a href="#string_type">string_type</a> const& other);
193+
operator&#x3D;(<a href="#string_view_type">string_view_type</a> const& other);
162194
</code>
163195
</pre>
164196
</div>
@@ -215,7 +247,7 @@ <h3>Return Value</h3>
215247
<div>
216248
<h2 id="A-2conversion-00"><a href="#A">A</a>::operator <a href="#string_view_type">string_view_type</a></h2>
217249
<div>
218-
<span><span>string_type()</span></span>
250+
<span><span>Convert A to a string</span></span>
219251

220252

221253
</div>
@@ -229,6 +261,11 @@ <h3>Synopsis</h3>
229261
operator <a href="#string_view_type">string_view_type</a>() const;
230262
</code>
231263
</pre>
264+
</div>
265+
<div>
266+
<h3>Return Value</h3>
267+
<p><span>A string representation of A</span></p>
268+
232269
</div>
233270
</div>
234271
<div>

test-files/golden-tests/javadoc/copydoc/conversion.xml

+54-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,56 @@
44
<namespace id="//////////////////////////8=">
55
<struct name="A" id="YrPSaKAbmXgzCAX5WByx4eVoqBM=">
66
<file short-path="conversion.cpp" source-path="conversion.cpp" line="4" class="def"/>
7+
<function name="operator=" id="gnscUVeCG+RVOHYPi/rKmD4KT3k=">
8+
<file short-path="conversion.cpp" source-path="conversion.cpp" line="20"/>
9+
<attr id="operator" name="assign" value="14"/>
10+
<return>
11+
<type class="lvalue-reference">
12+
<pointee-type id="YrPSaKAbmXgzCAX5WByx4eVoqBM=" name="A"/>
13+
</type>
14+
</return>
15+
<param name="other">
16+
<type class="lvalue-reference">
17+
<pointee-type id="aQ5vERa/ROUuSctnkS1VsKSt48E=" name="string_type" cv-qualifiers="const"/>
18+
</type>
19+
</param>
20+
<doc>
21+
<brief>
22+
<text>Convert a string to A</text>
23+
</brief>
24+
<returns>
25+
<text>A representation of the string</text>
26+
</returns>
27+
<param name="other">
28+
<text>The string to convert </text>
29+
</param>
30+
</doc>
31+
</function>
32+
<function name="operator=" id="CGrNRU4S73WU6e3HjSzK2ehtLi0=">
33+
<file short-path="conversion.cpp" source-path="conversion.cpp" line="24"/>
34+
<attr id="operator" name="assign" value="14"/>
35+
<return>
36+
<type class="lvalue-reference">
37+
<pointee-type id="YrPSaKAbmXgzCAX5WByx4eVoqBM=" name="A"/>
38+
</type>
39+
</return>
40+
<param name="other">
41+
<type class="lvalue-reference">
42+
<pointee-type id="EulqVl/v48vv9XjENaufduUwZKI=" name="string_view_type" cv-qualifiers="const"/>
43+
</type>
44+
</param>
45+
<doc>
46+
<brief>
47+
<text>Convert a string to A</text>
48+
</brief>
49+
<returns>
50+
<text>A representation of the string</text>
51+
</returns>
52+
<param name="other">
53+
<text>The string to convert </text>
54+
</param>
55+
</doc>
56+
</function>
757
<function class="conversion" name="operator string_type" id="KpKT2IPgl8pNnQdWRqrAmcPRtV0=">
858
<file short-path="conversion.cpp" source-path="conversion.cpp" line="9"/>
959
<attr id="is-const"/>
@@ -27,8 +77,11 @@
2777
</return>
2878
<doc>
2979
<brief>
30-
<text>string_type()</text>
80+
<text>Convert A to a string</text>
3181
</brief>
82+
<returns>
83+
<text>A string representation of A</text>
84+
</returns>
3285
</doc>
3386
</function>
3487
</struct>

0 commit comments

Comments
 (0)