Commit Graph

86 Commits

Author SHA1 Message Date
Dmitri Gribenko
a9f8d97d3e Replace 'unsigned int' with 'unsigned'
'unsigned' is more idiomatic in LLVM style.
2016-02-27 16:20:27 -08:00
Han Sangjin
e06c7136cb Porting to Cygwin. rebased and squashed 2016-02-22 13:20:21 +09:00
Xi Ge
77b7180f1a Rename CodeCompletionTypeChecking.h to IDETypeChecking.h since it's used by more clients now. NFC 2016-02-04 11:09:21 -08:00
Adrian Prantl
ecd47e0a81 PlaygroundTransform: Use a global TmpNameIndex to avoid having multiple
temporaries with the same name in the same scope.

rdar://problem/24318554
2016-01-27 14:12:15 -08:00
Doug Gregor
8336419844 Include completion source location information compound DeclNames.
When one spells a compound declaration name in the source (e.g.,
insertSubview(_:aboveSubview:), keep track of the locations of the
base name, parentheses, and argument labels.
2016-01-25 14:13:13 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Arsen Gasparyan
be738abb7c Fix else code style 2015-12-22 11:13:26 +03:00
Sean Callanan
8a0b1a7244 Updated PlaygroundTransform to call a function after print() is called.
We no longer try to change the print() statement.  I updated the tests, too.

<rdar://problem/22079705> ER: PlaygroundTransform support for print() API


Swift SVN r30891
2015-07-31 23:39:47 +00:00
Sean Callanan
1d9cdbbfeb PlaygroundTransform now forwards print() arguments to $builtin_print() exactly.
We put the argument to be printed (so not the stream or the appendNewline:) into
a temporary variable to avoid type-checking nastiness.  I also made the test
case considerably more comprehensive.

<rdar://problem/21905513> [Swift submission] playgrounds need to handle print with weird arguments


Swift SVN r30457
2015-07-21 18:30:51 +00:00
Chris Lattner
59f912ac3c Speculatively change PlaygroundTransform to stop using FreeTypeVariableBinding::GenericParameters,
there are two possible situations here:

1) This code never runs on invalid code, in which case this argument does nothing.
2) This code does run on invalid code, and the type checker would crash as 
   TypeCheckExpr attempted to apply the solution.

This causes no regressions on the playground logger testsuite, but I'm not really confident
in this so I'll chat with Sean.



Swift SVN r30182
2015-07-14 00:52:59 +00:00
Chris Lattner
3edd82837f remove the isDiscarded bool from TypeChecker::solveForExpression
and getTypeOfExpressionWithoutApplying and change typeCheckExpression
to take it as a single-entry OptionSet, in prep for getting other 
options.  NFC.


Swift SVN r30121
2015-07-11 22:06:45 +00:00
Sean Callanan
872a1c8592 Sequester expressions the PlaygroundTransform adds, isolating type-check errors.
We had a bit of back-and-forth over how to handle type-check errors in added
expressions.  Obviously all added expressions *should* type-check -- but we
don't want the compiler (and, by extension, the XPC playground service) crashing
when they don't.  So the ErrorTypes from failed type-checks must not leak into
existing code.

In this solution, we use a convenience class (Added) that wraps an expression.
It marks expressions we've constructed -- and we're only allowed to type-check
Added<Expr*>s.  (This isn't fully enforced -- you could still have Added<Expr*>s
that refer to existing Expr*s) but adding this and plumbing it through caught
most of the problems.

I also added checks to various places that weren't checking whether type
checking succeeded.  In one case where we were emitting a source location for
one element in a TupleExpr but not emitting source locations for the others
(which caused dumping to assert) I eliminated that source location.

Finally I added several test cases.  These cases used to crash; one of them
works perfectly now and I've XFAILed the other two.

<rdar://problem/20444876>


Swift SVN r29842
2015-07-01 17:53:06 +00:00
Ted Kremenek
57265acbfc Revert "Updated the playground transform's error handling. Specifically, we now report type-checking errors in added instrumentation to llvm::errs() and try to restore the ASTs to their former state."
This reverts commit r29798.

This commit was breaking the iOS bots.

Swift SVN r29800
2015-06-30 03:50:56 +00:00
Sean Callanan
789eff28e1 Updated the playground transform's error handling.
Specifically, we now report type-checking errors in
added instrumentation to llvm::errs() and try to
restore the ASTs to their former state.

As Jordan points out, this requires a better and
more full solution, involving some form of AST
cloning or doing the playground transform at the
SIL level.  I have left in a TODO to that effect.

