@@ -2309,8 +2309,36 @@ void AttributeChecker::visitExternAttr(ExternAttr *attr) {
2309
2309
}
2310
2310
}
2311
2311
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
+
2312
2340
void AttributeChecker::visitUsedAttr (UsedAttr *attr) {
2313
- if (!Ctx. LangOpts . hasFeature (Feature::SymbolLinkageMarkers )) {
2341
+ if (!allowSymbolLinkageMarkers (Ctx, D )) {
2314
2342
diagnoseAndRemoveAttr (attr, diag::section_linkage_markers_disabled);
2315
2343
return ;
2316
2344
}
@@ -2336,7 +2364,7 @@ void AttributeChecker::visitUsedAttr(UsedAttr *attr) {
2336
2364
}
2337
2365
2338
2366
void AttributeChecker::visitSectionAttr (SectionAttr *attr) {
2339
- if (!Ctx. LangOpts . hasFeature (Feature::SymbolLinkageMarkers )) {
2367
+ if (!allowSymbolLinkageMarkers (Ctx, D )) {
2340
2368
diagnoseAndRemoveAttr (attr, diag::section_linkage_markers_disabled);
2341
2369
return ;
2342
2370
}
0 commit comments