Commit Graph

1827 Commits

Author SHA1 Message Date
Dmitri Hrybenko
c2c15e401b Disallow use of module values
rdar://15000289


Swift SVN r10546
2013-11-18 20:45:50 +00:00
Dmitri Hrybenko
81dc5deee8 Change 'def' keyword back to 'func'
Swift SVN r10522
2013-11-17 07:45:28 +00:00
Anna Zaks
f4e6b746f5 Better handling of overflow diagnostics when user types are not available.
Currently, we use heuristics to determine if the conversion errors come from directly inlining the std integer types. However, if those operations are wrapped in another transparent function, we will not see the user-visible integer types anymore, so we fall back to Builtin types. Enhance the diagnostics in that case to specify if the sign-agnostic Builtin types are signed or unsigned.

This reverts r10484 and adds test cases.

Swift SVN r10512
2013-11-16 01:26:53 +00:00
Joe Groff
ab65140a2e Add a 'Builtin.once' builtin.
This lowers to a call to a to-be-written swift_once runtime function and will be used for lazy global initialization. Having this be a builtin seemed appropriate to me given that:

- references to it will be implicitly emitted by SILGen for global initializers.
- there are restrictions on its correct use that are currently impossible to express in the language outside of the stdlib.

Swift SVN r10508
2013-11-16 00:50:12 +00:00
Anna Zaks
f651e342c1 Add static checking for signed <-> unsigned int conversions (for same size ints).
Swift SVN r10477
2013-11-15 00:16:18 +00:00
Anna Zaks
0f390c9c54 Add dynamic checking for sign errors(overflows) during signed <-> unsigned conversions for integers of the same type.
Add unsafe alternatives to allow unsafe conversions:
 - asUnsigned()
 - asSigned()

Swift SVN r10476
2013-11-15 00:16:18 +00:00
Adrian Prantl
2edcd17029 [Mangler] Fix a bug in the new Qq mangling that would insert the
innermost DeclContext of the decl that uses the archetype instead of the
actual generic context of the archetype.

<rdar://problem/15453889> Qualified archetypes mangle wrong DeclCtx

Swift SVN r10470
2013-11-14 22:38:32 +00:00
Joe Groff
19457c12ea Give Builtin.Word an abstract size.
Instead of hardcoding Builtin.Word to be an alias for Builtin.Int64, make it its own type of abstract pointer width.

- Change BuiltinIntegerType's width representation to accommodate abstract widths.

- In the AST and in SIL, store values of the types as the greatest supported size for the abstract width (64 bits for a pointer).

- Add some type safety to the ([sz]ext|trunc)(OrBitCast)? builtins that they're used appropriately given the upper and lower bounds of the abstract sizes they're working with.

- Now that Builtin.Word is a distinct type, give it its own mangling.

- In IRGen, lower pointer-sized BuiltinIntegerType appropriately for the target, and truncate lowered SIL values if necessary.

Fixes <rdar://problem/15367913>.

Swift SVN r10467
2013-11-14 19:56:26 +00:00
Dmitri Hrybenko
d5047c96f5 Reject duplicate definitions of enum elements during the first pass of type checking
Swift SVN r10450
2013-11-14 02:54:03 +00:00
Anna Zaks
34f5e43b09 [CCP] Diagnose truncation errors in int to int conversions.
Here we add compile time checks similar to the ones performed at runtime.

Swift SVN r10446
2013-11-14 01:35:22 +00:00
Anna Zaks
b687c3ce9c Add runtime integer truncation checking to the conversion constructors
Add new builtins(by generalizing, renaming, and extending the builtins used for compile time integer literal checking). These new builtins truncate integers and check for overflow/truncation errors at runtime. Use these for FixedPoint conversion constructors.

Fix a routine in stdlib's String implementation and a test that relied on bitwise behavior of the constructors (and triggered overflows).

TODO:
- Teach CCP about these to get static checking.
- Add special builtins for same size signed <-> unsigned conversions.

