Commit Graph

1067 Commits

Author SHA1 Message Date
Doug Gregor b57a73ab42 [Concurrency ABI] Add standard substitutions for _Concurrency types.
Introduce a second level of standard substitutions to the mangling,
all of the form `Sc<character>`, and use it to provide standard
substitutions for most of the _Concurrency types.

This is a precursor to rdar://78269642 and a good mangling-size
optimization in its own right.
2021-06-01 17:15:02 -07:00
Hamish Knight ed104a8134 Merge pull request #37014 from hamishknight/entry-sign 2021-05-19 08:32:40 +01:00
Erik Eckstein 762e9c7882 Serialization: serialize if the module is a static library
If the `-static` option is specified, store that in the generated
swiftmodule file.  When de-serializing, recover this information in the
representative SILModule.

This will be used for code generation on Windows.  It is the missing
piece to allow static linking to function properly.  It additionally
opens the path to additional optimization on ELF-ish targets - GOT, PLT
references can be avoided when the linked module is known to be static.

Co-authored by: Saleem Abdulrasool <compnerd@compnerd.org>
2021-05-02 09:34:52 -07:00
Ben Barham 0fc005dd8e Merge pull request #37105 from bnbarham/serialize-offsets
[Serialization] Store offset of decls in .swiftsourceinfo
2021-04-29 16:37:15 +10:00
Ben Barham c763ab5d1e [Serialization] Store offset of decls in .swiftsourceinfo
The locations stored in .swiftsourceinfo included the presumed file,
line, and column. When a location is requested it would read these, open
the external file, create a line map, and find the offset corresponding
to that line/column.

The offset is known during serialization though, so output it as well to
avoid having to read the file and generate the line map.

Since the serialized location is returned from `Decl::getLoc()`, it
should not be the presumed location. Instead, also output the line
directives so that the presumed location can be built as per normal
locations.

Finally, move the cache out of `Decl` and into `ASTContext`, since very
few declarations will actually have their locations deserialized. Make
sure to actually write to that cache so it's used - the old cache was
never written to.
2021-04-29 12:33:05 +10:00
Robert Widmann 43a9f54b0f Repair Fingerprint Lookup Across Modules
Cross-module incremental builds require a stable source of fingerprint
information for iterable decl contexts. This is provided by the
incremental frontends when they produce partial swift module files.
Embedded in these files is a table of fingerprints, which are consumed
by merge-modules to construct a module-wide dependency graph that is
then serialized into the final merged swift module file. Unfortunately,
the implementation here iterated through the files in the module and
asked for the first fingerprint that would load for a particular
iterable decl context. If (more likely, when) the DeclID for that
serialized iterable decl context collided with another DeclID in the
wrong file, we would load that fingerprint instead.

Locate up to the module-scope context for an iterable decl context and
only load the fingerprint from there. This ensures that the fingerprints
in the partial modules matches the fingerprints in the merged modules.

rdar://77005039
2021-04-27 21:39:25 -07:00
Hamish Knight 272090752b [AST] Upgrade MainDecl to a ValueDecl
This will make it easier to store in a SILDeclRef.
2021-04-26 11:42:31 +01:00
Ben Barham 52de30ce1f [Gardening] Do not store start/end line in SingleRawComment
The start and end lines were only used while constructing the comments,
so move the line tracking into that method instead of storing it in each
comment.
2021-04-16 08:10:49 +10:00
Ben Barham c54c9c7079 [Gardening] Extract basic source info structs from RawComment.h 2021-04-14 10:05:27 +10:00
Alexis Laferrière 6bbb9f04da [Sema] Only look for PrivateFrameworks on Darwin 2021-03-26 16:33:09 -07:00
Alexis Laferrière f1f015c7dc [Sema] Use path::append in ModuleLibraryLevelRequest 2021-03-26 16:30:15 -07:00
Alexis Laferrière cf58bb7eb4 [Sema] Report public imports of private modules
Intro the concept of library access or distribution level to identify
layers of libraries and report public imports of private libraries from
public ones.

rdar://62934005
2021-03-26 16:30:15 -07:00
nate-chandler 64c75828f7 Merge pull request #36529 from nate-chandler/rdar75547146
Sema: Stop checking @main if no decl synthesized.
2021-03-23 08:04:40 -07:00
Nate Chandler 6c5d62c011 Sema: Stop checking @main if no decl synthesized.
When requestifying the synthesis of the main function for the type
annotated @main via SynthesizeMainFunctionRequest, what were previously
were bailouts from AttributeChecker::visitMainTypeAttr had to become
returns of nullptr from SynthesizeMainFunctionRequest::evaluate.
Consequently, AttributeChecker::visitMainTypeAttr must check whether
synthesis actually succeeded before proceeding to to register the main
decl for a file.

