Skip to content
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
1 change: 1 addition & 0 deletions test/api-digester/Inputs/cake_baseline/color.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public enum Color { case Red }
6 changes: 6 additions & 0 deletions test/api-digester/Inputs/cake_current/color.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public enum Color { case Red }

extension Color: RawRepresentable {
public var rawValue: String { return "" }
public init(rawValue: String) { self = .Red }
}
2 changes: 2 additions & 0 deletions test/api-digester/Outputs/color.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
color: Func Color.hash(into:) has been removed
color: Var Color.hashValue has been removed
11 changes: 11 additions & 0 deletions test/api-digester/compare-dump.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@
// RUN: %clang -E -P -x c %S/Outputs/Cake.txt -o - | sed '/^\s*$/d' > %t.expected
// RUN: %clang -E -P -x c %t.result -o - | sed '/^\s*$/d' > %t.result.tmp
// RUN: diff -u %t.expected %t.result.tmp

// Run another module API checking without -enable-library-evolution
// RUN: %swift -emit-module -o %t.mod1/color.swiftmodule %S/Inputs/cake_baseline/color.swift -parse-as-library -I %S/Inputs/APINotesLeft %clang-importer-sdk-nosource -module-name color
// RUN: %swift -emit-module -o %t.mod2/color.swiftmodule %S/Inputs/cake_current/color.swift -parse-as-library -I %S/Inputs/APINotesRight %clang-importer-sdk-nosource -module-name color
// RUN: %api-digester -dump-sdk -module color -o - -module-cache-path %t.module-cache %clang-importer-sdk-nosource -I %t.mod1 -I %S/Inputs/APINotesLeft > %t.dump1.json
// RUN: %api-digester -dump-sdk -module color -o - -module-cache-path %t.module-cache %clang-importer-sdk-nosource -I %t.mod2 -I %S/Inputs/APINotesLeft > %t.dump2.json
// RUN: %api-digester -diagnose-sdk -print-module --input-paths %t.dump1.json -input-paths %t.dump2.json -o %t.result

// RUN: %clang -E -P -x c %S/Outputs/color.txt -o - | sed '/^\s*$/d' > %t.expected
// RUN: %clang -E -P -x c %t.result -o - | sed '/^\s*$/d' > %t.result.tmp
// RUN: diff -u %t.expected %t.result.tmp
4 changes: 4 additions & 0 deletions tools/swift-api-digester/ModuleAnalyzerNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ class SDKContext {
std::vector<BreakingAttributeInfo> BreakingAttrs;

public:
// Define the set of known identifiers.
#define IDENTIFIER_WITH_NAME(Name, IdStr) StringRef Id_##Name = IdStr;
#include "swift/AST/KnownIdentifiers.def"

SDKContext(CheckerOptions Options);
llvm::BumpPtrAllocator &allocator() {
return Allocator;
Expand Down
12 changes: 12 additions & 0 deletions tools/swift-api-digester/swift-api-digester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,18 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
}
if (FoundInSuperclass)
return;

// When diagnosing API changes, avoid complaining the removal of these
// synthesized functions since they are compiler implementation details.
// If an enum is no longer equatable, another diagnostic about removing
// conforming protocol will be emitted.
if (!Ctx.checkingABI()) {
if (Node->getName() == Ctx.Id_derived_struct_equals ||
Node->getName() == Ctx.Id_derived_enum_equals) {
return;
}
}

Node->emitDiag(diag::removed_decl, Node->isDeprecated());
return;
}
Expand Down