<rdar://problem/20444876>


Swift SVN r29798
2015-06-30 00:46:45 +00:00
Sean Callanan
814a2d6623 Don't build temporary variables of InOutType.
This only appears in the print logging for now.
I've got to figure out a way of transforming
print() calls without building temporary variables
left and right.

<rdar://problem/21412489>


Swift SVN r29683
2015-06-25 20:01:24 +00:00
Sean Callanan
eb1ea2aca0 Harden the PlaygroundTransform against type-checking
errors.  These errors are now printed to errs() and
the data they produce is not used, avoiding crashes
later in SILGen when we encounter ErrorTypes.

<rdar://problem/20444876>
<rdar://problem/21321078>
...


Swift SVN r29674
2015-06-25 17:38:13 +00:00
Sean Callanan
eb8c9ac5e7 Handle "do { }" statements in playgrounds. Also
added a testcase.

<rdar://problem/21473935>


Swift SVN r29649
2015-06-25 00:43:48 +00:00
Chris Lattner
1b49bc31f8 improve coding style: remove unneeded llvm:: qualifications,
use isa instead of dyn_cast when ignoring the results, etc. NFC.


Swift SVN r29507
2015-06-19 05:45:04 +00:00
Sean Callanan
b2c6f4e5d5 Added support for do-catch blocks to the playground
transform.  Also added a testcase.

<rdar://problem/21196212> Some results don't show in sidebar -- why?


Swift SVN r29247
2015-06-02 20:03:23 +00:00
Sean Callanan
33b0079a95 Made the PlaygroundTransform instrument the print()/
debugPrint() APIs correctly.  PlaygroundLogger implements
APIs that always take a boolean as their second argument.
If print()/debugPrint() are called with just one argument,
we add "true" as the second argument and replace the call
with a call to the appropriate PlaygroundLogger API.

Also modified the testcase to verify that this is happening
correctly, including when the boolean argument comes from a
more complicated expression.

<rdar://problem/21084145> [Swift integration] Playground AST rewrites not updated for latest Swift standard library changes


Swift SVN r28946
2015-05-23 02:07:25 +00:00
Ben Langmuir
69fdca43da Fix assertion failure code completing after nil literal
We were asserting (and doing the wrong thing) when trying to code
complete
    nil #^HERE^#

The issue is that we tried to apply a solution to the expression that
contained free type variables (converted to generic parameters). This
trips us up when we expect the new type to conform to protocols. In code
completion we generally only need the type of the expression, so this
commit switches to getting that more explicitly.  That said, this did
cause us to drop non-API parameter names in call patterns after an
opening '(' in some cases (covered by rdar://20962472).

Thanks to Doug for suggesting this solution!

rdar://problem/20891867

Swift SVN r28584
2015-05-14 22:22:37 +00:00
Sean Callanan
032eefaed9 Make the PlaygroundLogger be able to deal with
all the strange and wonderful new ways of printing
things.  Also addeed a testcase.

Note: this does not yet pass information about
which version (print vs. debugPrint) is called and
whether a newline is desired or not; that will be
in a future commit once the PlaygroundLogger
support for that is in a build.

<rdar://problem/20859024>


Swift SVN r28518
2015-05-13 18:12:16 +00:00
John McCall
35fc1a090c Track whether an ApplyExpr throws in the AST.
Verify that this bit is set during type-checking on
every ApplyExpr, and fix the remaining locations where
we weren't doing coverage testing on expressions; most
of these were harmless, but it's better to be safe.

Swift SVN r28509
2015-05-13 07:11:44 +00:00
Dmitri Hrybenko
f46f16ae82 stdlib: implement new print() API
rdar://20775683

Swift SVN r28309
2015-05-08 01:37:59 +00:00
John McCall
36c605f7dc Remove ScalarToTupleExpr in favor of a flag on TupleShuffleExpr.
Also, implement in-place initialization through tuple shuffles.

Swift SVN r28227
2015-05-06 23:44:26 +00:00
Chris Lattner
37f5452d15 require -> guard.
Swift SVN r28223
2015-05-06 22:53:38 +00:00
Chris Lattner
0011b3ae21 rename "unless" to "require" and give it an 'else' keyword.
Swift SVN r28059
2015-05-02 00:16:44 +00:00
Chris Lattner
c6aa041fb9 Add parser/ast/sema/sourcekit/etc support for 'unless' statement.
SILGen support still missing.



Swift SVN r27961
2015-04-30 05:55:11 +00:00
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