Commit Graph

2563 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
1d27584ef8 [swift-ide-test] Rename option '-terminal-output' -> '-terminal'.
Swift SVN r8619
2013-09-25 01:35:38 +00:00
Argyrios Kyrtzidis
0fe6d45e62 [IDE] Introduce semantic annotation functionality and test.
Swift SVN r8618
2013-09-25 01:35:36 +00:00
Stephen Lin
4b6e14ba5d Clone DebugScope to new instruction when inlining, for Adrian (who will write tests for this)
Swift SVN r8614
2013-09-24 23:56:52 +00:00
Argyrios Kyrtzidis
2456b33471 Propagate implicit'ness of OverloadSetRefExpr nodes.
Swift SVN r8604
2013-09-24 21:18:00 +00:00
Dmitri Hrybenko
725b0e01eb AST Printer: fix printing of same type requirement in generic parameter lists
These types are really the same for the type checker, so they are printed in
exactly the same way.  To recover the original spelling, prefer to print
a TypeRepr, if available.


Swift SVN r8603
2013-09-24 21:16:35 +00:00
Argyrios Kyrtzidis
e224667315 Refactor Implicit'ness of expressions.
Introduce a bit in Expr to indicate whether the expression is implicit and decouple the implicitness
of an expression from whether it has a source location or not.

This allows implicit expressions to be able to point at the source location where they originated from.
It also allows decoupling the implicitness of a parent from its children, so for example, an implicit CallExpr
can have an explicit parameter value.

Swift SVN r8600
2013-09-24 20:42:29 +00:00
Manman Ren
6ff9cee5e5 "transparent" attribute on SILFunction
Update SILPrinter, SILParser, SILSerializer and SILDeserializer to handle
the attribute.


Swift SVN r8597
2013-09-24 19:06:05 +00:00
Michael Gottesman
4dc7cee606 Add in the option -disable-llvm-optzns to swift.
-disable-llvm-optzns in clang tells the frontend to do everything it would
normally do at lets say -O2, except run the actual LLVM IR passes on the
resulting IR. This is useful in the case where one wants to look at the result
of a non gauranteed SIL optimization pass at the IR level without llvm
optimizations applied.

Swift SVN r8594
2013-09-24 16:48:09 +00:00
Doug Gregor
f67aa78d69 Dynamic lookup for subscripts: semantic analysis and ASTs.
Swift SVN r8591
2013-09-24 05:51:30 +00:00
Doug Gregor
6a1db609e0 Allow [objc] subscripts and emit Objective-C thunks for the getters/setters.
Sema and SILGen; IRGen to follow.


Swift SVN r8589
2013-09-24 02:26:23 +00:00
Joe Groff
1921d265e3 Sema: Check that enum raw values are unique.
Track raw values of the enum in a DenseMap and flag repeat values, taking care to treat equal floating-point and integer values as the same key. Also keep track of the most recent explicit raw value for each implicit raw value, so that if we end up with repeated values due to auto-incrementing behavior, the diagnostic can include notes about where the auto-increment began.

Swift SVN r8586
2013-09-24 02:03:24 +00:00
Dmitri Hrybenko
10d8fdc64f AST/AbstractFunctionDecl: Remember if a function had a selector-style signature
... and use this information in AST printing


Swift SVN r8583
2013-09-24 00:56:33 +00:00
Manman Ren
be3a4101ed SIL Serialization: perform SIL linking right after SILGen.
Add a SILLinkage mode "Deserialized" to make sure IRGen will emit
hidden symbols for deserialized SILFunction.

Inside SIL linker, set Linkage to external if we only have a declaration for
a callee function.

Both sil block and decl block in a module can emit an array of substitutions.
To share the serialization between SILSerializer and Serializer, we modify
the interface to pass in the abbreviation codes to write functions and to
pass in a cursor to read functions.

We now correctly handle the serialization of Substitutions in SpecializeInst.

