Skip to content

Commit ee6ea39

Browse files
committed
---
yaml --- r: 344999 b: refs/heads/master c: b6374e7 h: refs/heads/master i: 344997: 6f6088d 344995: 0473498 344991: 3a38989
1 parent ae9c467 commit ee6ea39

16 files changed

+350
-291
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 32eeae65f52696bdd9a242f866438c56c0040b01
2+
refs/heads/master: b6374e756ddc1c331033740e1c9130eb2204aabc
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/AST/DiagnosticEngine.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,19 @@ namespace swift {
672672
return diagnose(Loc, Diagnostic(ID, std::move(Args)...));
673673
}
674674

675+
/// \brief Emit a diagnostic with the given set of diagnostic arguments.
676+
///
677+
/// \param ID The diagnostic to be emitted.
678+
///
679+
/// \param Args The diagnostic arguments, which will be converted to
680+
/// the types expected by the diagnostic \p ID.
681+
template<typename ...ArgTypes>
682+
InFlightDiagnostic
683+
diagnose(Diag<ArgTypes...> ID,
684+
typename detail::PassArgument<ArgTypes>::type... Args) {
685+
return diagnose(SourceLoc(), ID, std::move(Args)...);
686+
}
687+
675688
/// \brief Emit a diagnostic with the given set of diagnostic arguments.
676689
///
677690
/// \param Loc The declaration name location to which the

trunk/include/swift/AST/DiagnosticsAll.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "DiagnosticsFrontend.def"
5050
#include "DiagnosticsDriver.def"
5151
#include "DiagnosticsRefactoring.def"
52+
#include "DiagnosticsModuleDiffer.def"
5253

5354
#undef DIAG_NO_UNDEF
5455

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//===--- DiagnosticsModuleDiffer.def - Diagnostics Text ---------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file defines diagnostics emitted during diffing two Swift modules.
14+
// Each diagnostic is described using one of three kinds (error, warning, or
15+
// note) along with a unique identifier, category, options, and text, and is
16+
// followed by a signature describing the diagnostic argument kinds.
17+
//
18+
//===----------------------------------------------------------------------===//
19+
20+
#if !(defined(DIAG) || (defined(ERROR) && defined(WARNING) && defined(NOTE)))
21+
# error Must define either DIAG or the set {ERROR,WARNING,NOTE}
22+
#endif
23+
24+
#ifndef ERROR
25+
# define ERROR(ID,Options,Text,Signature) \
26+
DIAG(ERROR,ID,Options,Text,Signature)
27+
#endif
28+
29+
#ifndef WARNING
30+
# define WARNING(ID,Options,Text,Signature) \
31+
DIAG(WARNING,ID,Options,Text,Signature)
32+
#endif
33+
34+
#ifndef NOTE
35+
# define NOTE(ID,Options,Text,Signature) \
36+
DIAG(NOTE,ID,Options,Text,Signature)
37+
#endif
38+
39+
ERROR(generic_sig_change,none,"%0 has generic signature change from %1 to %2", (StringRef, StringRef, StringRef))
40+
41+
ERROR(raw_type_change,none,"%0(%1) is now %2 representable", (StringRef, StringRef, StringRef))
42+
43+
ERROR(removed_decl,none,"%0 has been removed%select{| (deprecated)}1", (StringRef, bool))
44+
45+
ERROR(moved_decl,none,"%0 has been moved to %1", (StringRef, StringRef))
46+
47+
ERROR(renamed_decl,none,"%0 has been renamed to %1", (StringRef, StringRef))
48+
49+
ERROR(decl_type_change,none,"%0 has %1 type change from %2 to %3", (StringRef, StringRef, StringRef, StringRef))
50+
51+
ERROR(decl_attr_change,none,"%0 changes from %1 to %2", (StringRef, StringRef, StringRef))
52+
53+
ERROR(decl_new_attr,none,"%0 is now %1", (StringRef, StringRef))
54+
55+
#ifndef DIAG_NO_UNDEF
56+
# if defined(DIAG)
57+
# undef DIAG
58+
# endif
59+
# undef NOTE
60+
# undef WARNING
61+
# undef ERROR
62+
#endif
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//===--- DiagnosticsModuleDiffer.h - Diagnostic Definitions ----*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
/// \file
14+
/// \brief This file defines diagnostics for the Swift module differ.
15+
//
16+
//===----------------------------------------------------------------------===//
17+
18+
#ifndef SWIFT_DIAGNOSTICS_MODULE_DIFFER_H
19+
#define SWIFT_DIAGNOSTICS_MODULE_DIFFER_H
20+
21+
#include "swift/AST/DiagnosticsCommon.h"
22+
23+
namespace swift {
24+
namespace diag {
25+
// Declare common diagnostics objects with their appropriate types.
26+
#define DIAG(KIND,ID,Options,Text,Signature) \
27+
extern detail::DiagWithArguments<void Signature>::type ID;
28+
#include "DiagnosticsModuleDiffer.def"
29+
}
30+
}
31+
32+
#endif

