Commit Graph

60 Commits

Author SHA1 Message Date
Ben Langmuir
34da079aa6 Pass DynamicLookupInfo through VisibleDeclConsumers NFC
This commit adds a new type DynamicLookupInfo that provides information
about how a dynamic member lookup found a particular Decl. This is
needed to correctly handle KeyPath dynamic member lookups, but for now
just plumb it through everywhere.
2019-05-06 10:02:39 -07:00
Joe Groff
71912bbfd6 AST: Represent OpaqueTypeDecls.
To represent the abstracted interface of an opaque type, we need a generic signature that refines
the outer context generic signature with an additional generic parameter representing the underlying
type and its exposed constraints. Opaque types also need to be keyed by their originating decl, so
that we can treat values of the same opaque type as the same. When we check a FuncDecl with an
opaque type specified as its return type, create an OpaqueTypeDecl and associate it with the
originating decl. (A representation for *types* derived from the opaque decl will come next.)
2019-04-17 14:43:32 -07:00
Graydon Hoare
fa95f7aebd [ModuleInterface] Factor out common AST-layer withOutputFile helper. 2018-10-18 00:31:24 -07:00
Owen Voorhees
a676ab6d4c [Frontend]: Write out .swiftdeps files atomically
Modify ReferenceDependenciesEmitter::emit to write to a temporary file and then atomically rename it in place using the atomicallyWritingToFile helper function.
This resolves SR-8707, where .swiftdeps files could be truncated if the compiler job was killed in the middle of a write.
2018-10-05 19:13:40 -07:00
Slava Pestov
391eae3714 FrontendTool: Remove hasAccess() checks 2018-09-05 16:51:42 -07:00
Jordan Rose
e224e31720 Break almost all dependencies of Driver on Frontend
- Sink OutputFileMap{.h,.cpp} and ReferenceDependencyKeys.h to Basic
- Remove unnecessary includes of Frontend.h.
2018-08-27 20:47:58 -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
Slava Pestov
45fb11ce3c AST: Add ExistentialLayout::getSuperclass(), rename superclass to explicitSuperclass
More groundwork for protocols with superclass constraints.
In several places we need to distinguish between existential
types that have a superclass term (MyClass & Proto) and
existential types containing a protocol with a superclass
constraint.

This is similar to how I can write 'AnyObject & Proto', or
write 'Proto1 & Proto2' where Proto1 has an ': AnyObject'
in its inheritance clause.

Note that some of the usages will be revisited later as
I do more refactoring and testing. This is just a first pass.
2018-07-02 22:06:33 -07:00
David Ungar
8c2f733152 Address review comments. 2018-06-15 14:29:30 -07:00
David Ungar
43cad63742 clang-format 2018-06-15 11:18:16 -07:00
David Ungar
f626396f6d Doxygenation. 2018-06-15 11:15:22 -07:00
David Ungar
37289f9bb3 Rename CollectedProvidedDeclarations to CollectedDeclarations 2018-06-15 11:15:22 -07:00
David Ungar
42576ab0d4 Constify argument to findNominalsAndOperators 2018-06-15 11:15:22 -07:00
David Ungar
a9d7ef18e1 Centralize string constants. 2018-06-15 11:15:22 -07:00
David Ungar
35fab64bac Move outputing provides-top-level. 2018-06-15 11:15:22 -07:00
David Ungar
50c725e0bc Preparing ReferenceDependencies for centralizing strings. 2018-06-15 11:15:22 -07:00
David Ungar
4c4e25f3d2 Added consts where helpful and deleted where not. 2018-06-15 11:15:22 -07:00
David Ungar
617b506dd4 const WIP 2018-06-15 11:15:22 -07:00
David Ungar
41f75ab324 Move helpers into the classes that use them. 2018-06-15 11:15:22 -07:00
David Ungar
44af96dc6d Reorder functions to group members together. 2018-06-15 11:15:22 -07:00
David Ungar
cac9a9a907 Move class declarations to top of file, put CollectedProvidedDeclarations inside of ProvidesEmitter. 2018-06-15 11:15:22 -07:00
David Ungar
1f7c920854 Rename TableEntryTy per Jordan's advice. 2018-06-15 11:15:22 -07:00
David Ungar
11aa1f15bc Shorted names of member fns of DependsEmitter. 2018-06-15 11:12:25 -07:00
David Ungar
d0affb24ad Wrap depends emitters in a class. 2018-06-15 11:12:25 -07:00
David Ungar
16a1299f90 Move provides emitters into a class 2018-06-15 11:12:25 -07:00
David Ungar
5477b3987a Aggregate the provided declatations into CollectedProvidedDeclarations. 2018-06-15 11:12:25 -07:00
David Ungar
c8130663d5 Move top-level emitting into a class, ReferenceDependenciesEmitter. 2018-06-15 11:12:25 -07:00
David Ungar
ebf8713c08 Break up emitReferenceDependencies to separate the file opening from emitting to a stream. 2018-06-15 11:12:25 -07:00
David Ungar
70005c10e5 Factor out file openning & error handling. 2018-06-15 11:12:25 -07:00
David Ungar
fe8ac4b2b2 Per Jordan, use raw_ostream instead of raw_fd_ostream. 2018-06-15 11:12:25 -07:00
David Ungar
44e5cd3bba clang-format 2018-06-15 11:12:25 -07:00
David Ungar
abe7544c1a Subdivide emitting a provides decl. 2018-06-15 11:12:25 -07:00
David Ungar
d53122f03a clang-format 2018-06-15 11:12:25 -07:00
David Ungar
c4172183f0 Subdivide one more level down. 2018-06-15 11:12:25 -07:00
David Ungar
45c562b8e5 Split up emitReferenceDependencies into 3 steps: provides, depends, interfaceHash. 2018-06-15 11:12:25 -07:00
Slava Pestov
181d7a2eac FrontendTool: Deterministic order when a normal declname has same spelling as special declname 2018-06-14 20:41:27 -07:00
David Ungar
4866df6dfd Move SupplementaryOutputs into each InputFile. 2018-02-28 09:41:49 -08:00
David Ungar
488db9fb9b Fix ReferencedNameTracker in preparation for batch mode. 2018-02-16 22:28:10 -07:00
David Ungar
ba4f2a84b4 Move supplementary outputs to SupplementaryOutputs in FrontendInputsAndOutputs. 2018-02-07 13:55:32 -08:00
Harlan
5e02d2a877 Implement #warning and #error (#14048)
* Implement #warning and #error

