@@ -125,7 +125,8 @@ SymbolLookup::
125
125
lookupInContext (
126
126
const Info* context,
127
127
std::string_view name,
128
- bool for_nns)
128
+ bool for_nns,
129
+ LookupCallback& callback)
129
130
{
130
131
// if the lookup context is a typedef, we want to
131
132
// lookup the name in the type it denotes
@@ -136,17 +137,27 @@ lookupInContext(
136
137
// KRYSTIAN FIXME: disambiguation based on signature
137
138
for (auto & result : table.lookup (name))
138
139
{
139
- // per [basic.lookup.qual.general] p1, when looking up a
140
- // component name of a nested-name-specifier, we only consider:
141
- // - namespaces,
142
- // - types, and
143
- // - templates whose specializations are types
144
- if (! for_nns ||
145
- result->isNamespace () ||
146
- result->isRecord () ||
147
- result->isEnum () ||
148
- result->isTypedef ())
149
- return result;
140
+ if (for_nns)
141
+ {
142
+ // per [basic.lookup.qual.general] p1, when looking up a
143
+ // component name of a nested-name-specifier, we only consider:
144
+ // - namespaces,
145
+ // - types, and
146
+ // - templates whose specializations are types
147
+ // KRYSTIAN FIXME: should we if the result is acceptable?
148
+ if (result->isNamespace () ||
149
+ result->isRecord () ||
150
+ result->isEnum () ||
151
+ result->isTypedef ())
152
+ return result;
153
+ }
154
+ else
155
+ {
156
+ // if we are looking up a terminal name, call the handler
157
+ // to determine whether the result is acceptable
158
+ if (callback (*result))
159
+ return result;
160
+ }
150
161
}
151
162
152
163
// if this is a record and nothing was found,
@@ -159,7 +170,8 @@ lookupInContext(
159
170
for (const auto & B : RI->Bases )
160
171
{
161
172
if (const Info* result = lookupInContext (
162
- corpus_.find (B.Type ->namedSymbol ()), name, for_nns))
173
+ corpus_.find (B.Type ->namedSymbol ()),
174
+ name, for_nns, callback))
163
175
return result;
164
176
}
165
177
}
@@ -172,14 +184,16 @@ SymbolLookup::
172
184
lookupUnqualifiedImpl (
173
185
const Info* context,
174
186
std::string_view name,
175
- bool for_nns)
187
+ bool for_nns,
188
+ LookupCallback& callback)
176
189
{
177
190
if (! context)
178
191
return nullptr ;
179
192
context = adjustLookupContext (context);
180
193
while (context)
181
194
{
182
- if (auto result = lookupInContext (context, name, for_nns))
195
+ if (auto result = lookupInContext (
196
+ context, name, for_nns, callback))
183
197
return result;
184
198
if (context->Namespace .empty ())
185
199
return nullptr ;
@@ -191,38 +205,31 @@ lookupUnqualifiedImpl(
191
205
192
206
const Info*
193
207
SymbolLookup::
194
- lookupUnqualified (
195
- const Info* context,
196
- std::string_view name)
197
- {
198
- return lookupUnqualifiedImpl (
199
- context, name, false );
200
- }
201
-
202
- const Info*
203
- SymbolLookup::
204
- lookupQualified (
208
+ lookupQualifiedImpl (
205
209
const Info* context,
206
210
std::span<const std::string_view> qualifier,
207
- std::string_view terminal)
211
+ std::string_view terminal,
212
+ LookupCallback& callback)
208
213
{
209
214
if (! context)
210
215
return nullptr ;
211
216
if (qualifier.empty ())
212
- return lookupInContext (context, terminal);
217
+ return lookupInContext (
218
+ context, terminal, false , callback);
213
219
context = lookupUnqualifiedImpl (
214
- context, qualifier.front (), true );
220
+ context, qualifier.front (), true , callback );
215
221
qualifier = qualifier.subspan (1 );
216
222
if (! context)
217
223
return nullptr ;
218
224
while (! qualifier.empty ())
219
225
{
220
226
if (! (context = lookupInContext (
221
- context, qualifier.front (), true )))
227
+ context, qualifier.front (), true , callback )))
222
228
return nullptr ;
223
229
qualifier = qualifier.subspan (1 );
224
230
}
225
- return lookupInContext (context, terminal);
231
+ return lookupInContext (
232
+ context, terminal, false , callback);
226
233
}
227
234
228
235
} // mrdocs
0 commit comments