For a deserialized SILFunction, we now temporarily set its SILLocation and 
DebugScope to an empty FileLocation. Once mandatory inliner sets the SILLocation
to the location of ApplyInst, a null SILLocation and a null DebugScope
may work for a deserialized SILFunction.

Update testing cases to reflect that we are now inlining transparent functions
from modules, or to disable SILDeserializer for now (I am not sure how to update
those testing cases).


Swift SVN r8582
2013-09-24 00:44:54 +00:00
Joe Groff
55bbf1f8bd Stale comment.
Swift SVN r8578
2013-09-24 00:17:59 +00:00
Joe Groff
014f270516 SIL: Have project_existential_ref project to a protocol Self archetype.
This mirrors the behavior of project_existential and simplifies some special cases in SILGen. It unfortunately makes dynamic_lookup sequences a bit noisier because of the need to explicitly cast the projection from DynamicLookup.Self to Builtin.ObjCPointer, but I think this modeling is more solid and will fit better with my planned redesign of archetype_method/protocol_method.

Swift SVN r8572
2013-09-23 21:57:12 +00:00
Dmitri Hrybenko
af8fa8c8cd Remove a circular dependency AST<->Sema caused by type printing
AST used to depend on Sema in type printing.  Specifically,
TypeVariableType::printImpl() is inside Sema.

This change moves the type variable identifier from
TypeVariableType::Implementation to TypeVariableType. This enables us to print
type variables in AST library.

Because type variable type is a temporary type for use inside type checker
only, I don't expect that we will modify it to be more verbose to enhance
diagnostics.  This is a job for locator printing.


Swift SVN r8559
2013-09-23 17:40:43 +00:00
Joe Groff
9e54a69016 SIL: Allow RefToObjectPointer and ObjectPointerToRef to cast to/from Builtin.ObjCPointer.
Swift SVN r8558
2013-09-23 16:20:29 +00:00
Argyrios Kyrtzidis
9e0cfb811d [AST] Allow the mangler to handle declarations with error types in them.
This is only useful for unique-identification uses of the mangler, like in SourceKit,
which has to deal with invalid code.
Since this is not related to ABI, we can change the encoding anytime we want.

Swift SVN r8557
2013-09-23 16:11:26 +00:00
Chris Lattner
cac7969c33 split dump() into two functions, LLDB doesn't know about default arguments.
Swift SVN r8551
2013-09-22 00:38:00 +00:00
Chris Lattner
361aba5f68 improve QoI for global function closing over global variable. Where before we produced:
err.swift:5:1: error: variable '_x' captured by a closure before being initialized
get : return _x
^
err.swift:2:5: note: variable defined here
var _x : MyInt

We now produce:

t.swift:5:1: error: variable '_x' used by function definition before being initialized
get : return _x
^
t.swift:2:5: note: variable defined here
var _x : MyInt
    ^

This resolves rdar://15017114


Swift SVN r8550
2013-09-22 00:22:27 +00:00
Joe Groff
c4b4db732f Parse and check raw values on enum cases.
Iff an enum declares a raw type, its cases may declare raw values or else have them assigned to them implicitly by autoincrementing from zero, like in C. If the raw type is float-, string-, or char-literal-convertible, there is no autoincrement, and the raw values must all be explicit. The raw type is rejected if any cases have payloads.

We don't yet diagnose duplicate raw values. That'll come next. We also don't yet serialize or deserialize the raw values. We don't strictly need to do this, since the RawRepresentable protocol conformance will be exported from the module as API, but Jordan pointed out that, for fragile raw values, this would be good for documents/jump-to-definition purposes, so we have a plan for only serializing the literals without having to deal with fully general expression serialization.

Swift SVN r8545
2013-09-21 04:31:26 +00:00
Dmitri Hrybenko
738d65f01e Make generic parameter list printing an implementation detail of TypePrinter
Swift SVN r8540
2013-09-21 02:49:10 +00:00
Dmitri Hrybenko
1f601d8ebd AST: rename bitfield data structures to have a common naming pattern
Swift SVN r8539
2013-09-21 01:21:02 +00:00
John McCall
3ef23d6268 [weak] variables have Optional type.
This contains one significant difference from the design:
previously, you declared:
  var [weak] x : NSObject
