Commit Graph

129 Commits

Author SHA1 Message Date
Slava Pestov
b4ea644910 IDE: Replace some calls to getDeclaredType() with getDeclaredInterfaceType() 2020-07-31 13:39:02 -04:00
Meghana Gupta
b34791a0a0 Update code as per Apple Style Guide
whitelist -> allowlist
blacklist -> denylist
2020-07-24 11:37:15 -07:00
Nathan Hawes
244dc4a768 [AST] Rename PlatformKind::OSX to PlatformKind::macOS
Because the names are coming from a .def file used for printing too, this
simplifies the printing logic as well.
2020-07-08 16:29:31 -07:00
Xi Ge
4448a229df ABI-checker: include Swift symbols only when ABI checking is enabled
ABI checking logics are largely Swift-specific, so we should exclude
symbols from the underlying Clang module.

rdar://64373983
2020-06-16 16:41:07 -07:00
Xi Ge
c5730beb42 API checker: only diagnose adding enum cases to exhaustive enums
Adding new cases to a non-exhaustive enum type isn't source-breaking
since it only triggers a warning.

rdar://63464929
2020-05-23 15:56:22 -07:00
Anthony Latsis
74252028ca AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl 2020-04-23 05:16:55 +03:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Xi Ge
c585fd6748 ABIChecker: contains only opaque accessors for ABI/API checking
rdar://53776566
2020-02-24 12:23:03 -08:00
Dan Zheng
1486d6b346 NFC: Add GenericSignature::getCanonicalSignature. (#29105)
Motivation: `GenericSignatureImpl::getCanonicalSignature` crashes for
`GenericSignature` with underlying `nullptr`. This led to verbose workarounds
when computing `CanGenericSignature` from `GenericSignature`.

Solution: `GenericSignature::getCanonicalSignature` is a wrapper around
`GenericSignatureImpl::getCanonicalSignature` that returns the canonical
signature, or `nullptr` if the underlying pointer is `nullptr`.

Rewrite all verbose workarounds using `GenericSignature::getCanonicalSignature`.
2020-01-12 12:17:41 -08:00
Harlan Haskins
4d731735d2 [api-digester] Teach the api-digester about hasMissingDesignatedInitializers
Because we won’t be serializing this attribute, add custom diagnostics for the cases where:

- We add @_hasMissingDesignatedInits to an open class, which means subclasses won’t be able to inherit its inits
- We remove @_inheritsConvenienceInitializers, which means APIs are removed
2020-01-06 10:15:07 -08:00
Saleem Abdulrasool
7d8aac60ca disambiguate some type shadowing (NFCI)
Adjust the type shadowing identified by GCC 7.  The declaration shadows
a type which changes the meaning of the identifier subsequently.
2019-12-23 15:34:55 -08:00
Xi Ge
7d600eb27a ABI/API checker: teach the tool to emit diagnostics to serialized source location for decls 2019-10-17 16:31:56 -07:00
Xi Ge
dd33540231 AST: rename printDeclUSRForModuleDoc to printDeclUSR. NFC 2019-10-09 15:29:52 -07:00
Robert Widmann
5a8d0744c3 [NFC] Adopt TypeBase-isms for GenericSignature
Structurally prevent a number of common anti-patterns involving generic
signatures by separating the interface into GenericSignature and the
implementation into GenericSignatureBase.  In particular, this allows
the comparison operators to be deleted which forces callers to
canonicalize the signature or ask to compare pointers explicitly.
2019-09-30 14:04:36 -07:00
Robert Widmann
d5c014b8e4 Remove validateDeclForNameLookup
Flush it and the early validation hack now that we can delay computing the underlying interface type on demand and have taught type resolution to honor the structural type of a typealias.

This changes the way requirement signatures are spelled as a side effect.
2019-09-17 08:49:03 -07:00
Sasha Krassovsky
edc26bb92d Fix warning in swift-api-digester 2019-09-13 09:57:48 -07:00
Xi Ge
78bb298389 ABI/API checker: diagnose adding new designated initializers to open classes
If client's subclass provides an implementation of all of its superclass designated
initializers, it automatically inherits all of the superclass convenience initializers.
This means if a new designated init is added to the base class, the inherited
convenience init may be missing and cause breakage.

SR-11454
2019-09-12 15:46:45 -07:00
Xi Ge
4189b6c99b AST: promote API/ABI impact bit of decl attributes to AST, NFC
ABI/API checker used to hard-code whether adding or removing of a
decl attribute could break the existing ABI/API. This is not ideal because
new attributes may be added to AST without updating the checker. After this
change, new decl attribute could be specified whether it has ABI/API
impact and the checker could pick up the knowledge instantly.
2019-09-11 17:58:36 -07:00
Xi Ge
a7e8620582 ABI/API checker: include SDK version number when generating diagnostic baselines 2019-09-10 17:00:46 -07:00
Xi Ge
cc6a246deb Revert "Revert "swift-api-digester: teach the tool to find framework-specific baselines from relative path"" 2019-09-01 09:19:43 -07:00
eeckstein
63a3cee0bf Revert "swift-api-digester: teach the tool to find framework-specific baselines from relative path" 2019-09-01 09:51:06 +02:00
Xi Ge
178e5d5ecf swift-api-digester: teach the tool to find framework-specific baselines from relative path
The framework baselines are installed at 'lib/swift/FrameworkABIBaseline' and the
tool is inside 'bin'. This patch teaches the executable to locate baselines
from the relative path.

In addition, this patch moves the stdlib ABI/API baselines to the canonical
location so we don't have to check the stability of the stdlib using a
different mechanism from other Swift frameworks.
2019-08-30 23:14:03 -07:00
Xi Ge
1e173d8931 ABI/API checker: populate several lazily computed attributes to nodes
ABI/API checker should check semantic differences of two modules.
Adhering too strictly to the actual ASTs could yield false positives. This
patch populates ObjC, Dynamic and Final to the attribute list if AST
APIs say so.

rdar://50217247
2019-08-29 15:24:16 -07:00
Xi Ge
6dd41f44db ABI checker: exclude unavailable decls from ABI descriptors
Framework authors usually have different schemes for different deployment
targets. We should exclude platform-unavailable ABIs from the Json file so
developers will only be warned of the breakages that are relevant to the current
scheme.

rdar://54273296
2019-08-28 16:02:03 -07:00
Xi Ge
6374d3676a ABI/API checker: diagnose ObjC name changes as breakages
rdar://54797695
2019-08-28 11:56:03 -07:00
Xi Ge
4108beb92d ABI/API checker: always print fully qualified names for types when diagnosing module difference
This change introduces a Json format change where we always print fully
qualified type names everywhere. This is beneficial for diagnosing purposes but
may not be ideal for generating migrator scripts. To resolve this conflict, the
patch also introduces a flag -migrator to opt-out fully qualified type names.

After the format change, we need to update the ABI and API baselines for the
Swift stdlib.
2019-08-27 11:42:28 -07:00
Xi Ge
03bd23ebe0 ABI checker: prefer sugared version of generic signature while emitting diagnostics. 2019-08-25 13:28:47 -07:00
Xi Ge
ce57492609 swift-api-digester: add an action to generate empty baselines 2019-08-21 17:44:53 -07:00
Xi Ge
0517e97ea7 ABI/API checker: use colors when emitting diagnostics in module loading 2019-08-21 16:25:44 -07:00
Xi Ge
d4bfae8595 ABI/API checker: abort after error occurs while importing a module 2019-08-21 15:57:39 -07:00
Xi Ge
77ba60f145 Merge pull request #26727 from nkcsgexi/version-abi-checker
ABI/API checker: add a version number for the json descriptors of APIs
2019-08-19 15:24:32 -07:00
Xi Ge
3266fd53d9 ABI/API checker: add a version number for the json descriptors of APIs 2019-08-19 14:15:52 -07:00
Jordan Rose
94d1e5efe6 Avoid reserved names in C++ code: "__Consuming" (#26720)
Double-underscored names are reserved for the C++ "implementation"
(language and standard library). Even though "__Consuming" isn't
likely to be part of the C++ standard any time soon, we should follow
the rules.

Note that the API digester will continue to use the string
"__Consuming" for now, even though the underscores aren't really
significant, to avoid invalidating existing dumps.

No functionality change.
2019-08-19 13:06:53 -07:00
Xi Ge
6a65a01e8a ABI/API checker: serialized json format should include all tool invocation arguments 2019-08-19 12:11:00 -07:00
Slava Pestov
19d283d9dc AST: Replace ImplicitlyUnwrappedOptionalAttr with Decl::{is,set}ImplicitlyUnwrappedOptional() 2019-08-15 18:41:41 -04:00
Xi Ge
4b8abdf852 swift-api-digester: use qualified type names for generic signatures
There could be cases where several modules having types of the same name.
Using fully qualified names could help us detect changing from using
one of them to another.

The commit also updates the existing ABI/API baselines to incorporate such change.
2019-08-14 09:54:55 -07:00
Xi Ge
dfcfdf726b ABI/API checker: avoid printing fully qualified names in generic signature
The heuristics to decide whether fully qualified type names should be printed may
work differently when generating the baseline and when importing from just built
frameworks. This patch makes it consistent so that such false positives won't happen.

rdar://54276347
2019-08-13 15:16:25 -07:00
Xi Ge
a79b1ff73d ABI checker: report any printed name changes for type nodes
Under ABI checking mode where we don't have sugar types, any printed name
changes of type nodes worth raising an alert.

rdar://45567621
2019-08-09 17:24:45 -07:00
Xi Ge
64fc0cbdb7 ABI/API checker: check if module has failed to load and abort if so 2019-08-05 15:44:50 -07:00
Slava Pestov
4c499fd4ac AST: Stop passing around LazyResolvers in various places 2019-07-06 00:43:22 -04:00
Xi Ge
e99fac01ed ABI Checker: diagnose underlying type changes of opaque result types from inlinable decls.
Inlinable decls from swift interface files allow us to construct the underlying types
of opaque result types, whose changes can break ABI.

rdar://52273137
2019-07-01 12:06:02 -07:00
Xi Ge
5c22fd50e2 ABI checker: include all kinds of accessors for abstract storage decl and diagnose their missing.
Removing accessors other than getter and setter can be ABI breaking. This
patch starts to formally include all accessor decls in the tree and diagnose
their removal. This change only applies to the ABI checker since we still
exclude accessors other than getter and setter when diagnosing source
compatibility.

Including accessors formally can also allow us to check the missing
of availability attributes for newly added accessors.

rdar://52063421
2019-06-26 18:04:28 -07:00
Xi Ge
d405fcd8ec swift-api-digester: teach the tool to directly compare two module interfaces
We used to use a Json format to capture the ABI/API detail of Swift modules to
walk-around module compatibility issues across different compiler versions. Since
Swift module now is in stable format, we can compare two swiftinterface files
directly without dumping the content into Json format.
2019-06-12 11:16:23 -07:00
Xi Ge
c9660106a7 swift-api-digester: remove some unused code. NFC 2019-06-12 11:02:47 -07:00
Saleem Abdulrasool
6cf8792972 swift-api-digester: silence MSVC unreachable warning (NFC)
Add some llvm_unreachable to indicate to MSVC that the switch is
covered.
2019-06-03 16:48:23 -07:00
Xi Ge
f55d3ad029 ABI checker: diagnose the missing of @available attributes for added ABIs
New ABIs should have an @available attribute to describe the introducing
version. This patch teaches the tool to diagnose its missing.

Decls with @_AlwaysEmitIntoClient are excluded from the blaming lists since
they are essentially available all the time.

rdar://51089418
2019-05-28 16:38:59 -07:00
Xi Ge
05bec0c3e3 swift-api-digester: describing external type declarations as extensions in error messages
External type declarations are synthesized to incorporate members in extensions to types
of external modules. In diagnostics, we should use 'extension' instead of 'struct/class'
for these decls to avoid confusion.
2019-05-28 14:08:36 -07:00
Xi Ge
92719d6f30 swift-api-digester: mark if a type declaration is pulled from an external module
To incorporate extensions to types from other modules, the tool sometimes needs
to pull type declaration from external modules even though these modules
are not under checking. We need a flag to explicitly mark such case.
2019-05-24 16:02:40 -07:00
Xi Ge
7b445c3c98 api-digester: keep track of the introduced platforms and language versions for all APIs
These fields will be used to diagnose the missing of available
attributes for newly added APIs.

rdar://51089418
2019-05-23 17:23:30 -07:00
Xi Ge
f5853ba44f swift-api-digester: avoid adding MissingMemberDecl to the json file
We explicitly ignore these ABI placeholders to fix an unreachable hit.
2019-05-22 18:09:42 -07:00