Skip to content

Commit 00577ac

Browse files
committedSep 14, 2020
ABI checker: when invoking via build system, explicitly mention ABI breakge in diagnostics
The error messages emitted from the ABI checker are mostly explanations of breakages. We should explicitly mention why they are emitted to differentiate them from other compiler diagnostics. rdar://68864860

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed
 

‎test/api-digester/breakage-allowlist.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@
1010
// RUN: echo "public func foo() {}" > %t.mod1/Foo.swift
1111
// RUN: echo "public func bar() {}" > %t.mod2/Foo.swift
1212

13-
// RUN: echo "Foo: func foo() has been removed" > %t/incomplete-allowlist.txt
14-
// RUN: echo "Foo: func foo() has been removed" > %t/complete-allowlist.txt
15-
// RUN: echo "Foo: func bar() is a new API without @available attribute" >> %t/complete-allowlist.txt
13+
// RUN: echo "ABI breakage: func foo() has been removed" > %t/incomplete-allowlist.txt
14+
// RUN: echo "ABI breakage: func foo() has been removed" > %t/complete-allowlist.txt
15+
// RUN: echo "ABI breakage: func bar() is a new API without @available attribute" >> %t/complete-allowlist.txt
1616

1717
// RUN: %target-swift-frontend -disable-objc-attr-requires-foundation-module -emit-module -o %t.mod1/Foo.swiftmodule %t.mod1/Foo.swift -parse-as-library -enable-library-evolution -emit-module-source-info -emit-module-source-info-path %t.mod1/Foo.swiftsourceinfo -emit-module-interface-path %t.mod1/Foo.swiftinterface -module-name Foo -swift-version 5
1818

1919
// RUN: %target-swift-frontend -disable-objc-attr-requires-foundation-module -emit-module -o %t.mod2/Foo.swiftmodule %t.mod2/Foo.swift -parse-as-library -enable-library-evolution -emit-module-source-info -emit-module-source-info-path %t.mod2/Foo.swiftsourceinfo -emit-module-interface-path %t.mod2/Foo.swiftinterface -module-name Foo -swift-version 5
2020

2121
// RUN: %api-digester -dump-sdk -module Foo -output-dir %t.baseline -module-cache-path %t.module-cache %clang-importer-sdk-nosource -I %t.mod1 -abi -use-interface-for-module Foo
2222

23-
// RUN: %api-digester -diagnose-sdk -print-module -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -breakage-allowlist-path %t/complete-allowlist.txt -o %t/expected-diags.txt
23+
// RUN: %api-digester -diagnose-sdk -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -breakage-allowlist-path %t/complete-allowlist.txt -o %t/expected-diags.txt
2424

25-
// RUN: not %api-digester -diagnose-sdk -print-module -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -compiler-style-diags
25+
// RUN: not %api-digester -diagnose-sdk -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -compiler-style-diags
2626

27-
// RUN: not %api-digester -diagnose-sdk -print-module -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -compiler-style-diags -breakage-allowlist-path %t/incomplete-allowlist.txt
27+
// RUN: not %api-digester -diagnose-sdk -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -compiler-style-diags -breakage-allowlist-path %t/incomplete-allowlist.txt
2828

29-
// RUN: %api-digester -diagnose-sdk -print-module -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -compiler-style-diags -breakage-allowlist-path %t/complete-allowlist.txt
29+
// RUN: %api-digester -diagnose-sdk -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -compiler-style-diags -breakage-allowlist-path %t/complete-allowlist.txt
3030

31-
// RUN: not %api-digester -diagnose-sdk -print-module -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -serialize-diagnostics-path %t/serialized-diag.dia
31+
// RUN: not %api-digester -diagnose-sdk -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -serialize-diagnostics-path %t/serialized-diag.dia
3232
// RUN: ls %t/serialized-diag.dia
3333

34-
// RUN: not %api-digester -diagnose-sdk -print-module -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -serialize-diagnostics-path %t/serialized-diag.dia -breakage-allowlist-path %t/incomplete-allowlist.txt
34+
// RUN: not %api-digester -diagnose-sdk -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -serialize-diagnostics-path %t/serialized-diag.dia -breakage-allowlist-path %t/incomplete-allowlist.txt
3535
// RUN: ls %t/serialized-diag.dia
3636

37-
// RUN: %api-digester -diagnose-sdk -print-module -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -serialize-diagnostics-path %t/serialized-diag.dia -breakage-allowlist-path %t/complete-allowlist.txt
37+
// RUN: %api-digester -diagnose-sdk -baseline-dir %t.baseline -module Foo -I %t.mod2 -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -serialize-diagnostics-path %t/serialized-diag.dia -breakage-allowlist-path %t/complete-allowlist.txt
3838
// RUN: ls %t/serialized-diag.dia

‎test/api-digester/compare-dump-abi.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
// RUN: not %api-digester -diagnose-sdk -print-module -baseline-dir %t.baseline -module cake -I %t.mod2 -I %S/Inputs/APINotesLeft -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -o %t.result -compiler-style-diags 2> %t.abi.compiler.diags
1919
// RUN: %FileCheck %s < %t.abi.compiler.diags
2020

21-
// CHECK: cake_current/cake.swift:39:15: error: cake: struct C6 is now with @frozen
22-
// CHECK: cake_current/cake.swift:41:13: error: cake: enum IceKind is now without @frozen
21+
// CHECK: cake_current/cake.swift:39:15: error: ABI breakage: struct C6 is now with @frozen
22+
// CHECK: cake_current/cake.swift:41:13: error: ABI breakage: enum IceKind is now without @frozen

‎tools/swift-api-digester/ModuleAnalyzerNodes.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,16 @@ StringRef SDKNodeDecl::getScreenInfo() const {
409409
auto &Ctx = getSDKContext();
410410
llvm::SmallString<64> SS;
411411
llvm::raw_svector_ostream OS(SS);
412-
if (Ctx.getOpts().PrintModule)
413-
OS << ModuleName;
414-
if (!HeaderName.empty())
415-
OS << "(" << HeaderName << ")";
412+
if (Ctx.getOpts().CompilerStyle) {
413+
// Compiler style we don't need source info
414+
OS << (Ctx.checkingABI() ? "ABI breakage" : "API breakage");
415+
} else {
416+
// Print more source info.
417+
if (Ctx.getOpts().PrintModule)
418+
OS << ModuleName;
419+
if (!HeaderName.empty())
420+
OS << "(" << HeaderName << ")";
421+
}
416422
if (!OS.str().empty())
417423
OS << ": ";
418424
bool IsExtension = false;

0 commit comments

Comments
 (0)
Please sign in to comment.