Commit Graph

1905 Commits

Author SHA1 Message Date
Graydon Hoare
14db5d2285 [AST] Add and use NominalTypeDecl::LookupDirectFlags rather than booleans. 2018-09-21 14:34:26 -07:00
swift-ci
317eb61e6f Merge remote-tracking branch 'origin/master' into master-next 2018-09-20 14:29:50 -07:00
Slava Pestov
ea1ec895a8 AST: Extended types of extensions should be interface types 2018-09-20 01:20:31 -07:00
swift-ci
d5b96980be Merge remote-tracking branch 'origin/master' into master-next 2018-09-14 09:09:31 -07:00
Saleem Abdulrasool
d281b98220 litter the tree with llvm_unreachable
This silences the instances of the warning from Visual Studio about not all
codepaths returning a value.  This makes the output more readable and less
likely to lose useful warnings.  NFC.
2018-09-13 15:26:14 -07:00
swift-ci
4d14ecb4ed Merge remote-tracking branch 'origin/master' into master-next 2018-09-10 20:49:46 -07:00
Doug Gregor
ac37747c78 [Type checker] Break isObjC/getObjCSelector cycle.
When we're marking a declaration as @objc and recording it in the
class and source-file lookup tables (for @objc collision detection),
don't cause a cycle by querying `getObjCSelector()`. This is somewhat
of a hack: a better long-term approach would be to move the recording
much later, and request'ify the name computation. That'll be follow-up
work.
2018-09-10 17:30:17 -07:00
Bob Wilson
72c7eeb2fe Merge remote-tracking branch 'origin/master' into master-next 2018-09-10 13:22:19 -07:00
Harlan
eb75ad80dc [AST] Remove stored TypeLoc from TypedPattern (#19175)
* [AST] Remove stored TypeLoc from TypedPattern

TypedPattern was only using this TypeLoc as a means to a TypeRepr, which
caused it to store the pattern type twice (through the superclass and through
the TypeLoc itself.)

This also fixes a bug where deserializing a TypedPattern doesn't store
the type correctly and generally cleans up TypedPattern initialization.

Resolves rdar://44144435

* Address review comments
2018-09-07 21:14:04 -07:00
swift-ci
5613b214c1 Merge remote-tracking branch 'origin/master' into master-next 2018-08-28 18:29:52 -07:00
John McCall
b3120907d5 Merge pull request #15691 from rjmccall/max-alignment-16
Cap the alignment of all types in Swift at 16
2018-08-28 21:14:23 -04:00
John McCall
c1f99b5fdb Cap type alignment in Swift at 16.
rdar://31411216
2018-08-28 16:13:50 -04:00
swift-ci
aff5f82538 Merge remote-tracking branch 'origin/master' into master-next 2018-08-28 10:10:12 -07:00
Ben Cohen
6567438027 Squash release build warnings (#18986) 2018-08-28 09:56:17 -07:00
swift-ci
8303f90b44 Merge remote-tracking branch 'origin/master' into master-next 2018-08-27 23:49:09 -07:00
Slava Pestov
d9bd0d96cf ClangImporter: Refactor usage of SubscriptDecl::getIndicesInterfaceType() 2018-08-27 21:15:38 -07:00
Bob Wilson
2b6617e596 [master-next] Use the new AST getBeginLoc API instead of getLocStart
The getLocStart API is deprecated and slated for removal from LLVM
very soon. Switch to use getBeginLoc instead. I did not see any uses
of the corresponding getLocEnd API.
2018-08-27 12:42:47 -07:00
Slava Pestov
c360c82850 AST: Automatically create the 'self' parameter when needed
Parsed declarations would create an untyped 'self' parameter;
synthesized, imported and deserialized declarations would get a
typed one.

In reality the type, if any, depends completely on the properties
of the function in question, so we can just lazily create the
'self' parameter when needed.

If the function already has a type, we give it a type right there;
otherwise, we check if a 'self' was already created when we
compute a function's type and set the type of 'self' then.
2018-08-25 10:44:55 -07:00
Jordan Rose
21b6cdd301 [ClangImporter] A method can't interfere with an existing property (#18749)
That is, if we encounter a property declaration, and a no-argument
method is visible, it's only a problem if there's not already a
property there. (Arguably this means that it's either not a problem at
all, or that we shouldn't be mirroring protocol methods onto classes
if there's a conflicting property, but this change doesn't attempt to
answer that.)

https://bugs.swift.org/browse/SR-8490
2018-08-20 08:37:29 -07:00
Slava Pestov
527ff375dc AST: Rename old form of {Generic,}FunctionType::get() to getOld()
This makes it easier to grep for and eventually remove the
remaining usages.

It also allows you to write FunctionType::get({}, ...) to call the
ArrayRef overload empty parameter list, instead of picking the Type
overload and calling it with an empty Type() value.

While I"m at it, in a few places instead of renaming just clean up
usages where it was completely mechanical to do so.
2018-08-17 19:28:17 -04:00
Jordan Rose
537954fb93 [AST] Rename several DeclContext methods to be clearer and shorter (#18798)
- getAsDeclOrDeclExtensionContext -> getAsDecl

This is basically the same as a dyn_cast, so it should use a 'getAs'
name like TypeBase does.

- getAsNominalTypeOrNominalTypeExtensionContext -> getSelfNominalTypeDecl
- getAsClassOrClassExtensionContext -> getSelfClassDecl
- getAsEnumOrEnumExtensionContext -> getSelfEnumDecl
- getAsStructOrStructExtensionContext -> getSelfStructDecl
- getAsProtocolOrProtocolExtensionContext -> getSelfProtocolDecl
- getAsTypeOrTypeExtensionContext -> getSelfTypeDecl (private)

These do /not/ return some form of 'this'; instead, they get the
extended types when 'this' is an extension. They started off life with
'is' names, which makes sense, but changed to this at some point.  The
names I went with match up with getSelfInterfaceType and
getSelfTypeInContext, even though strictly speaking they're closer to
what getDeclaredInterfaceType does. But it didn't seem right to claim
that an extension "declares" the ClassDecl here.

- getAsProtocolExtensionContext -> getExtendedProtocolDecl

Like the above, this didn't return the ExtensionDecl; it returned its
extended type.

This entire commit is a mechanical change: find-and-replace, followed
by manual reformatted but no code changes.
2018-08-17 14:05:24 -07:00
Doug Gregor
0a26e333bb Switch two simple callers over to decl-based lookupQualified. 2018-08-14 02:39:24 -07:00
Slava Pestov
f997ff4f68 ClangImporter: Convert function/method/accessor import to use ParameterList::getParams()
Note that these functions used to return a FunctionType; now, they
return the result type instead:

- importFunctionType()
- importMethodType()
- importAccessorMethodType()

The parameters were already being returned in the form of a ParameterList
of ParamDecls.

This actually has the effect of making the code simpler, because callers
would always take them apart and build new function types anyway.
2018-08-11 03:29:16 -07:00
Slava Pestov
4b258e86e6 AST: Stop setting contextual types on ParamDecls
VarDecl::getType() lazily maps the interface type into context if needed.
2018-08-10 13:33:12 -07:00
Doug Gregor
8f36061f25 Merge pull request #18530 from DougGregor/protocol-decl-based-resolution
[Name lookup] Use decl-based name lookup for protocol-related queries
2018-08-06 20:44:59 -07:00
Doug Gregor
7d3dd4983d [AST] Eliminate two simple uses of (NominalType|Extension)Decl::getInheritedType().
Simple checks for the presence of a protocol in the “inherited” list should only
require a scan through that list + name lookup; use those facilities instead of
recursing through the type checker.
2018-08-06 16:59:40 -07:00
swift-ci
71f0248b0a Merge remote-tracking branch 'origin/master' into master-next 2018-08-06 11:07:55 -07:00
Doug Gregor
bd5f5d80e4 [AST] Add ExtensionDecl::getExtendedNominal().
Introduce ExtensionDecl::getExtendedNominal() to provide the nominal
type declaration that the extension declaration extends. Move most
of the existing callers of the callers to getExtendedType() over to
getExtendedNominal(), because they don’t need the full type information.

ExtensionDecl::getExtendedNominal() is itself not very interesting yet,
because it depends on getExtendedType().
2018-08-03 11:26:48 -07:00
swift-ci
5830e237ff Merge remote-tracking branch 'origin/master' into master-next 2018-07-31 13:29:50 -07:00
Doug Gregor
792d934e3e [Clang importer] Avoid recursion through isObjC more directly.
Also address some review comments related to the name lookup requests.
2018-07-31 10:20:15 -07:00
Doug Gregor
d07fa5ab69 Switch many callers of ClassDecl::getSuperclass() to ClassDecl::getSuperclassDecl().
ClassDecl::getSuperclass() produces a complete interface type describing the
superclass of a class, including any generic arguments (for a generic type).
Most callers only need the referenced ClassDecl, which is (now) cheaper
to compute: switch those callers over to ClassDecl::getSuperclassDecl().

Fixes an existing test for SR-5993.
2018-07-31 10:14:44 -07:00
Doug Gregor
2860557a77 [Name lookup] Use the declaration-based lookupQualified() where it’s easy.
Switch a number of callers of the Type-based lookupQualified() over to
the newer (and preferred) declaration-based lookupQualified(). These are
the easy ones; NFC.
2018-07-31 10:14:44 -07:00
swift-ci
f7b8996498 Merge remote-tracking branch 'origin/master' into master-next 2018-07-30 20:59:23 -07:00
Slava Pestov
294f54399f ClangImporter: Only set overrides on class members
Fixes <rdar://problem/42635132>.
2018-07-30 17:27:37 -07:00
Slava Pestov
90c215cec9 ClangImporter: Set the 'is dynamic' bit explicitly on synthesized declarations 2018-07-30 15:47:34 -07:00
swift-ci
cba2d0bdfd Merge remote-tracking branch 'origin/master' into master-next 2018-07-29 20:48:56 -07:00
Mark Lacey
1c42ee2e07 [ClangImporter] Replace getInput() with getParams(). 2018-07-29 16:25:24 -07:00
swift-ci
d40f3d3ced Merge remote-tracking branch 'origin/master' into master-next 2018-07-23 13:49:26 -07:00
Slava Pestov
7265617a9f ClangImporter: Use AbstractFunctionDecl::computeType() 2018-07-23 02:21:29 -07:00
swift-ci
b4bae42909 Merge remote-tracking branch 'origin/master' into master-next 2018-07-21 13:49:33 -07:00
Slava Pestov
bfc4121971 AST: Rework AbstractFunctionDecl construction away from multiple parameter lists
There are two general constructor forms here:

- One took the number of parameter lists, to be filled in later.
  Now, this takes a boolean indicating if there is an implicit
  'self'.

- The other one took the actual parameter lists and filled them
  in right away. This now takes a separate 'self' ParamDecl and
  ParameterList.

Instead of storing the number of parameter lists, an
AbstractFunctionDecl now only needs to store if there is a 'self'
or not.

I've updated most places that construct AbstractFunctionDecls to
properly use these new forms. In the ClangImporter, there is
more code that remains to be untangled, so we continue to build
multiple ParameterLists and unpack them into a ParamDecl and
ParameterList at the last minute.
2018-07-21 07:30:30 -07:00
swift-ci
403cb35abc Merge remote-tracking branch 'origin/master' into master-next 2018-07-20 00:29:49 -07:00
Slava Pestov
090934f6b6 ClangImporter: Remove uses of AbstractFunctionDecl::getParameterLists() 2018-07-19 21:23:44 -07:00
swift-ci
e2acff2bbc Merge remote-tracking branch 'origin/master' into master-next 2018-07-18 23:08:57 -07:00
Doug Gregor
780f8fea93 [Clang importer] Consistently set “isObjC” bit on imported decls. 2018-07-18 14:52:57 -07:00
Doug Gregor
b70466dc63 [Type Checker] Add a request kind for computing 'ValueDecl::isObjC()'.
Still a WIP
2018-07-18 14:50:39 -07:00
Doug Gregor
8f23915334 [Type Checker] Introduce a request for “overridden declarations”.
Introduce a new request kind to capture the computation of the set of
overridden declarations of a given declaration, eliminating the
stateful “setOverriddenDecls()” calls from the type checker.
2018-07-18 14:50:38 -07:00
Doug Gregor
4073055c7a [Clang importer] Remove some now-unnecessary code.
The use of getAsClassOrClassExtensionContext() obviates the need for a
specific isTypeContext() check. NFC.
2018-07-18 14:50:38 -07:00
swift-ci
a792448233 Merge remote-tracking branch 'origin/master' into master-next 2018-07-17 14:09:53 -07:00
Slava Pestov
8d6a55fedb Merge pull request #16655 from davezarzycki/formalize_DeclIsBeingValidatedRAII
[AST] NFC: Formalize Decl validation tracking via RAII
2018-07-17 14:07:53 -07:00