Commit Graph

77 Commits

Author SHA1 Message Date
swift-ci
448807f579 Merge remote-tracking branch 'origin/master' into master-next 2019-09-20 19:09:54 -07:00
Robert Widmann
f0e73c84fc Merge pull request #26480 from CodaFi/makes-a-nominal-decl-healthy-wealthy-and-memberwise
[FB6918951] Expand "Make Memberwise Initializer" Refactoring Action
2019-09-20 19:01:16 -07:00
swift-ci
c97950d7da Merge remote-tracking branch 'origin/master' into master-next 2019-08-19 21:30:00 -07:00
Slava Pestov
80ccbe5116 AST: Stop passing around a LazyResolver in name lookup
Note that in all cases it was either nullptr or ctx.getLazyResolver().
While passing in nullptr might appear at first glance to mean something
("don't type check anything"), in practice we would check for a nullptr
value and pull out ctx.getLazyResolver() instead. Furthermore, with
the lazy resolver going away (at least for resolveDeclSignature() calls),
it won't make sense to do that anymore anyway.
2019-08-19 23:00:57 -04:00
Jonas Devlieghere
b4d268e9e1 Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances in the swift repo.
2019-08-15 11:32:39 -07:00
Slava Pestov
6c5ecb5fc9 AST: Introduce AbstractStorageDecl::visit{Parsed,Emitted}Accessors() 2019-08-06 16:30:13 -04:00
Robert Widmann
713dcd8762 Expand Memberwise Initializer Refactoring Action
- Struct declarations are now eligible for the refactoring action
- Default argument expressions specified in source are printed into the generated initializer as well

Note that we are explicitly missing the ability to print a 'nil' default argument for members of type T? because TypeReprs are not fully resolved by the time the refactoring engine runs.
2019-08-03 22:36:15 -07:00
Xi Ge
8f1a9b4789 IDE+Evaluator: refactor range info resolver to an IDE evaluator request. NFC 2019-07-17 12:20:09 -07:00
Xi Ge
8915cf8c4d Sourcekit/Evaluator: refactor cursor-info resolver to using the evaluator model. NFC
This change adds a new IDE request ID zone and refactors the cursor-info resolver
to use the request evaluator model.
2019-07-16 09:55:16 -07:00
Nathan Hawes
306584339e Merge pull request #26016 from cltnschlosser/SR-11077-inner-rename-nested-type
[refactoring] Fix error when renaming nested type at constructor - init() has no declaration location
2019-07-11 17:49:12 -07:00
Colton Schlosser
07675a75e0 [refactoring] Fix error when renaming nested type at constructor - init() has no declaration location
Resolves SR-11077
2019-07-10 21:02:00 -04:00
Власов Антон Вячеславович
f119f211e6 SR-5744 Fixs from comments to pull request 2019-07-09 17:49:19 +03:00
Власов Антон Вячеславович
8acd794935 SR-5744 Refactoring action to convert if-let to guard-let and vice versa 2019-07-09 16:21:25 +03:00
Slava Pestov
4c499fd4ac AST: Stop passing around LazyResolvers in various places 2019-07-06 00:43:22 -04:00
Argyrios Kyrtzidis
3332b37d00 [Index/SourceKit] Remove the code related to calculating a module hash from the indexing walker
This has been an unnecessary code path for a long time now and should be removed particularly because it triggers wasteful `stat` calls.

rdar://51523161
2019-06-21 17:09:12 -07:00
Slava Pestov
1467f554f5 AST: Remove ArgumentShuffleExpr 2019-03-31 01:36:19 -04:00
Slava Pestov
e212d4567f Sema: Collect varargs into an ArrayExpr and use DefaultArgumentExpr
Instead of building ArgumentShuffleExprs, lets just build a TupleExpr,
with explicit representation of collected varargs and default
arguments.

This isn't quite as elegant as it should be, because when re-typechecking,
SanitizeExpr needs to restore the 'old' parameter list by stripping out
the nodes inserted by type checking. However that hackery is all isolated
in one place and will go away soon.

