Commit Graph

911 Commits

Author SHA1 Message Date
Jordan Rose
c22711a261 [AST] static_assert that Decls, Stmts, and Exprs don't need cleanup (#19667)
These types are all allocated on the ASTContext's BumpPtrAllocator,
and by default their destructors are never called. (ModuleDecl is the
exception; it registers its destructor with the ASTContext on
construction.)

No functionality change.
2018-10-02 10:42:42 -07:00
Joe Groff
93b5de61e7 Implement the final approved syntax for SE-227 identity key paths.
`\.self` is the final chosen syntax. Implement support for this syntax, and remove the stopgap builtin and `WritableKeyPath._identity` property that were in place before.
2018-09-19 11:45:13 -07:00
Mark Lacey
352e4a2de4 [ConstraintSystem] Infer empty closures as returning () more eagerly.
We previously allowed these closures to default to (), but be inferred
as other types as well, which means that we will find some expressions
to be ambiguous because we end up finding multiple viable solutions
where there is really only one reasonable solution.

Fixes: rdar://problem/42337247
2018-09-12 13:30:35 -07:00
Graydon Hoare
ffa1bf1979 [Stats] Expand and improve traceable-entity vocabulary. 2018-09-01 00:05:58 -07:00
John McCall
a30d91e3cb Implement vararg expansion well enough to support argument forwarding.
I needed this for materializeForSet remission, but it makes inherited
variadic initializers work, too.

I tried to make this a reasonable starting point for a real language
feature.  Here's what's still missing:

- syntax
- semantic restrictions to ensure that the expression isn't written in
  invalid places or arbitrarily converted
- SILGen support for expansions that aren't the only variadic argument