* Fix #warning/#error in switch statements

* Fix AST printing for #warning/#error

* Add to test case

* Add extra handling to ParseDeclPoundDiagnostic

* fix dumping

* Consume the right paren even in the failure case

* Diagnose extra tokens on the same line after a diagnostic directive
2018-02-03 18:07:05 -05:00
David Ungar
4a0a7f2e82 Fix for emit_reference_dependencies_without_primary_file warning required after changes to introduce multiple primary files to CompilerInstance.
Revealed by test Frontend/dependencies.swift.
2018-01-17 11:58:11 -08:00
John McCall
7f0f8830cd Split AccessorDecl out from FuncDecl. NFC.
This has three principal advantages:

- It gives some additional type-safety when working
  with known accessors.

- It makes it significantly easier to test whether a declaration
  is an accessor and encourages the use of a common idiom.

- It saves a small amount of memory in both FuncDecl and its
  serialized form.
2018-01-12 14:20:27 -05: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
Alex Hoppen
949968a182 Adjust printing to take into account special DeclNames
Print DeclBaseNames using a new userFacingStr() method to prepare for
DeclBaseNames that are not backed by Identifiers
2017-06-24 11:39:09 +02:00
contraultra
c40efd4154 [SR-4978] Fix compiler crash for malformed ASTs 2017-06-12 12:40:13 -07:00
Jordan Rose
325a96983e [AST] Preparations for removal of getName on ValueDecl (#9969)
With the introduction of special decl names, `Identifier getName()` on
`ValueDecl` will be removed and pushed down to nominal declarations
whose name is guaranteed not to be special. Prepare for this by calling
to `DeclBaseName getBaseName()` instead where appropriate.
2017-05-28 19:04:19 -07:00
Alex Hoppen
f302afc97f Unify approach to printing declaration names (#9320)
Printing a declaration's name using `<<` and `getBaseName()` is be
independent of the return type of `getBaseName()` which will change in
the future from `Identifier` to `DeclBaseName`
2017-05-28 17:25:20 -07:00
Jordan Rose
4cdb597b23 Rename VTablePlaceholderDecl to MissingMemberDecl.
As such, we no longer insert two placeholders for initializers that
need two vtable slots; instead we record that in the
MissingMemberDecl. I can see MissingMemberDecl growing to be something
we'd actually show to users, that can be used for other kinds of
declarations that don't have vtable entries, but for now I'm not going
to worry about any of that.
2017-05-10 11:55:55 -06:00
Jordan Rose
82930033d2 Add VTablePlaceholderDecl (but don't hook it up to anything yet). 2017-05-10 11:55:54 -06:00