In simple cases, this happened to work because
SourceFile::registerMainDecl would return early if the decl being
registered was the same as the already registered main decl and in
particular if the decl being registered was nullptr and the previously
registered one was nullptr as well.  When, however, there are multiple
types annotated @main, if a function is successfully synthesized for one
type but synthesis fails for the second, an attempt will be made to
register nullptr as the main decl and will move past the check at the
beginning of SourceFile::registerMainDecl, resulting in a crash.

Here, we bail from AttributeChecker::visitMainTypeAttr if function
synthesis fails and add an assert to SourceFile::registerMainDecl that
the provided decl is non-null.

rdar://75547146
2021-03-19 16:54:16 -07:00
Doug Gregor 9579390024 [SE-0304] Rename ConcurrentValue to Sendable 2021-03-18 22:48:20 -07:00
Doug Gregor 6ed794d188 Bake the _Concurrency -> Swift ABI module name into the compiler.
Using `-module-abi-name` for the `_Concurrency` module breaks older
Swift compilers. Instead, hard-code that "Swift" is the ABI name of the
"_Concurrency" module in the compiler to dodge the problem.
2021-03-12 11:21:46 -08:00
Doug Gregor 71b7c92453 Handle more cycles with ConcurrentValue inference 2021-03-02 12:09:14 -08:00
Doug Gregor b5e4b085aa Infer ConcurrentValue conformances for structs and enums.
When a struct or enum has only ConcurrentValue-conforming instance
data, infer conformance to ConcurrentValue.
2021-03-02 00:23:33 -08:00
David Ungar 90ee114b4a add fingerprint excluding to basic source file info 2021-02-26 17:20:44 -08:00
Rintaro Ishizaki bb45b2a822 [CodeCompletion] Lazily populate 'BasicSourceFileInfo' 2021-02-25 14:56:55 -08:00
David Ungar 6e034cac4e Revert "[NFC; Incremental] Rename BasicSourceFileInfo.InterfaceHash" 2021-02-25 09:06:53 -08:00
David Ungar cbd92e65ff Rename BasicSourceFileInfo.InterfaceHash 2021-02-24 09:13:22 -08:00
Holly Borla 11028350a7 Merge pull request #35589 from Jumhyn/placeholder-types
[AST, Sema] Replace HoleType with PlaceholderType
2021-02-22 08:35:37 -08:00
Doug Gregor 66cd7d82ae Marker protocols are self-conforming. 2021-02-18 23:44:39 -08:00
Frederick Kellison-Linn a5d0153fbf [AST] Assume that placeholder types conform to all protocols 2021-02-16 22:59:19 -05:00
Becca (née Brent) Royal-Gordon e6aee251be Merge pull request #35904 from beccadax/go-back-to-the-shadow
Warn about module name shadowing in interfaces
2021-02-16 15:32:41 -08:00
AG a5b804602d Merge pull request #35110 from bitjammer/acgarland/emit-symbol-graph
Add optional -emit-symbol-graph output when emitting modules
2021-02-12 09:00:58 -08:00
Becca Royal-Gordon c2f3725f56 Warn about module name shadowing in interfaces
There is a known issue with module interfaces where a type with the same name as a module will disrupt references to types in that module. Fully fixing it will require a new language feature (SR-898) which is not yet available. In the meantime, module interfaces support a workaround flag (“-Xfrontend -module-interface-preserve-types-as-written”) which prints an alternate form that usually works. However, you have to know to add this flag, and it’s not obvious because nothing breaks until a compiler tries to consume the affected module interface (or sometimes even one of its clients).

This commit emits a warning during module interface emission whenever the module interface either imports a type with the same name as the module being built, or declares a type with the same name as a visible module. This lets the user know that the type may cause problems and they might need to implement a workaround.
2021-02-10 19:03:06 -08:00
Robert Widmann b960c6e31c Derive a Fingerprint from a Module's BasicSourceFileInfo 2021-02-02 09:57:46 -08:00
Robert Widmann 7c5f8a0e6c [NFC] Const-qualify BasicSourceFileInfo 2021-02-02 09:57:04 -08:00
Ashley Garland 69c4fc47cb Add optional -emit-symbol-graph output when emitting modules
rdar://71497047
2021-01-28 09:55:33 -08:00
Robert Widmann 73ac8d3531 Replace llvm::MD5 with StableHasher 2021-01-21 17:19:38 -08:00
Erik Eckstein e3d636e519 CrossModuleOptimization: fix crash when importing a module as implementationOnly
If a function uses a type imported as implementationOnly (or similar), it cannot be serialized.

