Commit Graph

211 Commits

Author SHA1 Message Date
Xi Ge
1163c33cfc swift-api-digester: minor refactoring. NFC 2018-04-05 14:58:04 -07:00
Xi Ge
cb53468c5f swift-api-digester: refine diagnostic messages for removed type alias.
Framework authors can use SwiftWraper:none to bring back string enums
to type alias of String. When diagnosing source breaking changes, these
type alias are shown as removed. Therefore, it's hard to tell whether these
changes are automatically migratable. This patch refines the
removed-type-alias by further analyzing whether a
RawRepresentable with the same usr appeared in the later version of
SDK. If there is, another kind of message is emitted for differentiation.
2018-04-04 21:10:10 -07:00
Xi Ge
6ffad8085b swift-api-digester: if a removed declaration has been hoisted to a type member,
show this declaration as renamed instead of removed.
2018-04-03 13:26:30 -07:00
Xi Ge
784116a79b swift-api-digester: simplify some code. NFC 2018-03-26 15:46:32 -07:00
Xi Ge
b2c437525c swift-api-digester: teach the tool to detect [String:Any] changes to [StringRepresentable:Any].
This allows us to migrate string enum changes from the frameworks.
2018-03-26 15:35:07 -07:00
Doug Gregor
b2b69e8abf Rename BoundNameAliasType to NameAliasType.
NameAliasType is dead! Long live NameAliasType!
2018-03-25 21:35:17 -07:00
Doug Gregor
c43f96a855 [AST] Remove now-unused NameAliasType. 2018-03-25 21:35:16 -07:00
Xi Ge
20a48e5adb swift-api-digester: teach the tool to serialize USRs for nominal type. (#15463)
This allows us to map back from a type to the declaration in the dump,
so that we can perform more fine-grained analysis like whether a string
has been changed to string enum.
2018-03-23 16:29:54 -07:00
Doug Gregor
253bd10bd3 Cope with BoundNameAliasType in more places that handle NameAliasType. 2018-03-21 23:49:33 -07:00
Slava Pestov
30dae65226 AST: Add DeclBaseName::Kind::Constructor
Not used yet.
2018-03-16 00:25:54 -07:00
Jordan Rose
c26f40b45b Fix some more misuses of LLVM's YAML parser. (#15119)
https://reviews.llvm.org/D44317 should prevent this from happening
again.
2018-03-10 17:47:14 -08:00
Xi Ge
f66dd8e59c swift-api-digester: keep track of type declarations with fixed layout. (#14991)
We need special logic to check abi-stability for decls with fixed
layout.
2018-03-05 15:08:06 -08:00
Xi Ge
f77b318831 swift-api-digester: teach the tool to serialize raw type name for enum declarations. 2018-03-02 17:14:36 -08:00
Huon Wilson
78bdc95ce3 Merge pull request #14874 from huonw/at-owned-cleanup
Various refactorings for __owned.
2018-03-02 14:20:21 -08:00
Huon Wilson
b94c5364f5 [NFC] Rename 'Ownership' to 'ReferenceOwnership'.
There's really two forms of ownership: references and values. Renaming
to make way for better distinguishing of the two.
2018-03-02 11:38:28 -08:00
Xi Ge
66bb9ce4ba swift-api-digester: teach the tool to serialize conforming protocols. (#14923) 2018-03-01 15:57:59 -08:00
Jordan Rose
3cd9f166bc Don't spend time initializing LLVM when running the driver (#14896)
Tiny start-up time optimization noticed while looking at how we do
PrettyStackTraceProgram. Also add PrettyStackTraceProgram to a few
more of our testing tools, via the new PROGRAM_START macro.
2018-02-28 19:56:19 -08:00
Xi Ge
60bd6b91e0 swift-api-digester: serialize and de-serialize whether a parameter has a default argument.
Removing default arguments can be source-breaking.
2018-02-27 13:18:58 -08:00
Xi Ge
1aa7816956 swift-api-digester: teach the tool to serialize and de-serialize generic requirements.
The tool should diagnose the change of extension's applicability since
such change can be source-breaking. We need first to support the
requirements in the module dump. Currently, we decorate each
member defined in extension with a field called extension info. The
field will keep track of the generic requirements that need to be satisfied
for this decorated member to be applicable. This patch doesn't implement the checking
of requirements change.
2018-02-23 15:30:57 -08:00
Xi Ge
4e84693ab9 swift-api-digester: print header file names along with source-breaking changes. (#14788)
When diagnosing API source-breaking changes, we
should also output the header file name from where the affected Clang
declaration is defined.

This may expedite screening process.
2018-02-22 13:47:35 -08:00
Mark Lacey
b4b66bc8e8 Replace getAnyOptionalObjectType with getOptionalObjectType. 2018-02-05 23:59:00 -08:00
Xi Ge
cd3b34c7cf swift-api-digester: for each source-breaking item, we should output its framework name to help screening. rdar://35421724 (#14068)
The framework name is behind a flag "print-module". We should
print them during whole-sdk checks however not in the per-framework diffing
tool.
2018-01-22 15:44:26 -08:00
Mark Lacey
4a913515a8 IUO: Update swift-api-digester for the removal of IUOs from the type system.
When IUOs actually go away I will commit changes to these tests for
the mangling difference:

  test/api-digester/Outputs/macro-gen.def
  test/api-digester/Outputs/macro-gen.json
2018-01-12 21:19:40 -08:00
Xi Ge
884f3dbdc2 swift-api-digester: Ignore the declarations that have no accessibility set. rdar://35375615 (#12784) 2017-11-07 11:19:54 -08:00
Jordan Rose
1c651973c3 Excise "Accessibility" from the compiler (2/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the 'Accessibility' enum to be named 'AccessLevel'.
2017-08-28 11:34:44 -07:00
Jordan Rose
7d7e496dc0 [swift-api-digester] Update for 'deinit' as a special name.
Missed switch case from the 17ddc5802f series. Unbreaks the build
after -Werror=switch.
2017-08-01 10:55:21 -07:00
Xi Ge
a603fcbcf3 swift-api-digester: More strict conditions when detecting member hoist API changes. [SR-5498] (#11091)
We observed several false positives of function hoist API changes. This patch
strictly checks the new module doesn't contain a declaration with the
identical name of the old function before hoisting to eliminate such
false positives.

This case is too complex to come up with an actual test case.
2017-07-20 17:07:06 -07:00
Xi Ge
a410f20584 swift-api-digester: Avoid considering a type decl is removed if a typealias with the same name is simultaneously added. rdar://33307864 (#11016) 2017-07-18 12:01:32 -07:00
Alex Hoppen
f8c2692f79 Introduce special decl names
Special DeclNames represent names that do not have an identifier in the
surface language. This implies serializing the information about whether
a name is special together with its identifier (if it is not special)
in both the module file and the swift lookup table.
2017-07-11 19:04:13 +02:00
Xi Ge
2b05e30756 swift-api-digester: don't assume super classes are always present in the module dump.
When we compare the APIs of entire SDKs, we can assume super classes
are always present in the API dump. However, this assumption is invalid
for framework-level API diff checking, where super classes can come from
other modules whose contents are not serialized.

rdar://33110442
2017-07-06 11:49:44 -07:00
Alex Hoppen
949968a182 Adjust printing to take into account special DeclNames
Print DeclBaseNames using a new userFacingStr() method to prepare for
DeclBaseNames that are not backed by Identifiers
2017-06-24 11:39:09 +02:00
swift-ci
4e7f2bf1b7 Merge pull request #10507 from nkcsgexi/digester-move 2017-06-22 13:00:32 -07:00
Xi Ge
246541fca6 swift-api-digester: more strict when detecting moved declarations.
We've witnessed high positive rate in this case.

rdar://31694080
2017-06-22 12:38:37 -07:00
Xi Ge
f6e6484437 swift-api-digester: Eliminate false positives introduced by moving a member declaration to super classes.
We shouldn't report these moved declarations as source breaking changes.

rdar://32778228
2017-06-21 19:47:07 -07:00
Xi Ge
87a0cfb910 swift-api-digester: teach the tool to serialize/deserialize super class Usrs. rdar://32778228
This can help us eliminate false positives when we report removed
declarations are actually moved to a newly-introduced super class.
2017-06-21 19:47:07 -07:00
Xi Ge
ce17eae939 swift-api-digester: detected getter/setter function to property updates should be explicit about the new property names instead of inferring them from old function name. 2017-06-12 15:10:41 -07:00
Xi Ge
9d0f24a1ee swift-api-digester: move NodeUpdateMap to the context instead of creating it locally. NFC 2017-06-09 10:30:14 -07:00
Xi Ge
935c85fca1 swift-api-digester: simplify some code. NFC 2017-06-05 15:05:28 -07:00
Xi Ge
d20f4a8a3e swift-api-digester: simplify some code. NFC (#10023) 2017-05-31 21:47:53 -07:00
Xi Ge
824aaa11e2 swift-api-digester: detect the move of static members only.
This patch restricts the detection of moved members to be static members,
since only in this case we need to update qualified access to
them. The move of instance members will be either handled by rename or
we don't need to update anything at all.

Additionally, this patch introduces a sub-kind of type member diff item
called qualified replacement to describe the aforementioned case. However,
the migrator part has not started to honor this sub-kind yet.

rdar://32466196
2017-05-31 11:47:27 -07:00
Xi Ge
d1b0e67620 swift-api-digester: teach the tool do detect APINotes' moving one member variable/method to another type. (#9985)
Different from type hoist that moves global variables to static member
variables, we've also seen member variables being moved among different
types via apinotes. Swift-api-digester should be able to detect such
case so that migrator can handle them properly.

rdar://32466196
2017-05-30 14:23:32 -07:00
Alex Hoppen
58c956a29a [Misc] Preparations for removal of getName on ValueDecl
With the introduction of special decl names, `Identifier getName()` on
`ValueDecl` will be removed and pushed down to nominal declarations
whose name is guaranteed not to be special. Prepare for this by calling
to `DeclBaseName getBaseName()` instead where appropriate.
2017-05-28 19:13:24 -07:00
Jordan Rose
c0ccdb1626 Change getBaseName to return DeclBaseName instead of Identifier (#9968)
This changes `getBaseName()` on `DeclName` to return a `DeclBaseName`
instead of an `Identifier`. All places that will continue to be
expecting an `Identifier` are changed to call `getBaseIdentifier` which
will later assert that the `DeclName` is actually backed by an
identifier and not a special name.

For transitional purposes, a conversion operator from `DeclBaseName` to
`Identifier` has been added that will be removed again once migration
to DeclBaseName has been completed in other parts of the compiler.

Unify approach to printing declaration names

Printing a declaration's name using `<<` and `getBaseName()` is be
independent of the return type of `getBaseName()` which will change in
the future from `Identifier` to `DeclBaseName`
2017-05-28 17:55:03 -07:00
Xi Ge
65b9043eb1 migrator: handle function hoist API changes and several its varieties. rdar://31234806 (#9544) 2017-05-12 21:34:06 -07:00
practicalswift
492f5cd35a [gardening] Remove redundant repetition of type names (DRY): RepeatedTypeName foo = dyn_cast<RepeatedTypeName>(bar)
Replace `NameOfType foo = dyn_cast<NameOfType>(bar)` with DRY version `auto foo = dyn_cast<NameOfType>(bar)`.

The DRY auto version is by far the dominant form already used in the repo, so this PR merely brings the exceptional cases (redundant repetition form) in line with the dominant form (auto form).

See the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es11-use-auto-to-avoid-redundant-repetition-of-type-names) for a general discussion on why to use `auto` to avoid redundant repetition of type names.
2017-05-05 09:45:53 +02:00
Xi Ge
a644ab33a0 swift-api-digester: fix recently found false positives. (#8899)
* swift-api-digester: ensure constructors are detected as removed if not moved. rdar://31694119

* swift-api-digester: types with the same printed name are considered behavior-preserving. rdar://31694085

* [test] Using tmp directory from build.
2017-04-20 18:34:52 -07:00
Xi Ge
b089bab40e swift-api-digester: avoid reporting moved constructors. rdar://31694119 (#8885)
They don't make more sense than renamed decls.
2017-04-20 12:48:17 -07:00
Xi Ge
ba33fd6236 swift-api-digester: Add a data structure APIDiffItemStore. (#8794)
This structure serves multiple purposes:
	a. Allow migrator to speak in the same language with swift-api-digester in terms of API changes.
	b. Serialize/Deserialize detected API change items in JSON format.
	c. Manage memory after deserializing API change items.
	d. Facilitate look up by USRs of APIs under migration.
The structure is tested by round-trip serialization and deserialization.
2017-04-17 13:04:02 -07:00
practicalswift
40cf4d183d [gardening] Use consistent spacing after if, for and while 2017-04-14 17:35:36 +02:00
Xi Ge
dbb71698e9 swift-api-digester: Extract/Expose API change descriptors to libIDE to allow visibility from libMigrator. NFC (#8766) 2017-04-13 18:31:41 -07:00