Skip to content

Commit 6a34ed0

Browse files
committed
Sema: Remove NPCR diagnostics
1 parent ae1e5b1 commit 6a34ed0

File tree

4 files changed

+0
-145
lines changed

4 files changed

+0
-145
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,6 @@ ERROR(incorrect_explicit_closure_result,none,
289289
"declared closure result %0 is incompatible with contextual type %1",
290290
(Type, Type))
291291

292-
ERROR(err_noescape_param_call,none,
293-
"passing a %select{|closure which captures a }1non-escaping function "
294-
"parameter %0 to a call to a non-escaping function parameter can allow "
295-
"re-entrant modification of a variable",
296-
(DeclName, unsigned))
297292
ERROR(cannot_call_function_value,none,
298293
"cannot invoke value of function type with argument list '%0'",
299294
(StringRef))

lib/Sema/MiscDiagnostics.cpp

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,6 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
179179

180180
ConcreteDeclRef callee;
181181
if (auto *calleeDRE = dyn_cast<DeclRefExpr>(base)) {
182-
// This only cares about declarations of noescape function type.
183-
auto AFT = calleeDRE->getType()->getAs<FunctionType>();
184-
if (AFT && AFT->isNoEscape())
185-
checkNoEscapeParameterCall(Call);
186182
checkForSuspiciousBitCasts(calleeDRE, Call);
187183
callee = calleeDRE->getDeclRef();
188184

@@ -416,104 +412,6 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
416412
TC.diagnose(E->getStartLoc(), diag::value_of_module_type);
417413
}
418414

419-
class NoEscapeArgument {
420-
llvm::PointerIntPair<ParamDecl*, 1, bool> ParamAndIsCapture;
421-
public:
422-
NoEscapeArgument() {}
423-
NoEscapeArgument(ParamDecl *param, bool isCapture)
424-
: ParamAndIsCapture(param, isCapture) {
425-
assert(param);
426-
}
427-
428-
explicit operator bool() const {
429-
return ParamAndIsCapture.getPointer() != nullptr;
430-
}
431-
432-
ParamDecl *getDecl() const { return ParamAndIsCapture.getPointer(); }
433-
bool isDeclACapture() const { return ParamAndIsCapture.getInt(); }
434-
435-
static NoEscapeArgument find(TypeChecker &tc, ValueDecl *decl,
436-
bool isCapture) {
437-
if (auto param = dyn_cast<ParamDecl>(decl)) {
438-
if (auto fnType =
439-
param->getInterfaceType()->getAs<AnyFunctionType>()) {
440-
if (fnType->isNoEscape())
441-
return { param, isCapture };
442-
}
443-
return {};
444-
}
445-
446-
if (auto fn = dyn_cast<AbstractFunctionDecl>(decl)) {
447-
if (fn->getDeclContext()->isLocalContext()) {
448-
return findInCaptures(tc, fn);
449-
}
450-
return {};
451-
}
452-
453-
// FIXME: captures of computed local vars? Can these be non-escaping?
454-
return {};
455-
}
456-
457-
static NoEscapeArgument findInCaptures(TypeChecker &tc,
458-
AnyFunctionRef fn) {
459-
// Ensure we have accurate capture information for the function.
460-
tc.computeCaptures(fn);
461-
462-
for (const auto &capture : fn.getCaptureInfo().getCaptures()) {
463-
if (capture.isDynamicSelfMetadata()) continue;
464-
if (auto param = find(tc, capture.getDecl(), true))
465-
return param;
466-
}
467-
return {};
468-
}
469-
};
470-
471-
/// Enforce the exclusivity rule against calling a non-escaping
472-
/// function parameter with another non-escaping function parameter
473-
/// as an argument.
474-
void checkNoEscapeParameterCall(ApplyExpr *apply) {
475-
NoEscapeArgument noescapeArgument;
476-
Expr *problematicArg = nullptr;
477-
478-
visitArguments(apply, [&](unsigned argIndex, Expr *arg) {
479-
// Just find the first problematic argument.
480-
if (noescapeArgument) return;
481-
482-
// Remember the expression which used the argument.
483-
problematicArg = arg;
484-
485-
// Look through the same set of nodes that we look through when
486-
// checking for no-escape functions.
487-
arg = lookThroughArgument(arg);
488-
489-
// If the argument isn't noescape, ignore it.
490-
auto fnType = arg->getType()->getAs<AnyFunctionType>();
491-
if (!fnType || !fnType->isNoEscape())
492-
return;
493-
494-
// Okay, it should be a closure or a decl ref.
495-
if (auto declRef = dyn_cast<DeclRefExpr>(arg)) {
496-
noescapeArgument =
497-
NoEscapeArgument::find(TC, declRef->getDecl(), false);
498-
} else if (auto closure = dyn_cast<AbstractClosureExpr>(arg)) {
499-
noescapeArgument =
500-
NoEscapeArgument::findInCaptures(TC, closure);
501-
} else {
502-
// This can happen with withoutActuallyEscaping.
503-
assert(isa<OpaqueValueExpr>(arg) &&
504-
"unexpected expression yielding noescape closure");
505-
}
506-
});
507-
508-
if (!noescapeArgument) return;
509-
510-
TC.diagnose(apply->getLoc(),
511-
diag::err_noescape_param_call,
512-
noescapeArgument.getDecl()->getName(),
513-
noescapeArgument.isDeclACapture())
514-
.highlight(problematicArg->getSourceRange());
515-
}
516-
517415
// Diagnose metatype values that don't appear as part of a property,
518416
// method, or constructor reference.
519417
void checkUseOfMetaTypeName(Expr *E) {

test/attr/attr_noescape.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ func doThing4(_ completion: @escaping CompletionHandler) {
303303
func apply<T, U>(_ f: @noescape (T) -> U, g: @noescape (@noescape (T) -> U) -> U) -> U {
304304
// expected-error@-1 6{{unknown attribute 'noescape'}}
305305
return g(f)
306-
// expected-error@-1 {{passing a non-escaping function parameter 'f' to a call to a non-escaping function parameter can allow re-entrant modification of a variable}}
307306
}
308307

309308
// <rdar://problem/19997577> @noescape cannot be applied to locals, leading to duplication of code

test/expr/postfix/call/noescape-param-exclusivity.swift

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)