Commit Graph

80 Commits

Author SHA1 Message Date
Anthony Latsis
c63b737e92 Collapse all indirect equivalents to ValueDecl::getBaseIdentifier 2020-03-29 00:36:01 +03:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Slava Pestov
3604b21f2a AST: Simplify Expr::getReferencedDecl() 2019-12-19 23:51:53 -05:00
Robert Widmann
060cbb293f [NFC] Downgrade The TypeLoc in VarDecl to a TypeRepr
TypeCheckPattern used to splat the interface type into this, and
different parts of the compiler would check one or the other.   There is
now one source of truth: The interface type.  The type repr is now just
a signal that the user has written an explicit type annotation on
a parameter.  For variables, we will eventually be able to just grab
this information from the parent pattern.
2019-10-11 11:15:51 -07:00
Xi Ge
dd33540231 AST: rename printDeclUSRForModuleDoc to printDeclUSR. NFC 2019-10-09 15:29:52 -07:00
Xi Ge
ab86991958 IDE: move two AST traversal utilities from libIndex to IDE type checking. NFC 2019-07-18 16:17:10 -07:00
Doug Gregor
015b7c5266 [AST] Use AbstractFunctionDecl::getBodySourceRange() more frequently.
A number of callers to AbstractFunctionDecl::getBody() were only
extracting the source range of the body... which can be retrieved more
efficiently with getBodySourceRange().
2019-07-11 21:31:21 -07:00
Ben Langmuir
effab8c522 Handle dynamic member lookup in annotation and cursor info
Ensure the various entity walkers handle the implicit subscript
reference correctly (usually by ignoring it) and fall through to the
underlying declarations.

rdar://49028895
2019-04-16 15:37:32 -07:00
Xi Ge
2be1ca0c8a migrator: add ! to property access whose definition changes from nonnull to nullable. rdar://48090648 2019-02-14 15:28:52 -08:00
Xi Ge
c6a64a9a21 migrator: handle function's return type changes from nonnull to nullable. rdar://47265255
Adding exclamation brings an optional type back to its original nonnull
version.
2019-01-14 14:15:07 -08:00
Parker Schuh
f5859ff46e Rename NameAliasType to TypeAliasType. 2019-01-09 16:47:13 -08:00
Xi Ge
83382c5f94 migrator: rename a property declaration if the framework property it overrides has been renamed. 2018-12-19 11:58:22 -08:00
Saleem Abdulrasool
d281b98220 litter the tree with llvm_unreachable
This silences the instances of the warning from Visual Studio about not all
codepaths returning a value.  This makes the output more readable and less
likely to lose useful warnings.  NFC.
2018-09-13 15:26:14 -07:00
Argyrios Kyrtzidis
7d1d0950cb [migrator] Handle AppKit protocol migrations
This is https://github.com/apple/swift/pull/18226 but with a fix for the test to be macos specific.
rdar://42480588
2018-07-27 15:43:29 -07:00
Pavel Yaskevich
f0d1f0bc66 Revert "migrator: handle AppKit protocol migrations. rdar://42480588" 2018-07-27 00:04:23 -07:00
Xi Ge
a8d43cc344 migrator: handle AppKit protocol migrations. rdar://42480588 2018-07-26 16:57:48 -07:00
Slava Pestov
5213f80e7e IDE: Remove uses of AbstractFunctionDecl::getParameterLists() 2018-07-22 20:56:56 -07:00
Xi Ge
f83ccd6438 migrator: handle changed parameter declarations by introducing bridging local variables.
When users override a SDK function whose parameter types have been changed,
we should introduce a local variable in the body of the function definition
to shadow the changed parameter. Also, a proper conversion function should
be applied to bridge the parameter to the local variable.

