Skip to content

Commit 06e6116

Browse files
committed
[Clang importer] Infer @unsafe independent of strict safety checking mode
1 parent 7c7ea1d commit 06e6116

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
@@ -2038,10 +2038,8 @@ namespace {
20382038
if (Impl.SwiftContext.LangOpts.hasFeature(Feature::LifetimeDependence)) {
20392039
fd->getAttrs().add(new (Impl.SwiftContext)
20402040
UnsafeNonEscapableResultAttr(/*Implicit=*/true));
2041-
if (Impl.SwiftContext.LangOpts.hasFeature(
2042-
Feature::StrictMemorySafety))
2043-
fd->getAttrs().add(new (Impl.SwiftContext)
2044-
UnsafeAttr(/*Implicit=*/true));
2041+
fd->getAttrs().add(new (Impl.SwiftContext)
2042+
UnsafeAttr(/*Implicit=*/true));
20452043
}
20462044
}
20472045

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

0 commit comments

Comments
 (0)