Commit Graph

1899 Commits

Author SHA1 Message Date
Hamish Knight
91a792b393 Merge branch 'master' into id-like-to-request-a-table 2019-10-07 22:05:30 -07:00
Slava Pestov
52cf3659b5 Sema: Simplify validateDecl()
Remove the early return in the case where one of our parent contexts was
being validated, and replace it with a simpler check that is only
performed in some callers related to associated type inference; we want
to bail out in one specific case only, which is that the declaration
is inside an extension whose generic signature is in the process of
being computed.
2019-10-07 22:20:18 -04:00
Slava Pestov
1d809801e1 AST: Add ValueDecl::isRecursiveValidation()
This will be used as a transitional aid in refactoring getInterfaceType()
to always return a valid type, instead of silently returning Type() when
there is circularity.
2019-10-07 22:20:18 -04:00
Slava Pestov
6bfe518344 AST: Compute FuncDecl::isStatic() using a request 2019-10-07 22:20:18 -04:00
Slava Pestov
e334e5d66f AST: Convert ValueDecl::getOpaqueResultTypeDecl() into a request
Instead of depending on a prior call to setOpaqueResultTypeDecl(),
we can instead just build the decl if we need one.
2019-10-04 22:11:07 -04:00
Hamish Knight
3f66608cb5 Check for stubs in NeedsNewVTableEntryRequest
This lets us remove `setNeedsNewVTableEntry`.
2019-10-03 19:13:39 -07:00
Hamish Knight
c1a1ddd458 Requestify needsNewVTableEntry
This commit introduces `NeedsNewVTableEntryRequest`,
which checks whether a class method needs a new
vtable entry.
2019-10-03 19:13:39 -07:00
Hamish Knight
934d4d1d87 Requestify whether a decl is an ABI compatible override
This commit adds `IsABICompatibleOverrideRequest`,
which checks if the decl is an override, and if
so whether it's ABI compatible with the base
This is then usedto replace the logic for
computing  `isValidKeyPathComponent` in addition
to being used in `requiresNewVTableEntry`.
2019-10-02 21:06:22 -07:00
Robert Widmann
2fe3ce8af8 Requestify the Raw Value Accessor
Make getRawValueExpr() return a checked value.

This entails a strange kind of request that effectively acts like
a cache warmer.  In order to properly check the raw value expression for
a single case, we actually need all the other cases for the
autoincrementing synthesis logic.  The strategy is therefore to have the
request act at the level of the parent EnumDecl and check all the values
at once.  We also cache at the level of the EnumDecl so the cache
"warms" for all enum elements simultaneously.

The request also abuses TypeResolutionStage to act as an indicator for
how much information to compute.  In the minimal case, we will return
a complete accounting of (auto-incremented) raw values.  In the maximal
case we will also check and record types and emit diagnostics.  The
minimal case is uncached to support repeated evaluation.

Note that computing the interface type of an @objc enum decl *must*
force this request.  The enum's raw values are part of the ABI, and we
should not get all the way to IRGen before discovering that we cannot
possibly lay out the enum.  In the future, we might want to consider
moving this check earlier or have IRGen tolerate broken cases but for
now we will maintain the status quo and not have IRGen emit
diagnostics.
2019-10-02 16:09:25 -07:00
Mishal Shah
2f86d67500 Merge pull request #27396 from shahmishal/master-rebranch
Update master to support apple/stable/20190619 branch for LLVM projects
2019-10-01 10:50:49 -07:00
Robert Widmann
75670c1727 Merge pull request #27436 from CodaFi/signed-sealed-delivered
[NFC] Adopt TypeBase-isms for GenericSignature
2019-09-30 15:50:42 -07:00
Robert Widmann
5a8d0744c3 [NFC] Adopt TypeBase-isms for GenericSignature
Structurally prevent a number of common anti-patterns involving generic
signatures by separating the interface into GenericSignature and the
implementation into GenericSignatureBase.  In particular, this allows
the comparison operators to be deleted which forces callers to
canonicalize the signature or ask to compare pointers explicitly.
2019-09-30 14:04:36 -07:00
swift-ci
26a8bf8e75 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-30 08:43:50 -07:00
David Ungar
ea81fdc7d8 Merge pull request #27313 from davidungar/generic-request-or-extended-nominal-assertion
Fail early if getExtendedNominal is called before extension has been bound.
2019-09-30 08:37:33 -07:00
David Ungar
4bc4030338 Catch failures earlier caused by premature requests for extended nominal 2019-09-28 15:19:32 -07:00
swift-ci
67e0f740c1 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-27 11:23:52 -07:00
Xi Ge
4069172a40 AST: refactor getLoc() of decls to have a single entry point for all decl kinds, NFC
After we start to serialize the result of getLoc() in the
.swiftsourceinfo file, getLoc() needs a single entry point to look up via
USRs in the serialized format.
2019-09-26 17:47:44 -07:00
swift-ci
349d6b073e Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-26 12:44:18 -07:00
Harlan Haskins
b904133c42 [Modules] Add flag to skip non-inlinable function bodies
This flag, currently staged in as `-experimental-skip-non-inlinable-function-bodies`, will cause the typechecker to skip typechecking bodies of functions that will not be serialized in the resulting `.swiftmodule`. This patch also includes a SIL verifier that ensures that we don’t accidentally include a body that we should have skipped.