rdar://16331406
2018-08-22 06:46:08 -04:00
Slava Pestov
381483bd74 AST: Remove Expr's LValueAccessKind 2018-07-05 23:54:13 -07:00
Ben Cohen
2b04e9f105 Suppress a number of warnings in no-assert builds (#17721)
* Supress a number of warnings about things used only in asserts

* Re-use a couple of variables instead of supressing the warning
2018-07-04 07:15:14 -07: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
Brent Royal-Gordon
6323a5131c Extract helper for making integer literals
Several different places in the codebase synthesize IntegerLiteralExprs from computed unsigned variables; each one requires several lines of code and does things slightly differently. Write one central helper method to handle this.
2018-06-16 12:31:46 -07:00
Slava Pestov
69701b1b90 AST: Fix "statically derived metatype" check
A static reference to DynamicSelfType can only be written as an
implicit member expression where the contextual type is a
DynamicSelfType, ie, 'return .init(...)' in a static method
returning Self.

In this case, the base expression is not a statically-derived
metatype.
2018-05-29 22:51:25 -07:00
David Zarzycki
da20780485 Merge pull request #16695 from davezarzycki/nfc_move_isSelfExpr
[AST] NFC: Make 'isSelfExpr()' available for general use
2018-05-24 14:47:26 -04:00
swift-ci
81ce77d510 Merge pull request #16644 from ravikandhadai/LargeIntOverflowPR 2018-05-21 20:37:47 -07:00
Ravi Kandhadai
f1ff8a61a5 [Sema] Add Sema checks for detecting large integer literals that
overflow Builtin.Int2048 and add tests for checking the
correctness of the diagnostics.
2018-05-21 18:41:44 -07:00
David Zarzycki
6d52f434af [AST] NFC: Create abstract class for MemberRefExpr/SubscriptExpr
This consolidation includes two examples of where this useful. There are
probably more.
2018-05-19 12:33:35 -04:00
David Zarzycki
43a457b0a6 [AST] NFC: Make 'isSelfExpr()' available for general use
Also, generalize the stripping of implicit conversions.
2018-05-19 09:23:31 -04:00
Mark Lacey
a61a6d536e Conditionalize warnings for IUO-to-Any coercion on Swift version.
These warnings are turning out to be pretty noisy for code that
declares IUOs (e.g. for @IBOutlets) and then passes them to
Objective-C APIs with parameters declared as _Nonnull id.

Since we bridge non-nil values successfully in most cases, and
previuosly written and correctly executing code is either not seeing
nil values passed in or are handling the nil (which is bridged as
NSNull), it seems like a nuisance to warn about these for existing
Swift versions.

We'll conditionalize the warning, and then users can deal with these
when moving to the new language version.

Fixes: rdar://problem/39886178
2018-05-07 15:49:56 -07:00
Huon Wilson
b6d44f31da [AST] std::function -> llvm::function_ref for some non-escaping params. 2018-05-01 08:29:06 +10:00
Slava Pestov
f64aa9876c AST: Ban type variable types from being stored into Exprs 2018-04-27 22:51:16 -07:00
Hamish
92931b7434 Merge remote-tracking branch 'upstream/master' into warn-weak-insta-dealloc 2018-04-02 18:06:45 +01:00
Hamish
8f2790633f [Sema] Fix implementation of getValueProvidingExpr()
We should trying to find the value providing expr(s) from the semantic providing expr.
2018-03-07 19:52:05 +00:00
Sho Ikeda
26d650292f [gardening] Use empty() over size() == 0 2018-03-05 14:43:13 +09:00
Graydon Hoare
76b82accbc [Stats] Simplify FrontendStatsTracer uses and formatter-definitions. 2018-02-21 14:49:24 -08:00
Graydon Hoare
9334779f33 [Stats] Reduce layering violations in FrontendStatsTracer. 2018-01-30 01:54:07 -08:00
Argyrios Kyrtzidis
f7e897ec4a [AST] Make sure that if a TupleExpr is created with element names but not name locations, it is marked implicit as appropriate
Fixes a crash for SourceEntityWalker which assumed that a non-implicit TupleExpr has source locations for its name elements.

Fixes SR-6517, rdar://35830880
2018-01-11 12:57:03 -08:00
Mark Lacey
b6430d0644 IUO: Add ImplicitlyUnwrappedFunctionConversionExpr.
This expression node is only used when applying the results of
expression type checking. It initially appears above the function
reference that returns an optional that needs to be unwrapped, and
then when dealing with function application we remove this and insert
a node to force-unwrap the result of the function application.
2018-01-04 11:40:45 -08:00
David Zarzycki
9c33f05f97 [AST] NFC: Migrate GenericIdentTypeRepr to llvm::TrailingObjects 2017-12-30 10:12:26 -05:00
David Zarzycki
62795501d9 [AST] NFC: De-boilerplate "has ParenType sugar" 2017-12-29 11:37:20 -05:00
David Zarzycki
1040d18227 [AST] NFC: Tail allocate TupleShuffleExpr data 2017-12-21 08:52:13 -05:00
David Zarzycki
362d801472 [AST] NFC: Tail allocate CaptureListExpr entries 2017-12-20 09:35:15 -05:00
David Zarzycki
5a4e96fcc2 [AST] NFC: Tail allocate UnresolvedSpecializeExpr TypeLocs 2017-12-20 09:35:15 -05:00
David Zarzycki
dbb421ba95 [AST] NFC: Tail allocate ErasureExpr conformances 2017-12-20 09:35:15 -05:00
David Zarzycki
60d2f5586e [AST] QoI: Track DictionaryExpr commas and tail allocate CollectionExpr comma locs 2017-12-19 13:33:09 -05:00
David Zarzycki
c75912215e [AST] NFC: Tail allocate CollectionExpr elements 2017-12-19 13:33:09 -05:00
David Zarzycki
00542951d2 [AST] NFC: Repack misc TupleExpr bits 2017-12-19 13:33:09 -05:00
David Zarzycki
54ea315586 [Basic] NFC: Stop using transparent unions 2017-12-16 10:43:49 -05:00
Joe Groff
a67f9ca3e5 Sema: Require indexes in key path subscript components to be Hashable.
And save the conformance to be captured when we form the KeyPath object.
2017-09-15 09:59:51 -07:00
David Zarzycki
d4dbce452a Merge pull request #11837 2017-09-11 08:53:38 -04:00
John McCall
2d3d6addc0 Delay the validaton of storage accessors until finalization.
The base mutability of storage is part of the signature, so be sure
to compute that during validation.  Also, serialize it as part of
the storage declaration, and fix some places that synthesize
declarations to set it correctly.
2017-09-10 04:56:02 -04:00
David Zarzycki
14870179bd [AST] NFC: Consolidate shared code into DynamicLookupExpr 2017-09-09 12:44:44 -04:00
Robert Widmann
2823a6960f Properly interpolate negative AP literals
Integer and Floating literals are aware of their negation but
do not store the sign in the text of the value.  Retrieve the
sign bit and properly interpolate the text of the literal value
with it to distinguish negative and positive literals.
2017-08-01 09:48:53 -07:00
Robert Widmann
8cdddef2f8 Refactor Params to use flags
Also, begin to pass around base types instead of raw InOutType types.  Ideally, only Sema needs to deal with them, but this means that a bunch of callers need to unwrap any inouts that might still be lying around before forming these types.

Multiple parts of the compiler were slicing, dicing, or just dropping these flags.  Because I intend to use them for the new function type representation, I need them to be preserved all across the compiler.  As a first pass, this stubs in what will eventually be structural rules as asserts and tracks down all callers of consequence to conform to the new invariants.

This is temporary.
2017-07-19 09:49:32 -07:00
Slava Pestov
737174fe9f AST: Add a DeclContext field to ComponentIdentTypeRepr
Plumb this through and set it appropriately, but don't use it
for anything yet.
2017-07-18 22:10:33 -07:00
Joe Groff
963c58c4b5 Push subscript label allocation for KeyPathComponents into the root constructor.
A preemptive strike against memory management bugs in the future.
2017-07-11 10:25:56 -07:00
Joe Groff
6ad01d63f6 Sema: Feed argument label and constraint locator info from key path subscript components into getCalleeDeclAndArgs.
Fixes SR-5189 | rdar://problem/32713662.
2017-07-10 14:55:08 -07:00
Robert Widmann
abd5aa8e6d Rename some X-Value-related entities
* Rename coerceToMaterializableValue to coerceToRValue

* Rename isLValueType to hasLValueType to better match the
intended semantics of the member.
2017-06-14 13:18:45 -07:00
John McCall
b542c75cb1 Use abstract implicit-conversion expressions for bridging cases instead of
expanding the conversion calls in Sema.
2017-06-11 01:39:51 -04:00
Mark Lacey
d1a0b35447 [Constraint solver] More type map changes.
A few more changes to use the side map for expression types in the
constraint solver. Still not enabled.
2017-06-02 08:13:57 -07:00
Mark Lacey
fb5ac6df02 [Constraint solver] Fix an issue with rewriting OpenExistentialExpr.
If we fail when doing a coercion while generating an OpenExistentialExpr
when applying a solution during type checking, make sure that the opaque
value on that OpenExistentialExpr is cleared.

We do not visit these during normal AST walks because they normally
appear in the subexpression held by the OpenExistentialExpr. In this
case, however, we replace that subexpression with an ErrorExpr which
means we will not visit the opaque value at all, so certain operations,
like setting the type on the opaque value, will never happen, and we can
run into problems later by code that assumes the type is set.

It seems reasonable to just clear these out in cases like this since
they are not reachable by any normal means.
2017-06-01 20:18:29 -07:00
Pavel Yaskevich
c94fe94d5d [Diagnostics] Add a fix-it for optional to raw representable type conversion
Situations where there is a contextual RawRepresentable type is
used incorrectly would produce `<Type>(rawValue: )` fix-it only
in cases where neither or both sides of the expression are optional.
Let's fix that by adding a fix-it for optional to contextual raw
value type conversion.

Resolves: rdar://problem/32431736
2017-05-31 13:58:17 -07:00
Slava Pestov
1b254a9843 Sema: Kill off old modeling of generic arguments 2017-05-24 20:39:10 -07:00