Skip to content

swift-module-digester: include operator overloads in the module dump. #19620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/api-digester/Inputs/cake.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ public protocol PSub: PSuper {
}

public let GlobalVar = 1

public extension P1 {
static func +(lhs: P1, rhs: P1) -> P1 { return lhs }
}
32 changes: 32 additions & 0 deletions test/api-digester/Outputs/cake-abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,38 @@
"kind": "TypeDecl",
"name": "P1",
"printedName": "P1",
"children": [
{
"kind": "Function",
"name": "+",
"printedName": "+(_:_:)",
"children": [
{
"kind": "TypeNominal",
"name": "P1",
"printedName": "P1",
"usr": "s:4cake2P1P"
},
{
"kind": "TypeNominal",
"name": "P1",
"printedName": "P1",
"usr": "s:4cake2P1P"
},
{
"kind": "TypeNominal",
"name": "P1",
"printedName": "P1",
"usr": "s:4cake2P1P"
}
],
"declKind": "Func",
"usr": "s:4cake2P1PAAE1poiyAaB_pAaB_p_AaB_ptFZ",
"moduleName": "cake",
"genericSig": "<τ_0_0 where τ_0_0 : P1>",
"static": true
}
],
"declKind": "Protocol",
"usr": "s:4cake2P1P",
"moduleName": "cake"
Expand Down
32 changes: 32 additions & 0 deletions test/api-digester/Outputs/cake.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,38 @@
"kind": "TypeDecl",
"name": "P1",
"printedName": "P1",
"children": [
{
"kind": "Function",
"name": "+",
"printedName": "+(_:_:)",
"children": [
{
"kind": "TypeNominal",
"name": "P1",
"printedName": "P1",
"usr": "s:4cake2P1P"
},
{
"kind": "TypeNominal",
"name": "P1",
"printedName": "P1",
"usr": "s:4cake2P1P"
},
{
"kind": "TypeNominal",
"name": "P1",
"printedName": "P1",
"usr": "s:4cake2P1P"
}
],
"declKind": "Func",
"usr": "s:4cake2P1PAAE1poiyAaB_pAaB_p_AaB_ptFZ",
"moduleName": "cake",
"genericSig": "<Self where Self : P1>",
"static": true
}
],
"declKind": "Protocol",
"usr": "s:4cake2P1P",
"moduleName": "cake"
Expand Down
36 changes: 36 additions & 0 deletions test/api-digester/source-stability.swift.expected
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,43 @@ AssociatedType StringProtocol.UTF16View has been added as a protocol requirement
AssociatedType StringProtocol.UTF8View has been added as a protocol requirement
AssociatedType StringProtocol.UnicodeScalarView has been added as a protocol requirement
AssociatedType _SequenceWrapper.Base has been added as a protocol requirement


// These operator changes are false positive because the baseline doesn't have operators.
Func BinaryInteger.%(_:_:) has been added as a protocol requirement
Func BinaryInteger.%=(_:_:) has been added as a protocol requirement
Func BinaryInteger.&(_:_:) has been added as a protocol requirement
Func BinaryInteger.&=(_:_:) has been added as a protocol requirement
Func BinaryInteger.<<(_:_:) has been added as a protocol requirement
Func BinaryInteger.<<=(_:_:) has been added as a protocol requirement
Func BinaryInteger.>>(_:_:) has been added as a protocol requirement
Func BinaryInteger.>>=(_:_:) has been added as a protocol requirement
Func BinaryInteger.\/(_:_:) has been added as a protocol requirement
Func BinaryInteger.\/=(_:_:) has been added as a protocol requirement
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like something got escaped improperly.

Func BinaryInteger.^(_:_:) has been added as a protocol requirement
Func BinaryInteger.^=(_:_:) has been added as a protocol requirement
Func BinaryInteger.isMultiple(of:) has been added as a protocol requirement
Func BinaryInteger.|(_:_:) has been added as a protocol requirement
Func BinaryInteger.|=(_:_:) has been added as a protocol requirement
Func BinaryInteger.~(_:) has been added as a protocol requirement
Func Comparable.<(_:_:) has been added as a protocol requirement
Func Comparable.<=(_:_:) has been added as a protocol requirement
Func Comparable.>(_:_:) has been added as a protocol requirement
Func Comparable.>=(_:_:) has been added as a protocol requirement
Func Equatable.==(_:_:) has been added as a protocol requirement
Func FixedWidthInteger.&<<(_:_:) has been added as a protocol requirement
Func FixedWidthInteger.&<<=(_:_:) has been added as a protocol requirement
Func FixedWidthInteger.&>>(_:_:) has been added as a protocol requirement
Func FixedWidthInteger.&>>=(_:_:) has been added as a protocol requirement
Func FloatingPoint.\/(_:_:) has been added as a protocol requirement
Func FloatingPoint.\/=(_:_:) has been added as a protocol requirement
Func Numeric.*(_:_:) has been added as a protocol requirement
Func Numeric.*=(_:_:) has been added as a protocol requirement
Func Numeric.+(_:_:) has been added as a protocol requirement
Func Numeric.+=(_:_:) has been added as a protocol requirement
Func Numeric.-(_:_:) has been added as a protocol requirement
Func Numeric.-=(_:_:) has been added as a protocol requirement
Func SignedNumeric.-(_:) has been added as a protocol requirement

// The subscript changes are bogus because we don't have subscript decls in the baseline.
Subscript Collection.subscript(_:) has been added as a protocol requirement
10 changes: 4 additions & 6 deletions tools/swift-api-digester/ModuleAnalyzerNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,8 +1129,6 @@ SwiftDeclCollector::shouldIgnore(Decl *D, const Decl* Parent) {
if (isa<OperatorDecl>(D))
return true;
if (auto VD = dyn_cast<ValueDecl>(D)) {
if (VD->isOperator())
return true;
if (VD->getBaseName().empty())
return true;

Expand Down Expand Up @@ -1325,12 +1323,12 @@ void SwiftDeclCollector::processDecl(ValueDecl *VD) {
RootNode->addChild(constructFunctionNode(FD, SDKNodeKind::DeclFunction));
} else if (auto NTD = dyn_cast<NominalTypeDecl>(VD)) {
RootNode->addChild(constructTypeDeclNode(NTD));
}
if (auto VAD = dyn_cast<VarDecl>(VD)) {
} else if (auto VAD = dyn_cast<VarDecl>(VD)) {
RootNode->addChild(constructVarNode(VAD));
}
if (auto TAD = dyn_cast<TypeAliasDecl>(VD)) {
} else if (auto TAD = dyn_cast<TypeAliasDecl>(VD)) {
RootNode->addChild(constructTypeAliasNode(TAD));
} else {
llvm_unreachable("unhandled value decl");
}
}

Expand Down