Skip to content

Commit 02eb552

Browse files
committed
Sema: Two small cleanups for inout capture @NoEscape change
1) ValueDecl::hasInterfaceType() is broken because it means "we have computed the interface type" not "there is an interface type that can be computed". The distinction comes into play with decls where the interface type is never set explicitly. 2) Use foo->is<InOutType>() instead of isa<InOutType>(foo.getPointer()); this is cleaner. 3) Use DeclContext::isLocalContext() instead of checking if the context is an AbstractFunctionDecl. These should be NFC for the most part.
1 parent 3e3fe3f commit 02eb552

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/Sema/TypeCheckExpr.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -973,13 +973,10 @@ namespace {
973973
if (!validateForwardCapture(DRE->getDecl()))
974974
return { false, DRE };
975975

976-
bool isInOut = D->hasInterfaceType()
977-
&& isa<InOutType>(D->getInterfaceType().getPointer());
976+
bool isInOut = D->hasType() && D->getInterfaceType()->is<InOutType>();
978977
bool isNested = false;
979-
if (auto f = AFR.getAbstractFunctionDecl()) {
980-
isNested = f->getDeclContext()->getContextKind() ==
981-
DeclContextKind::AbstractFunctionDecl;
982-
}
978+
if (auto f = AFR.getAbstractFunctionDecl())
979+
isNested = f->getDeclContext()->isLocalContext();
983980

984981
if (isInOut && !AFR.isKnownNoEscape() && !isNested) {
985982
if (D->getNameStr() == "self") {

0 commit comments

Comments
 (0)