[Sema] Diagnose unsound pointer conversions

Diagnose ephemeral conversions that are passed to @_nonEphemeral
parameters. Currently, this defaults to a warning with a frontend flag
to upgrade to an error. Hopefully this will become an error by default
in a future language version.
This commit is contained in:
Hamish Knight
2019-10-03 17:00:02 -07:00
parent 92c42ec791
commit 7077a68b83
19 changed files with 1510 additions and 4 deletions

View File

@@ -99,7 +99,6 @@ unsigned LocatorPathElt::getNewSummaryFlags() const {
switch (getKind()) {
case ConstraintLocator::ApplyArgument:
case ConstraintLocator::ApplyFunction:
case ConstraintLocator::ApplyArgToParam:
case ConstraintLocator::SequenceElementType:
case ConstraintLocator::ClosureResult:
case ConstraintLocator::ConstructorMember:
@@ -139,6 +138,11 @@ unsigned LocatorPathElt::getNewSummaryFlags() const {
case ConstraintLocator::FunctionArgument:
case ConstraintLocator::FunctionResult:
return IsFunctionConversion;
case ConstraintLocator::ApplyArgToParam: {
auto flags = castTo<LocatorPathElt::ApplyArgToParam>().getParameterFlags();
return flags.isNonEphemeral() ? IsNonEphemeralParam : 0;
}
}
llvm_unreachable("Unhandled PathElementKind in switch.");