Commit Graph

158 Commits

Author SHA1 Message Date
Chris Willmore
c7c7388cf2 Change do-while to repeat-while.
Change all uses of "do { ... } while <cond>" to use "repeat" instead.
Rename DoWhileStmt to RepeatWhileStmt. Add diagnostic suggesting change
of 'do' to 'repeat' if a condition is found afterwards.

<rdar://problem/20336424> rename do/while loops to repeat/while & introduce "repeat <count> {}" loops

Swift SVN r27650
2015-04-23 22:48:31 +00:00
Chris Willmore
d3a977d824 <rdar://problem/20402026> Remove scope entry/exit log entries
Don't emit scope entry/exit logging code in instrumentation for
playgrounds if -playground-high-performance option is passed.

Swift SVN r27046
2015-04-06 22:09:20 +00:00
Chris Lattner
59c22383fb Rework PatternBindingDecl to maintain a list of pattern/initexpr pairs inside of it.
Previously, a multi-pattern var/let decl like:
  var x = 4, y = 17

would produce two pattern binding decls (one for x=4 one for y=17).  This is convenient
in some ways, but is bad for source reproducibility from the ASTs (see, e.g. the improvements
in test/IDE/structure.swift and test/decl/inherit/initializer.swift).

The hardest part of this change was to get parseDeclVar to set up the AST in a way
compatible with our existing assumptions. I ended up with an approach that forms PBDs in 
more erroneous cases than before.  One downside of this is that we now produce a spurious
  "type annotation missing in pattern"
diagnostic in some cases.  I'll take care of that in a follow-on patch.





Swift SVN r26224
2015-03-17 16:14:18 +00:00
Chris Lattner
8521916b86 change PatternBindingDecl to be created with a static "create" method instead
of using its ctor directly.  NFC, this is in prep for other changes coming.


Swift SVN r26174
2015-03-16 00:44:52 +00:00
Chris Lattner
20f8f09ea8 Land: <rdar://problem/19382905> improve 'if let' to support refutable patterns and untie it from optionals
This changes 'if let' conditions to take general refutable patterns, instead of
taking a irrefutable pattern and implicitly matching against an optional.