There is still some work left to make sure the emitted .swiftmodule is exactly the same as what’s emitted without the flag, which is what’s causing the benchmark noise above. I’ll be committing follow-up patches to address those, but for now I’m going to land the implementation behind a flag.
2019-09-26 10:40:11 -07:00
swift-ci
170a84c5bd Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-25 18:44:16 -07:00
Robert Widmann
dd7d925610 Merge pull request #27364 from CodaFi/raw-smackdown
Clean up enum raw expression validation a bit
2019-09-25 18:43:20 -07:00
swift-ci
cb97094e71 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-25 13:44:21 -07:00
Robert Widmann
0df6b40710 Clean up enum raw expression validation a bit
The distinction between the type checked raw value expression and the regular raw value expression was never important.  Downstream clients were ignoring the type checked form and pulling the text out of the supposed "plain" form.  Drop the distinction and simply don't set back into the raw value expr if we don't have to.

Pushing this through naturally enables some cleanup in checkEnumRawValues.  Factor out type checking the literal value into an helper on the typechecker and pull a common diagnostic into the decl checker.
2019-09-25 11:14:47 -07:00
Robert Widmann
5964ce47b0 Use OperatorPrecedenceGroupRequest to clean up InfixOperatorDecl a bit 2019-09-24 17:45:50 -07:00
swift-ci
6afcaba05d Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-21 08:12:26 -07:00
swift-ci
656afb783d Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-20 22:23:33 -07:00
Robert Widmann
b135928125 Drop CheckingWithValidSignature from the validation state machine
Now that the generic signature is computable on demand, this predicate is doubly useless.  All of the callers intended to ask "hasInterfaceType" anyways.
2019-09-20 22:22:49 -07:00
Robert Widmann
e7fccde40c Directly detect the cyclic case while computing conditional requirement
The general class of cycle here is when validation asks for the generic signature which triggers requirement checking which forces us to ask for the generic signature of the extension again.  We should look into a more principled solution.

See rdar://55263708
2019-09-20 20:38:38 -07:00
swift-ci
463b04648e Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-18 15:03:46 -07:00
Robert Widmann
38bde33067 Merge pull request #27172 from CodaFi/aliasing-artifacts-and-noise-reduction-techniques
Kill validateDeclForNameLookup Harder
2019-09-18 15:00:51 -07:00
Slava Pestov
67c668200a Sema: Compute and store captures for default argument expressions 2019-09-18 14:26:01 -04:00
Robert Widmann
5e34169aca Separate computing interface types and underlying types
Computing the interface type of a typealias used to push validation forward and recompute the interface type on the fly.  This was fragile and inconsistent with the way interface types are computed in the rest of the decls.  Separate these two notions, and plumb through explicit interface type computations with the same "computeType" idiom.  This will better allow us to identify the places where we have to force an interface type computation.

