@@ -2376,8 +2376,36 @@ void AttributeChecker::visitExternAttr(ExternAttr *attr) {
2376
2376
}
2377
2377
}
2378
2378
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
+
2379
2407
void AttributeChecker::visitUsedAttr (UsedAttr *attr) {
2380
- if (!Ctx. LangOpts . hasFeature (Feature::SymbolLinkageMarkers )) {
2408
+ if (!allowSymbolLinkageMarkers (Ctx, D )) {
2381
2409
diagnoseAndRemoveAttr (attr, diag::section_linkage_markers_disabled);
2382
2410
return ;
2383
2411
}
@@ -2403,7 +2431,7 @@ void AttributeChecker::visitUsedAttr(UsedAttr *attr) {
2403
2431
}
2404
2432
2405
2433
void AttributeChecker::visitSectionAttr (SectionAttr *attr) {
2406
- if (!Ctx. LangOpts . hasFeature (Feature::SymbolLinkageMarkers )) {
2434
+ if (!allowSymbolLinkageMarkers (Ctx, D )) {
2407
2435
diagnoseAndRemoveAttr (attr, diag::section_linkage_markers_disabled);
2408
2436
return ;
2409
2437
}
0 commit comments