Note that there's a minor change the generated SIL. Caller default
arguments (#file, #line, etc) are no longer delayed and are instead
evaluated in their usual argument position. I don't believe this actually
results in an observable change in behavior, but if it turns out to be
a problem, we can pretty easily change it back to the old behavior with a
bit of extra work.
2019-03-31 01:36:19 -04:00
Slava Pestov
d470e9df4d AST: Split off ArgumentShuffleExpr from TupleShuffleExpr
Right now we use TupleShuffleExpr for two completely different things:

- Tuple conversions, where elements can be re-ordered and labels can be
  introduced/eliminated
- Complex argument lists, involving default arguments or varargs

The first case does not allow default arguments or varargs, and the
second case does not allow re-ordering or introduction/elimination
of labels. Furthermore, the first case has a representation limitation
that prevents us from expressing tuple conversions that change the
type of tuple elements.

For all these reasons, it is better if we use two separate Expr kinds
for these purposes. For now, just make an identical copy of
TupleShuffleExpr and call it ArgumentShuffleExpr. In CSApply, use
ArgumentShuffleExpr when forming the arguments to a call, and keep
using TupleShuffleExpr for tuple conversions. Each usage of
TupleShuffleExpr has been audited to see if it should instead look at
ArgumentShuffleExpr.

In sequent commits I plan on redesigning TupleShuffleExpr to correctly
represent all tuple conversions without any unnecessary baggage.

Longer term, we actually want to change the representation of CallExpr
to directly store an argument list; then instead of a single child
expression that must be a ParenExpr, TupleExpr or ArgumentShuffleExpr,
all CallExprs will have a uniform representation and ArgumentShuffleExpr
will go away altogether. This should reduce memory usage and radically
simplify parts of SILGen.
2019-03-21 02:18:41 -04:00
Xi Ge
28daecad81 refactoring: add a defensive check for nullptr. rdar://48290050 2019-02-25 11:02:05 -08:00
Robert Widmann
c5b7230d22 [NFC] Upgrade EnumElementDecl to a DeclContext
Pure plumbing for the sake of default arguments.
2019-01-16 18:39:30 -05:00
Jordan Rose
ac4a92a968 Merge pull request #19292 from jrose-apple/get-out-the-map
Minor improvements to the use of StringMap/StringSet
2018-09-14 10:52:59 -07: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
Jordan Rose
245b06b832 Use llvm::StringSet instead of StringMap where appropriate
That is, where we aren't using the value for anything.

No functionality change.
2018-09-13 15:15:24 -07:00
Slava Pestov
e520dd613b IDE: Remove hasAccess() checks 2018-09-05 16:51:42 -07:00
Xi Ge
bff3f8adcc Merge pull request #16983 from mohitathwani/SR-7292
[WIP] Generating member wise initializer with local refactoring
2018-07-26 13:05:08 -07:00
Mohit Athwani
ce1122921a SR-7292 - Refactoring tool for generating member wise init 2018-07-26 11:31:30 -07:00
Rintaro Ishizaki
711cef6869 [Refactoring] Fix crasher in switch with non-nominal subject type
rdar://problem/42098130
2018-07-24 18:07:07 +09:00
John McCall
9bee3cac5a Generalize storage implementations to support generalized accessors.
The storage kind has been replaced with three separate "impl kinds",
one for each of the basic access kinds (read, write, and read/write).
This makes it far easier to mix-and-match implementations of different
accessors, as well as subtleties like implementing both a setter
and an independent read/write operation.

AccessStrategy has become a bit more explicit about how exactly the
access should be implemented.  For example, the accessor-based kinds
now carry the exact accessor intended to be used.  Also, I've shifted
responsibilities slightly between AccessStrategy and AccessSemantics
so that AccessSemantics::Ordinary can be used except in the sorts of
semantic-bypasses that accessor synthesis wants.  This requires
knowing the correct DC of the access when computing the access strategy;
the upshot is that SILGenFunction now needs a DC.

Accessor synthesis has been reworked so that only the declarations are
built immediately; body synthesis can be safely delayed out of the main
decl-checking path.  This caused a large number of ramifications,
especially for lazy properties, and greatly inflated the size of this
patch.  That is... really regrettable.  The impetus for changing this
was necessity: I needed to rework accessor synthesis to end its reliance
on distinctions like Stored vs. StoredWithTrivialAccessors, and those
fixes were exposing serious re-entrancy problems, and fixing that... well.
Breaking the fixes apart at this point would be a serious endeavor.
2018-06-30 05:19:03 -04:00
Rintaro Ishizaki
1ca88478a8 [Refactoring] Handle TupleShuffleExpr in "convert to trailing closure"
Fixes crash in "Convert To Trailing Closure" action if call has
defaulted parameters. Handle `TupleShuffleExpr` properly.

rdar://problem/41093898
2018-06-18 16:18:58 +09:00
John McCall
69f4dd1ec9 Generalize accessor storage to preserve the original accessor list.
Only not NFC because it's detectable by source tools.
2018-06-16 18:16:31 -04:00
Rintaro Ishizaki
3c367e9227 [Refactoring] Simplify implementation of "move members to extension" action 2018-05-25 19:04:01 +09:00
Rintaro Ishizaki
db3020f031 [Refactoring] Disallow several kinds of decl to move to extension
* AccessorDecl and EnumElementDecl aren't independent decls
* DestructorDecl and EnumCaseDecl can't be put in extension
2018-05-25 19:04:01 +09:00
Rintaro Ishizaki
025f4dde55 Merge pull request #16789 from rintaro/refactoring-nested-if
[Refactoring] Re-implement "collapse nested if" action
2018-05-24 07:56:02 +09:00
Rintaro Ishizaki
70ff0c013b [Refactoring] Disallow extracting partial statement
`BraceStmt`, `CatchStmt` and `CaseStmt` cannot be independent
statement, thus unextractable.

rdar://problem/38390401
2018-05-23 18:03:27 +09:00
Rintaro Ishizaki
639fb85c5f [Refactoring] Rename CollapseNestedIfExpr to CollapseNestedIfStmt
'if' is not expression, but statement.
2018-05-23 17:13:35 +09:00
Rintaro Ishizaki
f1c8230b2a [Refactoring] Re-implement "collapse nested if" action
Narrowed `isApplicable()` condition to ensure that we don't emit this
action when it's not safe to apply this action.

Fixes rdar://problem/39516354
2018-05-23 17:13:35 +09:00
Huon Wilson
75313cfed5 [IDE] make replace.bodies.with.fatalError an internal refactoring.
This shouldn't be exposed to general users.
2018-04-17 09:05:26 +10:00
Huon Wilson
fac1a529fe [IDE] Tweak replace.bodies.with.fatalError.
The menu item should be capitalised, and it's nicer if the fatalError is on its
own line in the new function body.
2018-04-16 12:58:55 +10:00
Huon Wilson
8056102ee5 [IDE] Refactoring to change function bodies to "fatalError()".
This is immensely useful when working on generic code, where the signatures
of (many) functions are all that is required, and removing the bodies makes
things compile faster, allows tools like creduce to work better and results in
less noise in a debugger.

Unfortunately the design of refactoring means this currently only works on a
single top-level decl, or multiple decls inside a type.
2018-04-13 15:56:56 +10:00
Rintaro Ishizaki
53be298f1f [IDE] Don't emit “Convert to Trailing Closure” for trailing closure (#15824)
rdar://problem/39253640
2018-04-09 15:30:52 +09:00
Robert Widmann
03580d2fe5 Add a parameter list to EnumElementDecl
This models, but does not plumb through, default arguments.
2018-03-28 00:05:56 -04:00
Sho Ikeda
25cdc981c7 Merge pull request #14977 from ikesyo/gardening-use-empty
[gardening] Use `empty()` over `size() == 0`
2018-03-07 09:34:26 +09:00
Nathan Hawes
743d3a5f44 Merge pull request #14980 from nathawes/rdar37905156-rename-init-gives-empty-categorised-edit-ranges
[refactoring] Avoid producing empty string/comment categorized edit ranges when renaming init. Also disallow renaming inits with no arguments.
2018-03-06 15:40:22 -08:00
Nathan Hawes
91ec9982a8 [refactoring] Avoid producing empty categorised edit ranges when renaming init. Also disallow renaming inits with no arguments. 2018-03-05 18:38:35 -08:00
Xi Ge
2f47af6c7c refactoring: don't assume every pattern binding has an initializer. rdar://38062772 2018-03-05 16:14:09 -08:00
Sho Ikeda
26d650292f [gardening] Use empty() over size() == 0 2018-03-05 14:43:13 +09:00
David Ungar
a9819b6e60 Renaming FrontendInputs -> FrontendInputsAndOutputs
Fix comment in ArtsToFrontendOptionsConverter re getOutputFilenamesFromCommandLineOrFilelist
2018-01-30 18:54:38 -08:00
Xi Ge
cf36346021 refactoring: when RangeInfo is of kind PartOfExpression, we should use the dedicated field to get the parent expression. rdar://36755861 (#14088) 2018-01-23 12:53:50 -08:00
Xi Ge
a73b767bf6 refactoring: add a defensive check against null type. rdar://36305791 (#14014) 2018-01-18 17:28:54 -08:00
John McCall
7f0f8830cd Split AccessorDecl out from FuncDecl. NFC.
This has three principal advantages:

- It gives some additional type-safety when working
  with known accessors.

- It makes it significantly easier to test whether a declaration
  is an accessor and encourages the use of a common idiom.

- It saves a small amount of memory in both FuncDecl and its
  serialized form.
2018-01-12 14:20:27 -05:00