Where before you might have written:
  if let x = foo() {

you now need to write:
  if let x? = foo() {
    
The upshot of this is that you can write anything in an 'if let' that you can
write in a 'case let' in a switch statement, which is pretty general.

To aid with migration, this special cases certain really common patterns like
the above (and any other irrefutable cases, like "if let (a,b) = foo()", and
tells you where to insert the ?.  It also special cases type annotations like
"if let x : AnyObject = " since they are no longer allowed.

For transitional purposes, I have intentionally downgraded the most common
diagnostic into a warning instead of an error.  This means that you'll get:

t.swift:26:10: warning: condition requires a refutable pattern match; did you mean to match an optional?
if let a = f() {
       ^
        ?

I think this is important to stage in, because this is a pretty significant
source breaking change and not everyone internally may want to deal with it
at the same time.  I filed 20166013 to remember to upgrade this to an error.

In addition to being a nice user feature, this is a nice cleanup of the guts
of the compiler, since it eliminates the "isConditional()" bit from
PatternBindingDecl, along with the special case logic in the compiler to handle
it (which variously added and removed Optional around these things).




Swift SVN r26150
2015-03-15 07:06:22 +00:00
Dmitri Hrybenko
b15c0bd01c PlaygroundTransform: don't overflow an Int on 32-bit platforms
Swift SVN r24787
2015-01-28 05:22:41 +00:00
Dmitri Hrybenko
acc4baf2eb Don't use reserved names in PlaygroundTransform
Swift SVN r23989
2014-12-17 20:26:33 +00:00
Dmitri Hrybenko
721b9637ee Revert "Clang-format the PlaygroundTransform.cpp file"
This reverts commit r23984 because I don't have enough free time to
convince everyone that a consistent coding style is a good thing.

Swift SVN r23988
2014-12-17 20:26:32 +00:00
Dmitri Hrybenko
0a6dcd98a0 Revert "Don't use reserved names in PlaygroundTransform"
This reverts commit r23985 because it depends on r23984, which I'm
reverting.

Swift SVN r23987
2014-12-17 20:26:30 +00:00
Dmitri Hrybenko
55d1f0d4fa Don't use reserved names in PlaygroundTransform
Swift SVN r23985
2014-12-17 19:31:17 +00:00
Dmitri Hrybenko
052dd84e2b Clang-format the PlaygroundTransform.cpp file
Swift SVN r23984
2014-12-17 19:31:16 +00:00
Dmitri Hrybenko
45a0740d3c Stop using llvm::RandomNumberGenerator in the playground transform
It was never intended to be used without an llvm::Module.

Swift SVN r23983
2014-12-17 19:31:14 +00:00
Chris Lattner
9414378210 change maintenance of "ParentPattern" in VarDecl to be implicitly handled by PatternBindingDecl itself, instead of having all clients do it.
Swift SVN r23918
2014-12-13 07:35:34 +00:00
Chris Lattner
274310b888 Fix a few VarDecls that are initialized with a PatternBindingDecl but which aren't
getting their ParentPattern set up properly.


Swift SVN r23915
2014-12-13 07:09:30 +00:00
Sean Callanan
9b4b6dcfcf Modified the playground transform to provide a unique ID with
each instrumentation point.  This ID should only be a way to
identify a point for the purposes of the current run, so it is
somewhat random.

<rdar://problem/18788357> Instrumenter should start sending unique ID information for each logged entry to playgroundlogger


Swift SVN r23286
2014-11-12 22:28:16 +00:00
John McCall
6923101341 Rename "AccessKind" to "AccessSemantics". NFC.
There are a lot of different ways to interpret the
"kind" of an access.  This enum specifically dictates
the semantic rules for an access:  direct-to-storage
and direct-to-accessor accesses may be semantically
different from ordinary accesses, e.g. if there are
observers or overrides.

Swift SVN r22290
2014-09-25 23:12:39 +00:00
John McCall
8cae5ba1d0 Generalize 'isDirectPropertyAccess' to allow for
direct (i.e. non-polymorphic) access to accessor
functions, and use this in materializeForSet for
computed properties.

Swift SVN r22059
2014-09-18 05:51:32 +00:00
Sean Callanan
f14a1d7d88 Made the PlaygroundTransform support InOutExprs.
This allows e.g. array.append() to be logged
properly.

Added a test case.

<rdar://problem/17000097>


Swift SVN r21321
2014-08-20 21:21:21 +00:00
Sean Callanan
358bd09f3d Instrument mutations of ivars in playgrounds.
We accomplish this by generalizing the case of
references to variables.

Added a test case.

<rdar://problem/17000097>


Swift SVN r21302
2014-08-20 00:32:57 +00:00
Sean Callanan
612e7e65a6 Don't adjust line numbers in the PlaygroundTransform.
LLDB now uses #line directives to ensure that the
source lines are reported correctly.

<rdar://problem/17872766>


Swift SVN r20908
2014-08-01 18:54:44 +00:00
Sean Callanan
0159a1415d Don't instrument "self" in a constructor.
Instrumenting "self" might make the constructor
use "self" before calling its parent's constructor,
causing a SIL error.

Added a matching testcase.

<rdar://problem/17765562>


Swift SVN r20660
2014-07-29 00:04:44 +00:00
Sean Callanan
573cb7d63e Removed an unnecessary variable. Thanks Ben!
Swift SVN r20510
2014-07-24 19:01:33 +00:00
Sean Callanan
c6a21ff710 Omit scope entry and exit for playground top-level code.
Added a testcase for scopes.

<rdar://problem/17068383>


Swift SVN r20506
2014-07-24 18:36:49 +00:00
Sean Callanan
9bc668b119 Fixes to the playground transform to make it work
with the test case I'm working on.

Who knew that test cases find bugs?


Swift SVN r20451
2014-07-24 00:42:18 +00:00
Sean Callanan
b96e08139b Fixed the PlaygroundTransform so it doesn't make
the testsuite crash.  Restored the print/println
logging functionality.


Swift SVN r20341
2014-07-22 22:23:14 +00:00
Jordan Rose
140801f931 Revert "Extended the playground transform to handle print()"
This reverts r20200. It didn't have any tests and broke the existing
playground test.

Swift SVN r20227
2014-07-20 17:31:58 +00:00
Sean Callanan
1960c22f8b Extended the playground transform to handle print()
and println() calls, forwarding them appropriately
to versions in the PlaygroundLogger.

Also fixed a crash when dumping the instrumentation
call for debug purposes, by giving the arguments to
the call proper source locations.

<rdar://problem/16762680>


Swift SVN r20200
2014-07-19 01:41:56 +00:00
Sean Callanan
29edb6434f Make sure we instrument all function-like things,
e.g. constructors, and not just regular functions,
for playgrounds.

<rdar://problem/16975581>


Swift SVN r20042
2014-07-16 21:32:12 +00:00
Doug Gregor
f746481538 Reinstate r18522 "this patch fixes the playground transform to support transforming top-level code" with a hack to remove null elements.
This transform routine needs some serious work, because it's quadratic
in the number of elements (due to vector insertions everywhere) and
not resilient to type-checking failures. However, this
removing-null-elements hack is progress.



Swift SVN r18557
2014-05-22 06:47:42 +00:00
Dave Abrahams
75fec75dff Revert "This patch fixes the playground transform to support"
This reverts r18522, which was causing IRGen/playground.swift to fail in
various fun ways.

Swift SVN r18555
2014-05-22 05:38:28 +00:00
Sean Callanan
a5f737cc1c This patch fixes the playground transform to support
transforming top-level code.  This involves these
changes:

- The playground transform now looks for functions
  and top level code throughout the source file
  rather than identifying a single function whose
  body needs to be transformed.  

- The playground transform now does not look for
  VarDecls to transform; rather it looks for
  PatternBindingDecls with initializers.  This
  is because the VarDecls are typically at top
  level, where logging code can't be added, but
  the PatternBindingDecls are already in
  TopLevelCodeDecls.

<rdar://problem/16977837>


Swift SVN r18522
2014-05-21 21:19:52 +00:00
Sean Callanan
c30901cd94 Updated the line offset in the playground transform
to reflect the fact that a line got added to the
wrapper.

<rdar://problem/16905389>


Swift SVN r18076
2014-05-14 19:16:45 +00:00
Sean Callanan
e3d2c7c079 Handle implicit conversions in the playground
transform, so that assignments to properties of
superclasses are logged properly.

<rdar://problem/16789091>


Swift SVN r17747
2014-05-09 00:52:41 +00:00
Sean Callanan
a3a5447f14 Ignore implicit Decls when instrumenting
playgrounds.  They don't have source locations
inside them so it's not really safe to generate
log calls.

<rdar://problem/16835641>


Swift SVN r17642
2014-05-07 20:32:48 +00:00
Sean Callanan
9336c8f84f Updated the playground transform to instrument
methods of classes, structs, extensions, etc.

<rdar://problem/16806714>


Swift SVN r17556
2014-05-06 19:47:58 +00:00
Sean Callanan
904cccf77d Fixed a bug where the playground transform tried
to initialize variables using lvalues.  Instead
it now uses a LoadExpr to convert the lvalue to
an rvalue before using it as an initializer.

<rdar://problem/16812526>


Swift SVN r17553
2014-05-06 17:36:09 +00:00
Doug Gregor
9cfb1b5ca4 Keep track of the locations of the element names in a TupleExpr.
As part of this, use tail allocation to reduce the memory footprint of
TupleExprs. Use factory methods to make it easier to construct.

I'll be using this information in a follow-on patch. SourceKit
probably wants it as well.


Swift SVN r17129
2014-05-01 00:16:36 +00:00
Sean Callanan
2d689365c0 Modified the playground transform to fix two
problems related to scopes:

  - First, the return value was being printed
    after the relevant scope exits.  I switched
    the order.

  - Second, two "global" scopes were being
    emitted -- one for the wrapper function,
    and one for the wrapper "if" statement.  We
    only need one, so I added necessary gating.

<rdar://problem/16765632>


Swift SVN r17122
2014-04-30 23:20:03 +00:00
Sean Callanan
baded9a328 Modified the playground transform to treat assignments
to properties of objects as mutations of the underlying
object.  This means that we report the new state of the
object rather than reporting the value of what was
assigned to the property.

<rdar://problem/16688167>


Swift SVN r17065
2014-04-30 02:24:39 +00:00
Sean Callanan
57a432eec4 Changed the playground transform to report the end
of the final token in each source range rather than
its beginning.  This means we report much better
character ranges.

<rdar://problem/16603092>


Swift SVN r17063
2014-04-30 01:32:23 +00:00
Sean Callanan
f7e6c67413 Modifying the playround transform to support logging
of statements like "x += y".  This involved two changes:

 - Where we previously only treated CallExprs as function
   calls, now we instead look at ApplyExprs.  This covers
   cases like this += call, which is actually a BinaryExpr.

 - For all such Exprs, if there is exactly one inout
   argument and the Expr returns void, log that argument.

<rdar://problem/16609821>


Swift SVN r17046
2014-04-29 22:10:13 +00:00
Sean Callanan
54eb58bbd8 Modified the playground transform to report the
name of the affected variable when appropriate
(i.e., for declarations, mutations, and
assignments).

Also removed an unused function.

<rdar://problem/16583133>


Swift SVN r17006
2014-04-29 00:48:10 +00:00
Sean Callanan
ed02db7d5d Fixed a bug where the playground transform was
generating typeless assignments, which the
type checker hates.

<rdar://problem/16674964>


Swift SVN r16633
2014-04-21 23:23:38 +00:00
Chris Lattner
84d360bbb9 remove two dead functions.
Swift SVN r16573
2014-04-20 00:22:15 +00:00
Sean Callanan
2c3e86bfb6 Updated the PlaygroundTransform to no longer
require that the modules it uses are present.
LLDB now explicitly forward-declares the builtins
that transformed code requires, so we can just
use them.

This makes the playground transform less error
prone, and means that if the functions really are
missing we'll get a nice and obvious link error
rather than a hard-to-diagnose error where the
playground transform quietly refuses to do
anything.

<rdar://problem/16599338>


Swift SVN r16563
2014-04-19 03:11:04 +00:00
Sean Callanan
1fe0b3dd2e Modified the playground transform to instrument
closure bodies wherever we find them.

<rdar://problem/16647809>


Swift SVN r16480
2014-04-17 23:57:24 +00:00
Sean Callanan
f35acb6dba Updated the playground transform to handle switch
statments.

<rdar://problem/16628109>


Swift SVN r16461
2014-04-17 19:21:28 +00:00
Sean Callanan
23e6fccf4d Only log variable declarations that have
initializations, to avoid errors about use
before initialization.

<rdar://problem/16587570>


Swift SVN r16237
2014-04-11 23:41:40 +00:00
Sean Callanan
630ce68ba9 Completed my changes to the playground transform
to support brace entry/exit.  We now maintain a
stack of brace statements we know we're inside.
The elements of this stack are colored:

- If we encounter a loop, while we are walking
  that loop we color its container to indicate
  that "break" and "continue" exit all braces
  up until the container of the loop.

- If we encounter a function, while we are
  walking that function we color its container
  to indicate that "return" exits all braces
  up until the container of the function.

Since at this point every BraceStmt is modified,
we don't need the "Modified" flag and I excised
it.


Swift SVN r16230
2014-04-11 21:48:39 +00:00
Sean Callanan
bf0a540b4e Updated the playground transform to log brace
entries and exits.

  - Added support to buildLoggerCall for different
    logger functions;

  - Added support to buildLoggerCall to handle
    source locations that fall outside the
    user-entered expression text; and

  - Added the necessary logging functions to the
    functions we check for before adding our
    instrumentation.

This involved some minor refactoring.  I still have
to add a stack of scopes that I can pop out of when
I see a break, continue, or return.


Swift SVN r16197
2014-04-11 03:28:08 +00:00