Commit Graph

1242 Commits

Author SHA1 Message Date
Slava Pestov
7432bd70a2 ClangImporter: Compute signature conformances upfront in finishNormalConformance()
We will need them even if the protocol is not @objc.
2017-09-12 16:23:16 -07:00
Slava Pestov
526b42658b ClangImporter: Use existing protocol ordering in finishNormalConformance() 2017-09-12 16:23:11 -07:00
Slava Pestov
c7aa831363 AST: Push conformance state change down into implementations of finishNormalConformance() 2017-09-12 16:22:35 -07:00
Slava Pestov
f6d9693de9 AST: Store a LazyConformanceLoader inside the SynthesizedProtocolAttr 2017-09-11 22:34:43 -07:00
Slava Pestov
defb9cd5b6 AST: Add ASTContext::Id_ArrayLiteralElement 2017-09-11 21:48:01 -07:00
Jordan Rose
ff31714b69 [ClangImporter] ImportedName doesn't need to know its version.
Preparation for making ImportNameVersion a generalized struct rather
than an enum. We could have kept cramming it into a bitfield, sure,
but we don't actually need this.

No intended functionality change.
2017-09-11 18:06:35 -07: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
Slava Pestov
9f8760b942 AST: Remove unused 'resolver' parameter from ModuleDecl::lookupConformance()
... as well as a bunch of downstream plumbing that is no
longer necessary.
2017-09-07 03:36:17 -07:00
Slava Pestov
405b641246 ClangImporter: Synthesize typealiases instead of relying on associated type inference
Right now the ClangImporter relies on Sema to synthesize typealiases
in some cases, which doesn't work if a Sema instance is not available,
for example when the ClangImporter is asked to import a declaration
while deserializing SIL during optimization.

Begin addressing this by synthesizing typealiases for the following
conformances:

- ExpressibleByArrayLiteral.ArrayLiteralElement while importing
  OptionSets.

- RawRepresentable.RawValue while importing raw-valued enums.

- ObjectiveCBridgeable._ObjectiveCType while importing bridged
  newtypes.

Until further changes land, this is mostly NFC, except for a change
in generated interface printing where the new typealiases are now
explicitly shown.

Note that non-bridged newtypes whose raw type is ObjectiveCBridgeable
still rely on associated type inference, because the ClangImporter
cannot safely "copy" the _ObjectiveCType typealias from the raw type
to the newtype, for various reasons mostly having to do with
circularity. Subsequent patches will address this, in a rather novel
fashion that will shock you.
2017-09-07 00:30:44 -07:00
Slava Pestov
d575324e4c ClangImporter: 'ASTContext' should be abbreviated as 'ctx' not 'cxt' 2017-09-07 00:24:12 -07:00
Ben Langmuir
b083020759 Revert "Normalize version tuples in availability attributes coming from clang to use "."" 2017-09-05 14:03:31 -07:00
Ben Langmuir
f1c48daf70 Normalize version tuples in availability attributes coming from clang to use "."
Seen as @available attributes being printed with "_" in interface
generation, but fixing it in the importer means they can't leak into
anywhere else.

