@@ -2376,8 +2376,36 @@ void AttributeChecker::visitExternAttr(ExternAttr *attr) {
23762376 }
23772377}
23782378
2379+ static bool allowSymbolLinkageMarkers (ASTContext &ctx, Decl *D) {
2380+ if (ctx.LangOpts .hasFeature (Feature::SymbolLinkageMarkers))
2381+ return true ;
2382+
2383+ auto *sourceFile = D->getDeclContext ()->getParentModule ()
2384+ ->getSourceFileContainingLocation (D->getStartLoc ());
2385+ if (!sourceFile)
2386+ return false ;
2387+
2388+ auto expansion = sourceFile->getMacroExpansion ();
2389+ auto *macroAttr = sourceFile->getAttachedMacroAttribute ();
2390+ if (!expansion || !macroAttr)
2391+ return false ;
2392+
2393+ auto *decl = expansion.dyn_cast <Decl *>();
2394+ if (!decl)
2395+ return false ;
2396+
2397+ auto *macroDecl = decl->getResolvedMacro (macroAttr);
2398+ if (!macroDecl)
2399+ return false ;
2400+
2401+ if (macroDecl->getParentModule ()->isStdlibModule () &&
2402+ macroDecl->getName ().getBaseIdentifier ()
2403+ .str ().equals (" _DebugDescriptionProperty" ))
2404+ return true ;
2405+ }
2406+
23792407void AttributeChecker::visitUsedAttr (UsedAttr *attr) {
2380- if (!Ctx. LangOpts . hasFeature (Feature::SymbolLinkageMarkers )) {
2408+ if (!allowSymbolLinkageMarkers (Ctx, D )) {
23812409 diagnoseAndRemoveAttr (attr, diag::section_linkage_markers_disabled);
23822410 return ;
23832411 }
@@ -2403,7 +2431,7 @@ void AttributeChecker::visitUsedAttr(UsedAttr *attr) {
24032431}
24042432
24052433void AttributeChecker::visitSectionAttr (SectionAttr *attr) {
2406- if (!Ctx. LangOpts . hasFeature (Feature::SymbolLinkageMarkers )) {
2434+ if (!allowSymbolLinkageMarkers (Ctx, D )) {
24072435 diagnoseAndRemoveAttr (attr, diag::section_linkage_markers_disabled);
24082436 return ;
24092437 }
0 commit comments