I added a new API in ModuleDecl (canBeUsedForCrossModuleOptimization), which performs this check.

rdar://72864719
2021-01-18 13:09:27 +01:00
Ben Barham b6aedc75f8 Merge pull request #35441 from bnbarham/allow-delayed-parsing-with-interface-hash
[Parser] Keep delayed body parsing even with interface hash generation
2021-01-16 13:25:38 +10:00
Ben Barham 4be504673e [Parser] Keep delayed body parsing even with interface hash generation
The generated hash ignores tokens parsed in the body anyway, so there's
no reason to disable delayed body parsing in this case.
2021-01-15 10:17:12 +10:00
Rintaro Ishizaki a9a044c6e3 [Serialization] Serialize fingerprint, mtime, size of the source files 2021-01-13 11:49:52 -08:00
Rintaro Ishizaki 09121f7780 [AST] Move getInterfaceHashIncludingTypeMembers() to SourceFile 2021-01-13 11:49:52 -08:00
Rintaro Ishizaki 1b6e7857c2 [Serialization] Serialize/deserialize source file list 2021-01-13 11:49:52 -08:00
Slava Pestov d1a2a612b1 AST: Change some writeDependencySink() methods to take the result by const reference 2020-12-22 01:42:04 -05:00
Arnold Schwaighofer 2b6ba2830c Serialize decls with _specialize(exported:true, target: somefunc(_:), ...) in a list for fast lookup
rdar://71430641
2020-12-11 09:58:32 -08:00
Robert Widmann 883902411b Migrate loadFingerprint onto ModuleDecl and Friends 2020-11-18 12:20:14 -08:00
Robert Widmann 912ed2711b [NFC] Use Fingerprints When Computing the Interface Hash 2020-11-18 12:20:14 -08:00
Artem Chikin 3b545498d0 Merge pull request #34331 from artemcm/NoFoundationOnExplicitImportSoil
[Clang Importer] Do not rely on being able to always import Foundation on-demand
2020-11-02 13:02:15 -08:00
Alejandro Alonso 424802fb34 Revert SE-0283 (#34492)
Reverted despite build failures.
2020-10-29 17:32:06 -07:00
Artem Chikin 0305f20f32 [Clang Importer] Do not rely on being able to always import Foundation on-demand
When importing Clang types.
This is not an option with Explicit Module Builds. If the module being built does not (directly or transitively) depend on `Foundation`, then attempting to load it will produce an error because Implicit module loading is no longer allowed..

This change addresses a small number of cases where ClangImporter relies on being able to load `Foundation` on-demand:
- When importing a single Decl from a clang module, we check whether it has certain conformances by checking all extensions of the NominalTypeDecl of the Decl in question, to see if any of the extensions contain the conformance we are looking for, but we only check extensions whose parent module is either the original module of the NominalTypeDecl or the overlay module of the NominalTypeDecl or Foundation. It seems that we do not need to actually import `Foundation` here, just checking the module Identifier should be sufficient.
- In `maybeImportNSErrorOutParameter`, change the behavior to have an exit condition based on whether `Foundation` can be imported, before attempting to load it.
- When checking whether or not we are allowed to bridge an Objective-C type, it also looks sufficient the query whether or not `Foundation` *can* be imported, without loading it.
2020-10-28 14:47:17 -07:00
Varun Gandhi d32a371df5 Merge pull request #34410 from varungandhi-apple/vg-revert-import-filtering-refactor
Revert "[NFC] Clarify semantics of getImportedModules."
2020-10-26 13:36:32 -07:00
Varun Gandhi 1f479896f4 Revert "[NFC] Clarify semantics of getImportedModules."
This reverts commit 4b5d885114.
2020-10-23 10:01:35 -07:00
Azoy 4ff28f2b40 Implement Tuple Hashable Conformance 2020-10-22 18:28:02 -04:00
Azoy fd950ebbf3 Implement Tuple Comparable Conformance
Add protocol witnesses for all Comparable requirements
2020-10-22 18:27:07 -04:00
Azoy e60ef84bd2 Implement Tuple Equatable Conformance 2020-10-22 18:24:28 -04:00