and the type of 'x' was implicitly Optional.  This change
in the formal type proved problematic in a number of ways,
and Joe made the excellent suggestion to eliminate it:
so now you have to declare:
  var [weak] x : NSObject?
and [weak] is just a kind of modifier on the storage of the
optional value.  You could argue that this is somewhat
pedantic, but I think it restores a lot of consistency to
the model.

Swift SVN r8538
2013-09-21 00:26:17 +00:00
John McCall
22a3574654 Use copy_value and destroy_value when destroying loadable
aggregates in SIL-gen.  Leave the old expanded paths around
as emitLoweredCopyValue and emitLoweredDestroyValue.

Swift SVN r8535
2013-09-20 23:33:40 +00:00
Dmitri Hrybenko
df26716233 Refactor type printing to use TypeVisitor
Swift SVN r8533
2013-09-20 23:32:57 +00:00
Joe Groff
7d35db8a73 Type-check raw type of enum decls.
Allow the inheritance clauses of enums to reference a non-protocol type as their raw type. For now, only diagnose that the raw type occurs first, that there's only one raw type, that there are no circularities in raw types, like we do for class inheritance, and additionally that the raw type is literal convertible, which we'll require for the raw values of the cases.

Swift SVN r8529
2013-09-20 23:13:07 +00:00
Argyrios Kyrtzidis
eecb56a9ad Move the Mangler from the SIL library to the AST one.
No other functionality change.

Swift SVN r8527
2013-09-20 23:10:58 +00:00
Dmitri Hrybenko
12dbffab22 Remove a useless variadic template from TypeVisitor
Swift SVN r8525
2013-09-20 23:00:19 +00:00
Anna Zaks
5b71c8dcc5 [SIL] Propagate basic block arguments.
Propagate/remove basic block input values when all predecessors supply
the same arguments. Another optimization needed to fold 'true'.

TODO: I need to figure out additional surcumstances in which to to trigger this
optimization and if we need to rerun CCP after this. (For example, we need to
rerun this after constant folding the terminator in order to fold 'true'.)

Swift SVN r8518
2013-09-20 21:53:28 +00:00
Joe Groff
f9480828e0 Remove EnumCaseDecl backreference from EnumElementDecl.
Swift SVN r8516
2013-09-20 20:50:24 +00:00
Joe Groff
5d8a7ff9e7 Allow multiple comma-separated enum elements in a 'case' decl.
Introduce an EnumCaseDecl for source fidelity to track the 'case' location and ordering of EnumElementDecls. Parse a comma-separated list of EnumElementDecls after a 'case' token.

Swift SVN r8509
2013-09-20 19:51:13 +00:00
Adrian Prantl
9f84b92aa4 Mangler: Implement hierarchical lookup of generic parameters for the case
where we don't find an ArcheType in the local context.
Fixes rdar://problem/15033772

Swift SVN r8507
2013-09-20 19:00:29 +00:00
Doug Gregor
62e84f59e4 s/constructor/initializer in diagnostics
Swift SVN r8506
2013-09-20 18:59:22 +00:00
Doug Gregor
e52687f6ee Use "initial value" rather than "initializer" in diagnostics.
Swift SVN r8505
2013-09-20 18:45:15 +00:00
Dmitri Hrybenko
429633b18a Let the type checker create implicit DestructorDecls
Improve the type checker to create implicit DestructorDecls, tighten the
assertion in ImplicitReturnLocation::getImplicitReturnLoc(), and add a verifier
check that a class in a type checked AST always has exactly one destructor.

SILGen used to generate a destructor if the class does not have a
DestructorDecl.  SILGen used to put the ClassDecl inside the SILLocation for
the destructor SIL code.  This is not a very clean solution: in this case
ImplicitReturnLocation SILLocations contain ClassDecl, which is surprising.

