Skip to content

Commit 1db020d

Browse files
authored
Merge pull request #75324 from hborla/6.0-disable-symbol-linkage
2 parents b8ebe48 + 13a07b8 commit 1db020d

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,10 +1565,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
15651565
Opts.UseCheckedAsyncObjCBridging = true;
15661566
}
15671567

1568-
// @DebugDescription uses @_section and @_used attributes.
1569-
if (Opts.hasFeature(Feature::DebugDescriptionMacro))
1570-
Opts.enableFeature(Feature::SymbolLinkageMarkers);
1571-
15721568
Opts.DisableDynamicActorIsolation |=
15731569
Args.hasArg(OPT_disable_dynamic_actor_isolation);
15741570

lib/Sema/TypeCheckAttr.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
23122340
void 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

23382366
void 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

Comments
 (0)