@@ -6200,8 +6200,32 @@ TinyPtrVector<ValueDecl *> ClangRecordMemberLookup::evaluate(
6200
6200
ClangDirectLookupRequest ({recordDecl, recordDecl->getClangDecl (), name}),
6201
6201
{});
6202
6202
6203
- // Find the results that are actually a member of "recordDecl" .
6203
+ // The set of declarations we found .
6204
6204
TinyPtrVector<ValueDecl *> result;
6205
+ auto addResult = [&result, name](ValueDecl *imported) {
6206
+ result.push_back (imported);
6207
+
6208
+ // Expand any macros introduced by the Clang importer.
6209
+ imported->visitAuxiliaryDecls ([&](Decl *decl) {
6210
+ auto valueDecl = dyn_cast<ValueDecl>(decl);
6211
+ if (!valueDecl)
6212
+ return ;
6213
+
6214
+ // Bail out if the auxiliary decl was not produced by a macro.
6215
+ auto module = decl->getDeclContext ()->getParentModule ();
6216
+ auto *sf = module ->getSourceFileContainingLocation (decl->getLoc ());
6217
+ if (!sf || sf->Kind != SourceFileKind::MacroExpansion)
6218
+ return ;
6219
+
6220
+ // Only produce results that match the requested name.
6221
+ if (!valueDecl->getName ().matchesRef (name))
6222
+ return ;
6223
+
6224
+ result.push_back (valueDecl);
6225
+ });
6226
+ };
6227
+
6228
+ // Find the results that are actually a member of "recordDecl".
6205
6229
ClangModuleLoader *clangModuleLoader = ctx.getClangModuleLoader ();
6206
6230
for (auto foundEntry : directResults) {
6207
6231
auto found = foundEntry.get <clang::NamedDecl *>();
@@ -6236,7 +6260,8 @@ TinyPtrVector<ValueDecl *> ClangRecordMemberLookup::evaluate(
6236
6260
if (!imported)
6237
6261
continue ;
6238
6262
}
6239
- result.push_back (cast<ValueDecl>(imported));
6263
+
6264
+ addResult (cast<ValueDecl>(imported));
6240
6265
}
6241
6266
6242
6267
if (inheritance) {
@@ -6255,7 +6280,7 @@ TinyPtrVector<ValueDecl *> ClangRecordMemberLookup::evaluate(
6255
6280
if (!imported)
6256
6281
continue ;
6257
6282
6258
- result. push_back (cast<ValueDecl>( imported) );
6283
+ addResult ( imported);
6259
6284
}
6260
6285
}
6261
6286
@@ -6304,7 +6329,7 @@ TinyPtrVector<ValueDecl *> ClangRecordMemberLookup::evaluate(
6304
6329
if (foundNameArities.count (getArity (foundInBase)))
6305
6330
continue ;
6306
6331
6307
- result. push_back (foundInBase);
6332
+ addResult (foundInBase);
6308
6333
}
6309
6334
}
6310
6335
}
0 commit comments