Skip to content

Commit 81b68e5

Browse files
committed
[Strict memory safety] Temporarily disable warning about stray "unsafe" in _SwiftifyImport expansions
We need to improve on the macro so it doesn't generate unnecessary "unsafe" expressions.
1 parent 050a514 commit 81b68e5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/Sema/TypeCheckEffects.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4595,6 +4595,15 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
45954595
if (!Ctx.LangOpts.hasFeature(Feature::StrictMemorySafety))
45964596
return;
45974597

4598+
// Silence this warning in the expansion of the _SwiftifyImport macro.
4599+
// This is a hack because it's tricky to determine when to insert "unsafe".
4600+
unsigned bufferID =
4601+
Ctx.SourceMgr.findBufferContainingLoc(E->getUnsafeLoc());
4602+
if (auto sourceInfo = Ctx.SourceMgr.getGeneratedSourceInfo(bufferID)) {
4603+
if (sourceInfo->macroName == "_SwiftifyImport")
4604+
return;
4605+
}
4606+
45984607
if (auto *SVE = SingleValueStmtExpr::tryDigOutSingleValueStmtExpr(E)) {
45994608
// For an if/switch expression, produce a tailored warning.
46004609
Ctx.Diags.diagnose(E->getUnsafeLoc(),

0 commit comments

Comments
 (0)