Skip to content

Commit bad5adb

Browse files
authored
Merge pull request #79680 from DougGregor/clang-importer-always-unsafe
[Clang importer] Infer @unsafe independent of strict safety checking mode
2 parents 25186b2 + 06e6116 commit bad5adb

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,10 +2039,8 @@ namespace {
20392039
if (Impl.SwiftContext.LangOpts.hasFeature(Feature::LifetimeDependence)) {
20402040
fd->getAttrs().add(new (Impl.SwiftContext)
20412041
UnsafeNonEscapableResultAttr(/*Implicit=*/true));
2042-
if (Impl.SwiftContext.LangOpts.hasFeature(
2043-
Feature::StrictMemorySafety))
2044-
fd->getAttrs().add(new (Impl.SwiftContext)
2045-
UnsafeAttr(/*Implicit=*/true));
2042+
fd->getAttrs().add(new (Impl.SwiftContext)
2043+
UnsafeAttr(/*Implicit=*/true));
20462044
}
20472045
}
20482046

@@ -4179,19 +4177,19 @@ namespace {
41794177
LifetimeDependenceInfoRequest{result},
41804178
Impl.SwiftContext.AllocateCopy(lifetimeDependencies));
41814179
}
4182-
if (ASTContext.LangOpts.hasFeature(Feature::StrictMemorySafety)) {
4183-
for (auto [idx, param] : llvm::enumerate(decl->parameters())) {
4184-
if (swiftParams->get(idx)->getInterfaceType()->isEscapable())
4185-
continue;
4186-
if (param->hasAttr<clang::NoEscapeAttr>() || paramHasAnnotation[idx])
4187-
continue;
4188-
// We have a nonescapable parameter that does not have its lifetime
4189-
// annotated nor is it marked noescape.
4190-
auto attr = new (ASTContext) UnsafeAttr(/*implicit=*/true);
4191-
result->getAttrs().add(attr);
4192-
break;
4193-
}
4180+
4181+
for (auto [idx, param] : llvm::enumerate(decl->parameters())) {
4182+
if (swiftParams->get(idx)->getInterfaceType()->isEscapable())
4183+
continue;
4184+
if (param->hasAttr<clang::NoEscapeAttr>() || paramHasAnnotation[idx])
4185+
continue;
4186+
// We have a nonescapable parameter that does not have its lifetime
4187+
// annotated nor is it marked noescape.
4188+
auto attr = new (ASTContext) UnsafeAttr(/*implicit=*/true);
4189+
result->getAttrs().add(attr);
4190+
break;
41944191
}
4192+
41954193
Impl.diagnoseTargetDirectly(decl);
41964194
}
41974195

0 commit comments

Comments
 (0)