Swift SVN r10432
2013-11-13 21:54:34 +00:00
Dmitri Hrybenko
c1ce33afec @objc diagnostics: reject @objc methods with tuple-style declarations
Swift SVN r10429
2013-11-13 20:17:43 +00:00
Dmitri Hrybenko
0f8d6fed28 @objc diagnostics: also mention that subscript declarations can be @objc
Swift SVN r10387
2013-11-12 23:50:32 +00:00
Dmitri Hrybenko
ffab09afbf @objc diagnostics: update diagnostic message to provide more information
Swift SVN r10385
2013-11-12 23:34:20 +00:00
Joe Groff
b06afcbf55 Ensure 'isStatic' bit of PatternBindingDecls is always initialized.
And that it gets serialized.

Swift SVN r10382
2013-11-12 23:12:16 +00:00
Joe Groff
b64d601bba Sema: Don't try to initialize static properties in implicit constructors.
The implicit default constructor shouldn't try to initialize static properties, and the implicit memberwise constructor shouldn't have arguments for static properties.

Swift SVN r10378
2013-11-12 22:10:15 +00:00
Joe Groff
f26a5fa4b3 AST: Static vars aren't stored properties of instances.
Don't include static vars in the 'getStoredProperties' range.

Swift SVN r10373
2013-11-12 17:29:17 +00:00
Joe Groff
4f2adbe7ed AST: Include 'static' bit in VarDecls.
And track the 'static' SourceLoc in the PatternBindingDecl. This lets isInstanceMember return the right thing for static vars.

Swift SVN r10369
2013-11-12 06:16:48 +00:00
Dmitri Hrybenko
bd0f7783cb @objc diagnostics: add a special case diagnostic for generic type parameter
Swift SVN r10353
2013-11-12 00:54:19 +00:00
Dmitri Hrybenko
ba8ff3e67a @objc diagnostics: start producing diagnostics about functions that can not be marked @objc
Swift SVN r10351
2013-11-12 00:18:15 +00:00
Joe Groff
ea698da596 Parser: Admit 'static' properties in nongeneric struct or enum decls.
These properties are truly static and can be implemented just as global variables, and this is all we need in the short term to give a good interface to NS_OPTIONS-like Cocoa enumerations.

Swift SVN r10349
2013-11-11 23:57:27 +00:00
Adrian Prantl
da0cb5a10a [Mangler] Introduce a 'Qq' mangling format for archetypes that will be
used only for debug info and within the _Tt namespace.
The DWARF output created by swift is intentionally flat, therefore
archetypes need to be emitted with their DeclContext. While increasing the
length of the mangled names in some cases (substitutions help a lot) it
has the advantage of making names completely self-contained.
There is a lengthy thread on swift-debugger discussing this change.

Swift SVN r10348
2013-11-11 23:44:31 +00:00
Dmitri Hrybenko
de2064a83f @objc diagnostics: highlight source range of the variable type
Introduced VarDecl::getTypeSourceRangeForDiagnostics(), which is not precise
right now; it just highlights the type source range of the typed pattern.
Filed rdar://15441111 to improve it in future.


Swift SVN r10344
2013-11-11 22:07:56 +00:00
Anna Zaks
d1700b9f78 Use standard wording in the warning.
Swift SVN r10342
2013-11-11 21:20:05 +00:00
John McCall
0f97e9307c Extract out a function to print a SourceLoc for pretty stack traces.
Swift SVN r10339
2013-11-11 19:52:32 +00:00
Dmitri Hrybenko
b16378f5ed @objc diagnostics: specialize diagnostic text for structs and enums
Swift SVN r10336
2013-11-11 19:13:03 +00:00
Dmitri Hrybenko
c2a4b0a412 Remove unused diagnostics
Swift SVN r10334
2013-11-11 18:54:55 +00:00
Dmitri Hrybenko
21d1b2f4b8 @objc: produce diagnostics if a variable is explicitly marked @objc but can not
be represented in Objective-C


Swift SVN r10073
2013-11-09 05:30:03 +00:00
John McCall
abebe416c3 Allow substitution to walk into reference storage types.
For now, don't allow transforms to work on SILFunctionTypes.