Also remove access to the underlying type loc.  It's now just a cache location the underlying type request will use.  Push a type repr accessor to the places that need it, and push the underlying type accessor for everywhere else.  Getting the structural type is still preferred for pre-validated computations.

This required the resetting of a number of places where we were - in many cases tacitly - asking the question "does the interface type exist".  This enables the removal of validateDeclForNameLookup
2019-09-17 08:20:55 -07:00
Robert Widmann
2ab5ea8926 Define UnderlyingTypeRequest
Define a request for computing the interface type of the underlying type of a typealias.  This can be used in place of the declared interface type of the alias itself when it is nested to preserve the fragile validation ordering issues that can cause.
2019-09-17 08:19:55 -07:00
swift-ci
5ea6845952 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-16 17:43:52 -07:00
Robert Widmann
d097c8186d Requestify generic signatures
Define a request that provides the generic signature for a given generic context.  This unblocks a ton of cleanup and will allow us to remove validateExtension, validateDeclForNameLookup, and a lot of the surrounding infrastructure.

Being more honest about which declarations actually have a generic signature computed has naturally introduced more cycles in requests.  hasComputedGenericSignature() now acts as a recursion breaker.  In the future, we should purge any uses of this accessor that specifically head-off cycles as the cycle itself is probably part of a larger structural problem.
2019-09-16 11:41:53 -07:00
swift-ci
927fc3f39e Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-06 20:03:38 -07:00
Robert Widmann
edf2e3ba77 Merge pull request #27048 from CodaFi/chicken-param
Define GenericParamListRequest
2019-09-06 19:55:16 -07:00
swift-ci
f9a3c37ed6 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-06 19:03:47 -07:00
swift-ci
5b3fdba240 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-06 17:23:34 -07:00
Robert Widmann
d4bb9a5cfe Define GenericParamListRequest
GenericParamListRequest formalizes the lazy generic parameter list construction pattern we were performing before.
2019-09-06 17:22:30 -07:00
Slava Pestov
a0e160e215 AST: Refactor Decl::isWeakImported() API a little bit
First, remove the AvailabilityContext parameter; it was confusing because
we actually always want to use the deployment target here.

Then, split this method up into three methods:

- isAlwaysWeakImported(): simply checks for a @_weakLinked attribute, either
  on the declaration itself or one of its parent contexts.

- getAvailabilityForLinkage(): returns the OS version availability when
  this declaration was introduced, or if the declaration does not have
  explicit availability, check it's storage (if its an accessor), or its
  parent contexts.

- isWeakImported(ModuleDecl *fromModule): combines these two checks to
  determine if the declaration should be weak linked when referenced from
  the given module, or if it might be weak referenced from some module
  (if the module parameter is null).
2019-09-06 20:08:40 -04:00
Slava Pestov
f292c1b240 AST: Remove GenericContext::setGenericEnvironment()
This was a transitional step before converting all callers to
store a generic signature instead of an environment.
2019-09-06 17:16:04 -04:00
Slava Pestov
0405ab5ffc AST: GenericContexts store a GenericSignature instead of a GenericEnvironment
This eliminates the entire 'lazy generic environment' concept;
essentially, all generic environments are now lazy, and since
each signature has exactly one environment, their construction
no longer needs to be co-ordinated with deserialization.
2019-09-06 17:16:04 -04:00
swift-ci
95aa6e69f7 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-04 17:23:49 -07:00
Robert Widmann
07bcf5a579 Merge pull request #26995 from CodaFi/a-sign-from-on-high
Requestify Inferring Generic Requirements
2019-09-04 17:19:09 -07:00
swift-ci
eb52f0c448 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-04 15:23:47 -07:00
Slava Pestov
3ddfcae24b Merge pull request #27003 from slavapestov/remove-ignore-new-extensions
Remove IgnoreNewExtensions and related cleanups
2019-09-04 18:20:04 -04:00
swift-ci
f302c5a8e3 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-04 13:43:47 -07:00
David Ungar
f50961293f Fix typo in comment 2019-09-04 08:36:33 -07:00
Slava Pestov
a09382ce2b AST: Completely remove NominalTypeDecl::LookupDirectFlags::IgnoreNewExtensions 2019-09-03 22:53:52 -04:00