@@ -3474,40 +3474,19 @@ GenericParamListRequest::evaluate(Evaluator &evaluator, GenericContext *value) c
3474
3474
parsedGenericParams->getRAngleLoc ());
3475
3475
}
3476
3476
3477
- void swift::findMacroForCustomAttr (CustomAttr *attr, DeclContext *dc,
3478
- llvm::TinyPtrVector<ValueDecl *> ¯os) {
3479
- auto *identTypeRepr = dyn_cast_or_null<IdentTypeRepr>(attr->getTypeRepr ());
3480
- if (!identTypeRepr)
3481
- return ;
3482
-
3483
- // Look for macros at module scope. They can only occur at module scope, and
3484
- // we need to be sure not to trigger name lookup into type contexts along
3485
- // the way.
3486
- auto moduleScopeDC = dc->getModuleScopeContext ();
3487
- ASTContext &ctx = moduleScopeDC->getASTContext ();
3488
- UnqualifiedLookupDescriptor descriptor (
3489
- identTypeRepr->getNameRef (), moduleScopeDC
3490
- );
3491
- auto lookup = evaluateOrDefault (
3492
- ctx.evaluator , UnqualifiedLookupRequest{descriptor}, {});
3493
- for (const auto &result : lookup.allResults ()) {
3494
- // Only keep attached macros, which can be spelled as custom attributes.
3495
- if (auto macro = dyn_cast<MacroDecl>(result.getValueDecl ()))
3496
- if (isAttachedMacro (macro->getMacroRoles ()))
3497
- macros.push_back (macro);
3498
- }
3499
- }
3500
-
3501
3477
NominalTypeDecl *
3502
3478
CustomAttrNominalRequest::evaluate (Evaluator &evaluator,
3503
3479
CustomAttr *attr, DeclContext *dc) const {
3504
3480
// Look for names at module scope, so we don't trigger name lookup for
3505
3481
// nested scopes. At this point, we're looking to see whether there are
3506
3482
// any suitable macros.
3507
- llvm::TinyPtrVector<ValueDecl *> macros;
3508
- findMacroForCustomAttr (attr, dc, macros);
3509
- if (!macros.empty ())
3510
- return nullptr ;
3483
+ if (auto *identTypeRepr =
3484
+ dyn_cast_or_null<IdentTypeRepr>(attr->getTypeRepr ())) {
3485
+ auto macros = namelookup::lookupMacros (
3486
+ dc, identTypeRepr->getNameRef (), getAttachedMacroRoles ());
3487
+ if (!macros.empty ())
3488
+ return nullptr ;
3489
+ }
3511
3490
3512
3491
// Find the types referenced by the custom attribute.
3513
3492
auto &ctx = dc->getASTContext ();
0 commit comments