rdar://14970972 Implicit destructors should have AST nodes


Swift SVN r8498
2013-09-20 17:34:22 +00:00
Doug Gregor
40cf8d1bbc Remove ASTMutationListener::addedExternalType(). It's useless now.
Swift SVN r8491
2013-09-20 15:15:19 +00:00
Joe Groff
e109124186 Replace 'union' keyword with 'enum'.
This only touches the compiler and tests. Doc updates to follow.

Swift SVN r8478
2013-09-20 01:33:14 +00:00
Anna Zaks
1065caa2f4 [SIL] Store the BitWidth in the SwitchInstInst instead of computing it
getBitWidthForCase() is called from the destructor of the object and it
used to rely on Operand being around. However, dropAllReferences(), which
is run before instruction destruction makes the operand invalid at the
time of instruction death. (This results in a crash if we were to delete a
SwitchInstInt instruction.)

Swift SVN r8472
2013-09-19 23:41:03 +00:00
Joe Groff
c8e9a9d6c9 Stale comment.
Swift SVN r8469
2013-09-19 23:16:46 +00:00
John McCall
7954960797 Add 'copy_value' and 'destroy_value' operations to destroy
entire aggregates at once.

This has three worth effects:
  - It significantly decreases the amount of SIL required
    for these operations.
  - It makes it far easier for IR-gen to choose efficient
    patterns of destruction, e.g. calling a single entrypoint
    or recognizing that it can just use the runtime 'release'
    entrypoints.
  - It makes it easier to recognize and optimize aggregate
    copy/destroy operations.
It does make SROA-like tasks a bit more challenging.  The
intent is to give TypeLowering a way to expand these into
their primitive behavior.

Swift SVN r8465
2013-09-19 22:14:55 +00:00
Greg Parker
1a07770bbc Remove x86-specific code that was unused on x86.
Swift SVN r8446
2013-09-19 10:58:32 +00:00
Dmitri Hrybenko
0aaceb3878 Parser: improve error recovery in case of a bad function signature with selector-style arguments
We used to skip until the end of the file in two of these cases.
Looks like plain skipUntil() is never the correct tool for recovery.


Swift SVN r8441
2013-09-19 02:24:59 +00:00
John McCall
c915139f77 Convenience accessor for drilling into Optional<T> to T.
Swift SVN r8437
2013-09-19 00:54:52 +00:00
Anna Zaks
0f2f25dfc8 Disallow [transparent] on any declarations within a class
(Not only on static methods.)

Thanks for catching this Jordan (in review of r8405).

Swift SVN r8436
2013-09-19 00:53:15 +00:00
Greg Clayton
53e32527b6 Added a swift::Type::PrintOptions class to allow printing the module when
dumping type names. This allows you to get a fully qualified type name for any
swift::Type or swift::TypeBase, including any contained types like function
parameter types, bound generic types, etc.



Swift SVN r8426
2013-09-18 22:58:15 +00:00
Manman Ren
b78939e748 SIL Serialization: handle partial_apply.
Add command line argument -sil-link-all and -sil-serialize-all for testing
purpose.

Do not create new SILFunction for de-serialized SIL, instead update the
existing declaration with the de-serialized SILFunction.

Add testing case to cover partial_apply.


Swift SVN r8410
2013-09-18 18:51:04 +00:00
Anna Zaks
621be68642 Disallow [transparent] attribute on class methods and inside protocols
Swift SVN r8407
2013-09-18 17:30:54 +00:00
Anna Zaks
ba3298e6b8 Add support for [transparent] attribute on property getters and setters
Addresses radar://14738227

Swift SVN r8405
2013-09-18 17:30:52 +00:00
Anna Zaks
1fe64057b1 Reword error messages as a follow up to r8221.
Thanks to Dmitry and Jordan for catching the inconsistency.

Swift SVN r8404
2013-09-18 17:30:52 +00:00