rdar://41828411
2018-07-11 13:41:37 -07:00
Xi Ge
c40ebd1d2d migrator: support migration of raw representable initializer calls without explicit labels. rdar://41740103
Some raw representable struct from SDK can be initialized without
explicit labels (rawValue:). When their types have been changed to type
alias, we should migrate the initializer calls to the argument alone.
2018-07-03 11:44:21 -07:00
Xi Ge
8e0e779cc2 migrator: handle the composite change of updating type alias to raw-representable and rename the referenced variables simultaneously. rdar://41732485 2018-07-02 12:13:20 -07:00
Xi Ge
46a1142b7f Merge pull request #17644 from nkcsgexi/global-name
migrator: handle member variables change to global ones. rdar://41658300
2018-07-02 09:25:44 -07:00
Xi Ge
c23d1a89a4 migrator: ensure we update unresolved member access correctly to global names. rdar://41658300 2018-06-29 17:29:53 -07:00
Xi Ge
4ed9f9a9a6 migrator: support the migration from member variables to global ones. rdar://41658300 2018-06-29 16:35:51 -07:00
Nathan Hawes
50f9c94ac8 [migrator] Migrate UIApplicationMain
In Swift 4.2 the second parameter of UIApplicationMain exactly matches the type
of CommandLine.unsafeArgv so it can be called as below:

UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, ...)

This is how it was intended to be in Swift 4 as well, but the types had
optionality differences, so callers instead had to do something like the below
example from the Firefox-iOS project:

let pointer = UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(
    to: UnsafeMutablePointer<Int8>.self, capacity: Int(CommandLine.argc))
UIApplicationMain(CommandLine.argc, pointer, ...)

This migration simply replaces the the second argument with
CommandLine.unsafeArgv if the first argument is CommandLine.argc.

There is an open issue for providing a deprecated version with the old type so
we simply leave as is any callers that don't pass argc for the first argument.

Resolves rdar://problem/40045693.
2018-06-28 18:46:41 -07:00
Xi Ge
9a0196e991 migrator: avoid adding conversion functions when expression types change as well.
When inserting conversion functions around expressions, we should check
whether the type of the expression is a recognized name alias that is
known to be changed to raw-value representable type. We should avoid
inserting conversion functions in this case because doing so causes
build errors.

resolves: rdar://40463990
2018-06-25 14:44:58 -07:00
Xi Ge
859d918a78 Re-apply "[migrator] migrator: avoid inserting base name while renaming
if users' member access doesn't specify the base name. rdar://40373279"