trunk/include/swift/IDE/APIDigesterData.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ raw_ostream &operator<<(raw_ostream &Out, const NodeAnnotation Value);
6060
// Redefine << so that we can output the name of the node kind.
6161
raw_ostream &operator<<(raw_ostream &Out, const SDKNodeKind Value);
6262

63+
StringRef getDeclKindStr(const DeclKind Value);
64+
65+
// Redefine << so that we can output the name of decl kind.
66+
raw_ostream &operator<<(raw_ostream &Out, const DeclKind Value);
67+
6368
struct APIDiffItem {
6469
virtual void streamDef(llvm::raw_ostream &S) const = 0;
6570
virtual APIDiffItemKind getKind() const = 0;

trunk/lib/IDE/APIDigesterData.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using namespace swift;
2323
using namespace ide;
2424
using namespace api;
2525

26-
inline raw_ostream &swift::ide::api::
26+
raw_ostream &swift::ide::api::
2727
operator<<(raw_ostream &Out, const SDKNodeKind Value) {
2828
switch (Value) {
2929
#define NODE_KIND(Name, Value) case SDKNodeKind::Name: return Out << #Value;
@@ -32,13 +32,26 @@ operator<<(raw_ostream &Out, const SDKNodeKind Value) {
3232
llvm_unreachable("Undefined SDK node kind.");
3333
}
3434

35-
inline raw_ostream &swift::ide::api::
35+
raw_ostream &swift::ide::api::
3636
operator<<(raw_ostream &Out, const NodeAnnotation Value) {
3737
#define NODE_ANNOTATION(X) if (Value == NodeAnnotation::X) { return Out << #X; }
3838
#include "swift/IDE/DigesterEnums.def"
3939
llvm_unreachable("Undefined SDK node kind.");
4040
}
4141

42+
StringRef swift::ide::api::getDeclKindStr(const DeclKind Value) {
43+
switch (Value) {
44+
#define DECL(X, PARENT) case DeclKind::X: return #X;
45+
#include "swift/AST/DeclNodes.def"
46+
}
47+
llvm_unreachable("Unhandled DeclKind in switch.");
48+
}
49+
50+
raw_ostream &swift::ide::api::operator<<(raw_ostream &Out,
51+
const DeclKind Value) {
52+
return Out << getDeclKindStr(Value);
53+
}
54+
4255
Optional<SDKNodeKind> swift::ide::api::parseSDKNodeKind(StringRef Content) {
4356
return llvm::StringSwitch<Optional<SDKNodeKind>>(Content)
4457
#define NODE_KIND(NAME, VALUE) .Case(#VALUE, SDKNodeKind::NAME)

trunk/test/api-digester/Outputs/Cake-abi.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ cake1: Func C4.foo() has been removed
1111
/* Moved Decls */
1212

1313
/* Renamed Decls */
14-
cake1: Struct Somestruct2 has been renamed to Struct NSSomestruct2
1514
cake1: Func S1.foo5(x:y:) has been renamed to Func S1.foo5(x:y:z:)
15+
cake1: Struct Somestruct2 has been renamed to Struct NSSomestruct2
1616

1717
/* Type Changes */
1818
cake1: Constructor S1.init(_:) has parameter 0 type change from Int to Double
1919
cake1: Func C1.foo2(_:) has parameter 0 type change from Int to () -> ()
2020
cake1: Func Somestruct2.foo1(_:) has parameter 0 type change from C3 to C1
2121

2222
/* Decl Attribute changes */
23-
cake1: Enum IceKind is now without @_frozen
24-
cake1: Struct C6 is now with @_fixed_layout
2523
cake1: Class C5 is now without @objc
26-
cake1: Var C1.CIIns1 changes from weak to strong
27-
cake1: Var C1.CIIns2 changes from strong to weak
24+
cake1: Enum IceKind is now without @_frozen
2825
cake1: Func C1.foo1() is now not static
2926
cake1: Func C5.dy_foo() is now with dynamic
3027
cake1: Func S1.foo1() is now mutating
3128
cake1: Func S1.foo3() is now static
29+
cake1: Struct C6 is now with @_fixed_layout
30+
cake1: Var C1.CIIns1 changes from weak to strong
31+
cake1: Var C1.CIIns2 changes from strong to weak

trunk/test/api-digester/Outputs/Cake.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ cake1: Func C4.foo() has been removed
1111
/* Moved Decls */
1212

1313
/* Renamed Decls */
14-
cake1: Struct Somestruct2 has been renamed to Struct NSSomestruct2
1514
cake1: Func S1.foo5(x:y:) has been renamed to Func S1.foo5(x:y:z:)
15+
cake1: Struct Somestruct2 has been renamed to Struct NSSomestruct2
1616

1717
/* Type Changes */
1818
cake1: Constructor S1.init(_:) has parameter 0 type change from Int to Double
1919
cake1: Func C1.foo2(_:) has parameter 0 type change from Int to () -> ()
2020

2121
/* Decl Attribute changes */
22-
cake1: Var C1.CIIns1 changes from weak to strong
23-
cake1: Var C1.CIIns2 changes from strong to weak
2422
cake1: Func C1.foo1() is now not static
2523
cake1: Func S1.foo1() is now mutating
2624
cake1: Func S1.foo3() is now static
25+
cake1: Var C1.CIIns1 changes from weak to strong
26+
cake1: Var C1.CIIns2 changes from strong to weak

trunk/test/api-digester/source-stability.swift.expected

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@
44
/* RawRepresentable Changes */
55

66
/* Removed Decls */
7-
TypeAlias AbsoluteValuable has been removed
8-
TypeAlias BitwiseOperations has been removed (deprecated)
9-
TypeAlias IntMax has been removed
10-
TypeAlias Integer has been removed
11-
TypeAlias IntegerArithmetic has been removed
12-
TypeAlias SignedNumber has been removed
13-
TypeAlias StringProtocol.UTF16Index has been removed (deprecated)
14-
TypeAlias StringProtocol.UTF8Index has been removed (deprecated)
15-
TypeAlias StringProtocol.UnicodeScalarIndex has been removed (deprecated)
16-
TypeAlias UIntMax has been removed
17-
Var FixedWidthInteger.allZeros has been removed (deprecated)
187
Constructor Int.init(truncatingBitPattern:) has been removed
198
Constructor Int16.init(truncatingBitPattern:) has been removed
209
Constructor Int32.init(truncatingBitPattern:) has been removed
@@ -64,6 +53,17 @@ Func UInt32.toIntMax() has been removed
6453
Func UInt64.toIntMax() has been removed
6554
Func UInt8.toIntMax() has been removed
6655
Func UnsignedInteger.toUIntMax() has been removed
56+
TypeAlias AbsoluteValuable has been removed
57+
TypeAlias BitwiseOperations has been removed (deprecated)
58+
TypeAlias IntMax has been removed
59+
TypeAlias Integer has been removed
60+
TypeAlias IntegerArithmetic has been removed
61+
TypeAlias SignedNumber has been removed
62+
TypeAlias StringProtocol.UTF16Index has been removed (deprecated)
63+
TypeAlias StringProtocol.UTF8Index has been removed (deprecated)
64+
TypeAlias StringProtocol.UnicodeScalarIndex has been removed (deprecated)
65+
TypeAlias UIntMax has been removed
66+
Var FixedWidthInteger.allZeros has been removed (deprecated)
6767

6868
/* Moved Decls */
6969

@@ -72,12 +72,13 @@ Func Dictionary.filter(_:obsoletedInSwift4:) has been renamed to Func Dictionary
7272
Func Set.filter(_:obsoletedInSwift4:) has been renamed to Func Set.filter(_:)
7373

7474
/* Type Changes */
75-
Var Dictionary.keys has declared type change from LazyMapCollection<[Key : Value], Key> to Dictionary<Key, Value>.Keys
76-
Var Dictionary.values has declared type change from LazyMapCollection<[Key : Value], Value> to Dictionary<Key, Value>.Values
7775
Constructor String.init(_:) has return type change from String? to String
7876
Func Dictionary.filter(_:obsoletedInSwift4:) has return type change from [Dictionary<Key, Value>.Element] to [Dictionary<Key, Value>.Key : Dictionary<Key, Value>.Value]
7977
Func Dictionary.makeIterator() has return type change from DictionaryIterator<Dictionary<Key, Value>.Key, Dictionary<Key, Value>.Value> to Dictionary<Key, Value>.Iterator
8078
Func Set.filter(_:obsoletedInSwift4:) has return type change from [Set<Element>.Element] to Set<Element>
8179
Func Set.makeIterator() has return type change from SetIterator<Element> to Set<Element>.Iterator
80+
Var Dictionary.keys has declared type change from LazyMapCollection<[Key : Value], Key> to Dictionary<Key, Value>.Keys
81+
Var Dictionary.values has declared type change from LazyMapCollection<[Key : Value], Value> to Dictionary<Key, Value>.Values
82+
8283

8384
/* Decl Attribute changes */
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
add_swift_host_tool(swift-api-digester
22
swift-api-digester.cpp
33
ModuleAnalyzerNodes.cpp
4+
ModuleDiagsConsumer.cpp
45
LINK_LIBRARIES swiftFrontend swiftIDE
56
SWIFT_COMPONENT tools
67
)

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,22 @@ SDKNode *SDKNodeRoot::getInstance(SDKContext &Ctx) {
293293
return Info.createSDKNode(SDKNodeKind::Root);
294294
}
295295

296+
StringRef SDKNodeDecl::getScreenInfo() const {
297+
auto ModuleName = getModuleName();
298+
auto HeaderName = getHeaderName();
299+
auto &Ctx = getSDKContext();
300+
llvm::SmallString<64> SS;
301+
llvm::raw_svector_ostream OS(SS);
302+
if (Ctx.getOpts().PrintModule)
303+
OS << ModuleName;
304+
if (!HeaderName.empty())
305+
OS << "(" << HeaderName << ")";
306+
if (!OS.str().empty())
307+
OS << ": ";
308+
OS << getDeclKind() << " " << getFullyQualifiedName();
309+
return Ctx.buffer(OS.str());
310+
}
311+
296312
bool SDKNodeDecl::isSDKPrivate() const {
297313
if (getName().startswith("__"))
298314
return true;

trunk/tools/swift-api-digester/ModuleAnalyzerNodes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ struct CheckerOptions {
139139
bool ABI;
140140
bool Verbose;
141141
bool AbortOnModuleLoadFailure;
142+
bool PrintModule;
142143
StringRef LocationFilter;
143144
};
144145

@@ -303,6 +304,7 @@ class SDKNodeDecl: public SDKNode {
303304
bool hasDeclAttribute(DeclAttrKind DAKind) const;
304305
bool isStatic() const { return IsStatic; };
305306
StringRef getGenericSignature() const { return GenericSig; }
307+
StringRef getScreenInfo() const;
306308
};
307309

308310
class SDKNodeRoot: public SDKNode {

0 commit comments

Comments
 (0)