Swift SVN r10066
2013-11-09 01:41:12 +00:00
John McCall
555b57ca00 The constant types on ASTContexts are all canonical.
Swift SVN r10065
2013-11-09 01:41:11 +00:00
Anna Zaks
d3495ec5d4 Use ASCII quotes in the diagnostic message.
Swift SVN r10001
2013-11-06 20:02:23 +00:00
Anna Zaks
f8a79a56fb Address the reviews for r9982
Swift SVN r9999
2013-11-06 19:46:20 +00:00
Greg Parker
49e1856c13 Add Builtin.[trunc|zext|sext]OrBitCast() instead of hijacking the true casts.
Swift SVN r9985
2013-11-06 03:15:04 +00:00
Anna Zaks
c8ed1954f2 Issue a warning when returned expression is on the next line after the return keyword.
We still want to allow line wrapping, so only issue the warning when the indentation of the expression and the return keyword is the same.

radar://11945406

Swift SVN r9984
2013-11-06 02:00:13 +00:00
John McCall
dfd3c165a0 Switch resolveType over to a visitor.
Incidentally make a few syntactic checks proceed by looking
at the TypeRepr instead of the Type.

Swift SVN r9982
2013-11-06 01:56:39 +00:00
Dmitri Hrybenko
61c067fe5f Implement a check in Sema to find self-assignment
rdar://14151649 suggests that it should be a warning, but I don’t see a reason
why it should not be an error.  We have no legacy code that relies on this.


Swift SVN r9976
2013-11-05 23:43:54 +00:00
Doug Gregor
d79b1758c1 Add getter/setter type computations to VarDecl and SubscriptDecl.
Use the getter type computation for dynamic subscript references so
that we can handle optional subscripts in protocols properly.


Swift SVN r9975
2013-11-05 23:31:13 +00:00
Doug Gregor
84a4c08f1d Factor the computation of the 'self' type into an easier-to-use place.
Swift SVN r9973
2013-11-05 22:51:17 +00:00
Anna Zaks
54524e622a Replace ExprStmtOrDecl with ASTNode and make it a struct.
Previously, the Parser and BranchStmt typedef-ed ExprStmtOrDecl as a pointer union. Using typedef made the objects compatible, but did not allow us to extend the type with helper methods, such as getSourceRange(), which is something you can get on all of the AST objects. This patch introduces ASTNode that subclasses from PointerUnion and is used by both parser and BranchStmt.

Swift SVN r9971
2013-11-05 21:46:59 +00:00
Doug Gregor
6145fc3fa9 Restrict @optional to members of an @objc protocol.
Optional protocol methods are almost trivially implementable for
Objective-C protocols, so start with this over-zealous restriction. We
intend to lift this restriction later.


Swift SVN r9961
2013-11-05 16:13:38 +00:00
Doug Gregor
e5ca2c90d0 Parse @optional attribute on protocol members.
Swift SVN r9959
2013-11-05 15:58:19 +00:00
Dmitri Hrybenko
2e53423e33 ASTContext: add "the one true way" to get the stdlib module
Swift SVN r9952
2013-11-05 01:40:24 +00:00
Anna Zaks
16774496fd [SILGen] Emit warnings when SILGen fails to emit unreachable code.
Previously, we just did not emit SIL for unreachable code from these examples.

Swift SVN r9949
2013-11-05 01:17:14 +00:00
Anna Zaks
a48d832bb2 Improve error message
Swift SVN r9948
2013-11-05 01:17:13 +00:00
Jordan Rose
b43dd09107 All SourceFiles should always remember their buffer IDs, not just imports.
Swift SVN r9946
2013-11-04 23:50:48 +00:00
Doug Gregor
f7e285d9b3 Revert r9937; getInnermostDeclContext() doesn't do what we need
Swift SVN r9942
2013-11-04 23:44:27 +00:00
Doug Gregor
25b604fe82 getInnermostDeclContext() is already better than getPotentialGenericDeclContext().
Swift SVN r9939
2013-11-04 23:17:43 +00:00
Doug Gregor
ce104ed48b Introduce ValueDecl::getPotentialGenericDeclContext()
This little "find the context where the generic parameters could be"
idiom was copy-pasted in a few places, which is ugly. And if we get
generic subscripts (or some other generic value decl), we'll be sorry.


Swift SVN r9927
2013-11-04 18:21:16 +00:00
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Dmitri Hrybenko
91ce21666d Change 'func' keyword to 'def'
I tried hard find all references to 'func' in documentation, comments and
diagnostics, but I am sure that I missed a few.  If you find something, please
let me know.

rdar://15346654


Swift SVN r9886
2013-11-02 01:00:42 +00:00