mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
swift-module-digester: diagnose value ownership changes for parameters.
This commit is contained in:
@@ -86,6 +86,8 @@ ERROR(func_type_escaping_changed,none,"%0 has %select{removed|added}2 @escaping
|
||||
|
||||
ERROR(func_self_access_change,none,"%0 has self access kind changing from %1 to %2", (StringRef, StringRef, StringRef))
|
||||
|
||||
ERROR(param_ownership_change,none,"%0 has %1 changing from %2 to %3", (StringRef, StringRef, StringRef, StringRef))
|
||||
|
||||
#ifndef DIAG_NO_UNDEF
|
||||
# if defined(DIAG)
|
||||
# undef DIAG
|
||||
|
||||
@@ -134,3 +134,5 @@ public class EscapingFunctionType {
|
||||
}
|
||||
|
||||
infix operator ..*..
|
||||
|
||||
public func ownershipChange(_ a: inout Int, _ b: __shared Int) {}
|
||||
|
||||
@@ -144,3 +144,5 @@ public class EscapingFunctionType {
|
||||
}
|
||||
|
||||
prefix operator ..*..
|
||||
|
||||
public func ownershipChange(_ a: Int, _ b: __owned Int) {}
|
||||
|
||||
@@ -36,6 +36,8 @@ cake1: Func C7.foo(_:_:) has removed default argument from parameter 1
|
||||
cake1: Func EscapingFunctionType.addedEscaping(_:) has added @escaping in parameter 0
|
||||
cake1: Func EscapingFunctionType.removedEscaping(_:) has removed @escaping in parameter 0
|
||||
cake1: Func Somestruct2.foo1(_:) has parameter 0 type change from C3 to C1
|
||||
cake1: Func ownershipChange(_:_:) has parameter 0 changing from InOut to Default
|
||||
cake1: Func ownershipChange(_:_:) has parameter 1 changing from Shared to Owned
|
||||
|
||||
/* Decl Attribute changes */
|
||||
cake1: Class C5 is now without @objc
|
||||
|
||||
@@ -31,6 +31,8 @@ cake1: Constructor S1.init(_:) has parameter 0 type change from Int to Double
|
||||
cake1: Func C1.foo2(_:) has parameter 0 type change from Int to () -> ()
|
||||
cake1: Func C7.foo(_:_:) has removed default argument from parameter 0
|
||||
cake1: Func C7.foo(_:_:) has removed default argument from parameter 1
|
||||
cake1: Func ownershipChange(_:_:) has parameter 0 changing from InOut to Default
|
||||
cake1: Func ownershipChange(_:_:) has parameter 1 changing from Shared to Owned
|
||||
|
||||
/* Decl Attribute changes */
|
||||
cake1: Func C1.foo1() is now not static
|
||||
|
||||
@@ -312,6 +312,10 @@ bool SDKNodeType::hasTypeAttribute(TypeAttrKind DAKind) const {
|
||||
TypeAttributes.end();
|
||||
}
|
||||
|
||||
StringRef SDKNodeType::getParamValueOwnership() const {
|
||||
return ParamValueOwnership.empty() ? "Default" : ParamValueOwnership;
|
||||
}
|
||||
|
||||
StringRef SDKNodeType::getTypeRoleDescription() const {
|
||||
assert(isTopLevelType());
|
||||
auto P = cast<SDKNodeDecl>(getParent());
|
||||
|
||||
@@ -368,7 +368,7 @@ public:
|
||||
bool hasDefaultArgument() const { return HasDefaultArg; }
|
||||
bool isTopLevelType() const { return !isa<SDKNodeType>(getParent()); }
|
||||
StringRef getTypeRoleDescription() const;
|
||||
StringRef getParamValueOwnership() const { return ParamValueOwnership; }
|
||||
StringRef getParamValueOwnership() const;
|
||||
static bool classof(const SDKNode *N);
|
||||
virtual void jsonize(json::Output &Out) override;
|
||||
virtual void diagnose(SDKNode *Right) override;
|
||||
|
||||
@@ -48,6 +48,7 @@ static StringRef getCategoryName(uint32_t ID) {
|
||||
case LocalDiagID::default_arg_removed:
|
||||
case LocalDiagID::decl_type_change:
|
||||
case LocalDiagID::func_type_escaping_changed:
|
||||
case LocalDiagID::param_ownership_change:
|
||||
return "/* Type Changes */";
|
||||
case LocalDiagID::raw_type_change:
|
||||
return "/* RawRepresentable Changes */";
|
||||
|
||||
@@ -871,6 +871,13 @@ void swift::ide::api::SDKNodeType::diagnose(SDKNode *Right) {
|
||||
Diags.diagnose(SourceLoc(), diag::default_arg_removed,
|
||||
LParent->getScreenInfo(), Descriptor);
|
||||
}
|
||||
if (getParamValueOwnership() != RT->getParamValueOwnership()) {
|
||||
Diags.diagnose(SourceLoc(), diag::param_ownership_change,
|
||||
getParent()->getAs<SDKNodeDecl>()->getScreenInfo(),
|
||||
getTypeRoleDescription(),
|
||||
getParamValueOwnership(),
|
||||
RT->getParamValueOwnership());
|
||||
}
|
||||
}
|
||||
|
||||
void swift::ide::api::SDKNodeTypeFunc::diagnose(SDKNode *Right) {
|
||||
|
||||
Reference in New Issue
Block a user