Previously, we saw that unconditionally omitting type names can lead to
build errors (rdar://40458118). This revised fix omits type names only when
the new member name is identical to the old one.
2018-06-19 12:46:02 -07:00
Xi Ge
90303d12a6 migrator: handle the reversion of raw representable changes. rdar://39498127 2018-06-15 16:51:57 -07:00
Xi Ge
6433bc59e7 migrator: avoid migrating synthesized initializer calls. rdar://40860228 2018-06-11 15:30:38 -07:00
Xi Ge
55495ec267 migrator: avoid inserting round-trip conversion functions.
By postponing the insertion of conversion function calls, we can filter
out the expressions that require more than one helper function wrapper.

resolves: rdar://40979943
2018-06-11 15:08:26 -07:00
Xi Ge
7312fea3b2 migrator: emit error messages when migration scripts are missing.
We used to assert migration scripts exist. This patch further
decouples these scripts and the compiler by treating missing scripts
as a regular compiler error.

Related: rdar://40538097
2018-05-25 11:25:32 -07:00
Xi Ge
c8752d1570 [migrator] Revert "migrator: avoid inserting base name while renaming if users' member access doesn't specify the base name. rdar://40373279"
We've seen cases where using dot member names cause build errors. Thus, we revert this QOL fix.

rdar://40458118
2018-05-22 13:58:08 -07:00
Xi Ge
27b1621f90 migrator: avoid inserting base name while renaming if users' member access doesn't specify the base name. rdar://40373279 2018-05-18 12:36:10 -07:00
Xi Ge
6a83c51cf8 migrator: use raw type names from migration scripts instead of hard-coding them. 2018-05-16 17:56:48 -07:00
Nathan Hawes
61d7193814 [migrator] Treat the top-level argument parens of function types as an index level in the ChildIndexFinder
The APIDiffMigrator pass was ignoring them in all cases, but function type
argument parens are significant and the API differ includes them as an index
level in the generated json. This was causing a segmentation fault when trying
to migrate anything inside a function type argument. E.g given the function
below:

func member(_ x: ([Any]?) -> Void) {}

to migrate Any to Int, the API differ produces an index into the signauture of
1:1:0:0:0, meant to indicate Any. The APIDiffMigratorPass was interpreting this
incorrectly, however:

1: The type of first parameter of member: ([Any]?) -> Void
   Migrator agreed.
1: The type of the function type's argument: ([Any]?)
   Migrator saw this as [Any]? due to the parens not being an index level
0: The 0th child of the paren type: [Any]?
   Migrator saw the 0th child of the optional, [Any]
0: the 0th child of the optional type, [Any]
   Migrator saw the 0th child of the array, Any
0: the 0th child of the array type, Any
  Migrator tried to look up the 0th child of Any, causing a crash.

Resolves rdar://problem/40225476.
2018-05-15 12:05:21 -07:00
swift-ci
aa5cb47fec Merge pull request #16598 from nkcsgexi/migrator-arg-rename-hoist 2018-05-14 12:31:48 -07:00
Xi Ge
343d84ba35 migrator: handle argument renames when a global function is hoisted to a static member function. rdar://40145590 2018-05-14 11:33:25 -07:00
Xi Ge
0f71331d73 migrator: avoid inserting helper function call for nil expression. rdar://40173366 2018-05-11 17:24:52 -07:00
swift-ci
9aead6bff3 Merge pull request #16507 from nkcsgexi/avoid-reinsert-function 2018-05-10 13:54:57 -07:00
Xi Ge
b302bd30db migrator: avoid inserting helper functions if a function with the same name exists in the source file. rdar://40108285 2018-05-10 13:20:47 -07:00
Xi Ge
d89b716cf1 migrator: handle composite changes that're necessary to both side of an assignment expression. rdar://40106370 2018-05-10 12:08:00 -07:00
Xi Ge
ca3bf34daf Merge pull request #16479 from nkcsgexi/api-digester-type-change-diff
swift-api-digester: we should further detect if the declared type of a hoisted variable has been changed. rdar://40076924
2018-05-09 17:34:06 -07:00
Xi Ge
740e336e02 migrator: make sure we can handle the composite change of rename and string representable update. radr://40076924 2018-05-09 15:53:51 -07:00
Ben Langmuir
2e1f3afe05 Merge pull request #16460 from benlangmuir/mig-type-rename
[migrator] Handle simple renames for TypeDecl
2018-05-08 16:01:47 -07:00
Ben Langmuir
1bceacf7b8 [migrator] Handle simple renames for TypeDecl
Previously we only handle VarDecl, but it ought to work for types as
well.
2018-05-08 14:32:15 -07:00
Xi Ge
aef79e9b03 migrator: update type name in constructor call if the type becomes nested. rdar://40042252 2018-05-08 14:28:00 -07:00
Xi Ge
3ee07be5ba migrator: handle the migration of string enum variable references. 2018-04-18 14:24:19 -07:00
Xi Ge
5db971de0e migrator: handle assignment of attribute dictionary and others.
When users' codebase assigns an attribute dictionary that used to be of
type [String: Any], this migration inserts a helper function call on the source of
the assignment to bridge the type.
2018-04-18 11:11:27 -07:00
Xi Ge
6a4df3e820 migrator: handle return value migration introduced by string enum changes.
This patch migrates the function call whose return type used to "String" and
now becomes "StringRepresentableStruct".
2018-04-17 15:18:33 -07:00
Xi Ge
7cf8bf4d55 migrator: correct a typo in the inserted helper function. NFC 2018-04-16 13:36:00 -07:00
Xi Ge
65eaccb2fa migrator: teach the tool to handle ArrayMemberUpdate and OptionalArrayMemberUpdate attributes emitted from swift-api-digester.
This bridges the function call arguments that used to be of type [String] and
now become [StringRepresentableStruct].
2018-04-16 13:30:53 -07:00