Skip to content

Commit 6c1a977

Browse files
committed
Sema: Move attached macro availability checking to DeclAvailabilityChecker.
This allows the `ExportContext` that is pre-computed for availability checking to be reused when checking attached macro availability. Also, it just makes more sense. NFC.
1 parent 16b71df commit 6c1a977

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

lib/Sema/TypeCheckAccess.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,6 @@ class AccessControlChecker : public AccessControlCheckerBase,
573573

574574
DeclVisitor<AccessControlChecker>::visit(D);
575575
checkGlobalActorAccess(D);
576-
checkAttachedMacrosAccess(D);
577576
}
578577

579578
// Force all kinds to be handled at a lower level.
@@ -1314,19 +1313,6 @@ class AccessControlChecker : public AccessControlCheckerBase,
13141313
noteLimitingImport(MD, minImportLimit, complainRepr);
13151314
}
13161315
}
1317-
1318-
void checkAttachedMacrosAccess(const Decl *D) {
1319-
for (auto customAttrC : D->getExpandedAttrs().getAttributes<CustomAttr>()) {
1320-
auto customAttr = const_cast<CustomAttr *>(customAttrC);
1321-
auto *macroDecl = D->getResolvedMacro(customAttr);
1322-
if (macroDecl) {
1323-
diagnoseDeclAvailability(
1324-
macroDecl, customAttr->getTypeRepr()->getSourceRange(), nullptr,
1325-
ExportContext::forDeclSignature(const_cast<Decl *>(D)),
1326-
std::nullopt);
1327-
}
1328-
}
1329-
}
13301316
};
13311317

13321318
class UsableFromInlineChecker : public AccessControlCheckerBase,
@@ -2141,9 +2127,22 @@ class DeclAvailabilityChecker : public DeclVisitor<DeclAvailabilityChecker> {
21412127
checkType(customAttr->getType(), customAttr->getTypeRepr(), D);
21422128
}
21432129

2130+
void checkAttachedMacros(const Decl *D) {
2131+
for (auto customAttrC : D->getExpandedAttrs().getAttributes<CustomAttr>()) {
2132+
auto customAttr = const_cast<CustomAttr *>(customAttrC);
2133+
auto *macroDecl = D->getResolvedMacro(customAttr);
2134+
if (macroDecl) {
2135+
diagnoseDeclAvailability(macroDecl,
2136+
customAttr->getTypeRepr()->getSourceRange(),
2137+
nullptr, Where, std::nullopt);
2138+
}
2139+
}
2140+
}
2141+
21442142
void visit(Decl *D) {
21452143
DeclVisitor<DeclAvailabilityChecker>::visit(D);
21462144
checkGlobalActor(D);
2145+
checkAttachedMacros(D);
21472146
}
21482147

21492148
// Force all kinds to be handled at a lower level.

0 commit comments

Comments
 (0)