@@ -2309,8 +2309,36 @@ void AttributeChecker::visitExternAttr(ExternAttr *attr) {
23092309 }
23102310}
23112311
2312+ static bool allowSymbolLinkageMarkers (ASTContext &ctx, Decl *D) {
2313+ if (ctx.LangOpts .hasFeature (Feature::SymbolLinkageMarkers))
2314+ return true ;
2315+
2316+ auto *sourceFile = D->getDeclContext ()->getParentModule ()
2317+ ->getSourceFileContainingLocation (D->getStartLoc ());
2318+ if (!sourceFile)
2319+ return false ;
2320+
2321+ auto expansion = sourceFile->getMacroExpansion ();
2322+ auto *macroAttr = sourceFile->getAttachedMacroAttribute ();
2323+ if (!expansion || !macroAttr)
2324+ return false ;
2325+
2326+ auto *decl = expansion.dyn_cast <Decl *>();
2327+ if (!decl)
2328+ return false ;
2329+
2330+ auto *macroDecl = decl->getResolvedMacro (macroAttr);
2331+ if (!macroDecl)
2332+ return false ;
2333+
2334+ if (macroDecl->getParentModule ()->isStdlibModule () &&
2335+ macroDecl->getName ().getBaseIdentifier ()
2336+ .str ().equals (" _DebugDescriptionProperty" ))
2337+ return true ;
2338+ }
2339+
23122340void AttributeChecker::visitUsedAttr (UsedAttr *attr) {
2313- if (!Ctx. LangOpts . hasFeature (Feature::SymbolLinkageMarkers )) {
2341+ if (!allowSymbolLinkageMarkers (Ctx, D )) {
23142342 diagnoseAndRemoveAttr (attr, diag::section_linkage_markers_disabled);
23152343 return ;
23162344 }
@@ -2336,7 +2364,7 @@ void AttributeChecker::visitUsedAttr(UsedAttr *attr) {
23362364}
23372365
23382366void AttributeChecker::visitSectionAttr (SectionAttr *attr) {
2339- if (!Ctx. LangOpts . hasFeature (Feature::SymbolLinkageMarkers )) {
2367+ if (!allowSymbolLinkageMarkers (Ctx, D )) {
23402368 diagnoseAndRemoveAttr (attr, diag::section_linkage_markers_disabled);
23412369 return ;
23422370 }
0 commit comments