Commit Graph

2550 Commits

Author SHA1 Message Date
Slava Pestov
9df82e18cf ClangImporter: Don't create redundant inheritance clause entries
If an imported type conforms to a protocol with a synthesized
conformance, we only add a SynthesizedProtocolAttr, without
adding an entry to the inheritance clause. Otherwise the
ConformanceLookupTable records an explicit conformance and the
LazyConformanceLoader is lost.
2017-09-14 01:14:24 -07:00
Slava Pestov
f166adaad4 ClangImporter: Compute requirement signature in finishNormalConformance() 2017-09-13 23:12:11 -07:00
Slava Pestov
20d834cc07 ClangImporter: Fix conformsToProtocolInOriginalModule() to walk SynthesizedProtocolAttrs 2017-09-13 23:12:11 -07:00
Slava Pestov
c624ff50ee ClangImporter: Fix finishTypeWitnesses() to work with protocol typealiases 2017-09-13 23:11:26 -07:00
Slava Pestov
1023b1c0ad ClangImporter: Fix finishSignatureConformances() to support associated types 2017-09-13 23:11:26 -07:00
Slava Pestov
ae5d6fd3b7 ClangImporter: Clean up inheritance clause synthesis
There was some duplicate code for adding protocols to inheritance
clauses and constructing the SynthesizedProtocolAttrs that indicate
a conformance should have a LazyConformanceLoader.

Clean this up to make it less error-prone.

NFC for now, until further changes land.
2017-09-12 22:40:21 -07:00
Slava Pestov
e26949d3fd ClangImporter: Find type witnesses in finishNormalConformance() 2017-09-12 22:31:25 -07:00
Slava Pestov
6d3ea57310 ClangImporter: Split up finishNormalConformance() 2017-09-12 16:36:54 -07:00
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