rdar://problem/30451293
2017-09-01 16:24:21 -07:00
Jacopo Andrea Giola
a598277ad3 Fix SR-5614, add check if importType succeds (#11698)
SwiftDeclConverter::importSwiftNewtype now check if the
storedUnderlyingType is null and return a nullptr
2017-09-01 13:41:48 -07:00
Slava Pestov
4a08fc6cc3 ClangImporter: Fix an unused variable warning 2017-09-01 02:04:22 -07:00
Jordan Rose
f8b7db4e76 Excise the terms "blacklist" and "whitelist" from Swift source. (#11687)
The etymology of these terms isn't about race, but "black" = "blocked"
and "white" = "allowed" isn't really a good look these days. In most
cases we weren't using these terms particularly precisely anyway, so
the rephrasing is actually an improvement.
2017-08-30 09:28:00 -07:00
Jordan Rose
1c651973c3 Excise "Accessibility" from the compiler (2/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the 'Accessibility' enum to be named 'AccessLevel'.
2017-08-28 11:34:44 -07:00
Jordan Rose
5f30eac288 Excise "Accessibility" from the compiler (1/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the names of methods, fields, a few local
variables, and even a swift-ide-test flag. The full list is below.

accessibilityForDiagnostics -> accessLevelForDiagnostics
checkAccessibility -> checkAccess
checkGenericParamAccessibility -> checkGenericParamAccess
checkTypeAccessibility -> checkTypeAccess
checkWitnessAccessibility -> checkWitnessAccessibility
computeAccessibility -> computeAccessLevel
computeDefaultAccessibility -> computeDefaultAccessLevel
fixItAccessibility -> fixItAccess
getAccessibilityString -> getAccessLevelString
getAccessibilityStrictly -> getAccessLevelStrictly
getAccessibilityUID -> getAccessLevelUID
getActualAccessibility -> getActualAccessLevel
getDefaultAccessibility -> getDefaultAccessLevel
getMaxAccessibility -> getMaxAccessLevel
getOverridableAccessibility -> getOverridableAccessLevel
getRawStableAccessibility -> getRawStableAccessLevel
getSetterAccessibility -> getSetterFormalAccess
hasAccessibility -> hasAccess
hasDefaultAccessibility -> hasDefaultAccessLevel
inferAccessibility -> inferAccessLevel
inferDefaultAccessibility -> inferDefaultAccessLevel
inferSetterAccessibility -> inferSetterAccessLevel
overwriteAccessibility -> overwriteAccess
overwriteSetterAccessibility -> overwriteSetterAccess
printAccessibility -> printAccess
requiredAccessibilityForDiagnostics -> requiredAccessForDiagnostics
resolveAccessibility -> resolveAccessControl
setAccessibility -> setAccess
setSetterAccessibility -> setSetterAccess
setDefaultAndMaxAccessibility -> setDefaultAndMaxAccess
validateAccessibility -> validateAccessControl

Accessibility -> AccessLevel
AccessibilityFilter -> AccessFilter
IgnoreAccessibility -> IgnoreAccessControl
NL_IgnoreAccessibility -> NL_IgnoreAccessControl
PrintAccessibility -> PrintAccess
PrintInternalAccessibilityKeyword -> PrintInternalAccessKeyword
SetterAccessibility -> SetterAccessLevel

setterAccessibility -> setterAccess
storedPropertyAccessibility -> storedPropertyAccess

-print-accessibility -> -print-access
2017-08-28 11:11:57 -07:00
David Ungar
57bb55f0bf Merge pull request #11530 from davidungar/compilation_time_ClangImporter_loadAllMembers
Carve up ClangImporter::Implementation::loadAllMembers for readability.
2017-08-24 22:02:30 -07:00
Slava Pestov
b7737df5a5 ClangImporter: The _rawValue field of imported swift_newtype structs should be private
Hopefully this doesn't affect source compatibility for anyone;
it should never have been public in the first place.

Fixes <rdar://problem/34036290>.
2017-08-24 21:22:57 -07:00
David Ungar
5c8828b486 git-clang-format my changes 2017-08-24 20:09:19 -07:00
David Ungar
ac51eea5f2 condence traceName parameter to trace() 2017-08-24 20:09:19 -07:00
David Ungar
37867ba15e combine if...returns 2017-08-24 20:09:19 -07:00
David Ungar
b72dde8927 use separate variable for result
& remove redundant comment
2017-08-24 20:09:18 -07:00
David Ungar
2bf519a39a move findMemberThatWillLandInAnExtensionContext to avoid forward declaration 2017-08-24 20:09:18 -07:00
David Ungar
1be30281da separate findMemberThatWillLandInExtensionContext 2017-08-24 20:09:18 -07:00
David Ungar
e7ccad358c reindent 2017-08-24 20:09:18 -07:00
David Ungar
27aaa549ad separate out addMemberAndAlternatesToExtension 2017-08-24 20:09:18 -07:00
David Ungar
bd6a9c0432 factor out loadAllMembersIntoExtension 2017-08-24 20:09:17 -07:00
David Ungar
7d06a9af71 reindent the rest 2017-08-24 20:09:17 -07:00
David Ungar
9bc7afc652 reindent as much as diff will handle 2017-08-24 20:09:17 -07:00
David Ungar
d25b59a045 flip order of test in loadAllMembers 2017-08-24 20:09:17 -07:00
David Ungar
672e46c9ad factor out loadMembersOfBaseImportedFromClang 2017-08-24 20:09:17 -07:00
David Ungar
6a4005ca69 factor out figureOutTheDeclarationContextToImportInto 2017-08-24 20:09:16 -07:00
David Ungar
cdfd3c561f demorgan for-loop condition 2017-08-24 20:09:16 -07:00
David Ungar
f8b524342d factor out for-loop body into insertMembersAndAlternates 2017-08-24 20:09:16 -07:00
David Ungar
0f57a83229 factor out collectMembersToAdd 2017-08-24 20:09:16 -07:00
David Ungar
a2e7ea1237 separate out loadAllMembersOfObjcContainer 2017-08-24 20:09:16 -07:00
Robert Widmann
76a4935d16 Staging for __consuming
Pushes __consuming through the frontend and extends existing
attribute-based diagnsotics to cover it.  Unlike `nonmutating`,
__consuming is allowed in class methods, though it makes little
sense to put it there.
2017-08-23 12:19:00 -07:00
Slava Pestov
bf2ca1ab94 Sema/AST: Don't crash when stdlib declarations are missing
I don't have reduced test cases. The original test cases
were a series of frontend invocations in -parse-stdlib
mode.

While the original bugs seem to have been fixed, while
verifying I found a few places where we weren't checking
for null decls property in the ASTContext.

Probably not too useful to check this in, but I don't see it
causing any harm, either.
2017-08-06 00:43:23 -07:00
swift-ci
ac4efebac6 Merge remote-tracking branch 'origin/master' into master-next 2017-07-25 22:28:55 -07:00
Doug Gregor
e82e7d5fbd [Clang importer] Map swift_objc_members attribute found on superclasses.
Fixes rdar://problem/33514802.
2017-07-25 16:18:31 -07:00
swift-ci
d9f0e3cedb Merge remote-tracking branch 'origin/master' into master-next 2017-07-19 13:28:52 -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
swift-ci
54f218676d Merge remote-tracking branch 'origin/master' into master-next 2017-07-13 15:48:48 -07:00
Jordan Rose
663c4f9524 [ClangImporter] Don't import compatibility methods named 'print'. (#10928)
...because they make things harder for people trying to use
Swift.print. Before:

  error: 'print' has been renamed to 'printDocument(_:)'

After:

  error: use of 'print' nearly matches global function
    'print(_:separator:terminator:)' in module 'Swift'
    rather than instance method 'print(_:extra:)'

(This actually occurs with AppKit's NSDocument, so it's not just a
hypothetical concern.)

rdar://problem/32839733
2017-07-13 15:44:39 -07:00
swift-ci
e0782d0448 Merge remote-tracking branch 'origin/master' into master-next 2017-07-11 13:29:16 -07:00
swift-ci
e98182387b Merge remote-tracking branch 'origin/master' into master-next 2017-07-11 12:23:35 -07:00
Alex Hoppen
f8c2692f79 Introduce special decl names
Special DeclNames represent names that do not have an identifier in the
surface language. This implies serializing the information about whether
a name is special together with its identifier (if it is not special)
in both the module file and the swift lookup table.
2017-07-11 19:04:13 +02:00
Jordan Rose
85019e8d3d [ClangImporter] Structs lexically in an ObjC class are still top-level. (#10874)
Not every declaration that's syntactically in an Objective-C container
is a member of that container. Double-check the decl context before
adding it.

This is technically a breaking change in non-asserts builds, because
the struct really could be found via member lookup. But that should
be considered a bug, and I /suspect/ no one is relying on it.

rdar://problem/32451417
2017-07-11 08:25:19 -07:00
John McCall
0e89efa1c8 Bridge types during import only if we are in a fully-bridgeable context.
Somehow the logic had slipped so that we were basing this decision purely
on the ImportTypeKind and not on whether the broader context is bridgeable.
This was allowing us to use bridged types when e.g. importing the results
and parameters of C function pointer types, which is really bad.

Also, when importing a reference to a typedef of block type, do not use
the typedef in a non-bridgeable context.  We import typedefs of block type
as fully-bridged types, but this means that it is invalid to import a type
using the typedef in a context where the original C type must be used.
Similarly, make sure we use a properly-imported underlying type of the
typedef when the typedef itself is unavailable.

Also, extend the special behavior of block typedefs to abstract-function
typedefs, which seems to be consistent with the expected behavior of the
tests.

Finally, I changed importType to take a new Bridgeability enum instead of
a raw canFullyBridgeTypes bool.  At the time, I was doing that because I
was going to make it tri-valued; that turned out to be unnecessary, but I
think it's an improvement anyway.
2017-07-09 13:53:19 -04:00