591 Commits

Author SHA1 Message Date
Alexis Laferrière
14c639b549 [Index] Index only system modules in the SDK
Indexing a module from the swiftinterface puts the swiftinterface
version in the cache. Subsequent builds don't see the adjacent
swiftmodule file. This can break test clients that need the adjacent
swiftmodule information. To avoid this scenario, ensure that we only
index system modules in the SDK, not local versions.

rdar://102207620
2022-12-07 13:27:08 -08:00
Xi Ge
afbc4a5ffd Merge pull request #62251 from nkcsgexi/allowable-serialization
serialization: encode allowable client names in binary module format
2022-11-28 18:12:43 -08:00
Alexis Laferrière
c266e9dce5 Merge pull request #62185 from xymus/improve-rmodule-loading
Improve `-Rmodule-loading` to show both the path to the source and to the cached file actually loaded
2022-11-28 14:25:15 -08:00
Xi Ge
c3db946517 sema: diagnose importation from disallowed modules 2022-11-25 23:37:01 -08:00
Xi Ge
67bbab7e02 serialization: encode allowable client names in binary module format 2022-11-25 18:43:40 -08:00
Alexis Laferrière
319d49816d [Frontend] -Rmodule-loading shows both source path and cached path 2022-11-18 15:28:16 -08:00
Robert Widmann
9ff5d88847 Remove SourceKit Support for the libSyntax Tree 2022-11-16 14:52:28 -08:00
Alexis Laferrière
e52fbb89c1 [AST] Intro a check for the export_as relationship between 2 modules 2022-11-14 12:28:31 -08:00
Doug Gregor
0cb2746c49 Keep track of source files created for macro expansions and such.
Introduce a new source file kind to describe source files for macro
expansions, and include the macro expression that they expand. This
establishes a "parent" relationship

Also track every kind of auxiliary source file---whether for macro
expansions or other reasons---that is introduced into a module, adding
an operation that allows us to find the source file that contains a
given source location.
2022-11-01 08:03:26 -07:00
Alexis Laferrière
82f63b090e [Serialization] Minor improvements to doc from PR comments 2022-10-31 10:59:18 -07:00
Alexis Laferrière
2854c1b3cb [Serialization] Write in the swiftmodule if it's built from a swiftinterface
This information will allow us to distinguish swiftmodule built from
source vs swiftinterface.
2022-10-27 18:51:28 -07:00
Nate Chandler
de19777da3 [AST] Retrieve @main type from module.
Added a convenience function to ModuleDecl to look up the entry point
@main type if there is one.
2022-09-23 15:26:22 -07:00
QuietMisdreavus
f674b473ec introduce a @_documentation(...) attribute to influence SymbolGraphGen (#60242)
* add @_documentation(...) attribute to influence SymbolGraphGen

rdar://79049241
2022-09-06 14:12:42 -06:00
Alexis Laferrière
aaaef3411e [Sema] Intro @_spiOnly attribute and import filter
Introduce the attribute and basic import filter logic.
2022-09-01 15:16:44 -07:00
Alexis Laferrière
ae9bc59a93 Merge pull request #60659 from xymus/print-missing-imports
[ModuleInterface] Print missing imports in swiftinterface
2022-08-23 09:47:25 -07:00
Alexis Laferrière
9e3f5f9cea [ModuleInterface] Print missing imports in swiftinterface
Hack to fix swiftinterfaces in case of missing imports. We can get rid
of this logic when we don't leak the use of non-locally imported things
in API.
2022-08-19 12:32:43 -07:00
Allan Shortlidge
40eb1422bb IRGen/SIL: Fix IR linkage computation for inlined function references from modules imported @_weakLinked.
Include the parent `ModuleDecl` when serializing a `SILFunction` so that it is available on deserialized functions even though the full `DeclContext` is not present. With the parent module always available we can reliably compute whether the `SILFunction` comes from a module that was imported `@_weakLinked`.

Serialize the `DeclContext` member of `SILFunction` so that it can be used to look up the module that a function belongs to in order to compute weak import status.

Resolves rdar://98521248
2022-08-19 09:56:45 -07:00
Allan Shortlidge
f71a3232cf IRGen: Use extern_weak linkage for Clang symbols from @_weakLinked imported modules.
rdar://96098097
2022-08-11 11:02:57 -07:00
Allan Shortlidge
bc5f13cb6b AST: Accept @_weakLinked on import decls to force weak linkage of symbols from a module.
The effect of declaring an import `@_weakLinked` is to treat every declaration from the module as if it were declared with `@_weakLinked`. This is useful in environments where entire modules may not be present at runtime. Although it is already possible to instruct the linker to weakly link an entire dylib, a Swift attribute provides a way to declare intent in source code and also opens the door to diagnostics and other compiler behaviors that depend on knowing that all the module's symbols will be weakly linked.

rdar://96098097
2022-08-11 11:02:57 -07:00
QuietMisdreavus
2d874788f6 [SymbolGraphGen] only include the given symbol for qualified imports (#59852)
* only include the given symbol for qualified imports

rdar://96309088

* re-exporting one type should not allow unrelated types to sneak in

* ensure that children of re-exported types are also re-exported
2022-07-08 09:13:08 -06:00
Slava Pestov
bd46bdaaaa AST: Narrow the filtering of unavailable conformances to Sendable only
Remove the allowUnavailable parameter to lookupConformance(), and instead
explicitly check the result for hasUnavailableConformance() in the places
where we used to pass 'false'.

Also, narrow down this check in those places to the Sendable protocol
only, fixing a regression with Hashable conformance synthesis.

Fixes rdar://problem/94460143.
2022-06-14 21:24:08 -04:00
Robert Widmann
0d117c1345 Don't Mutate ModuleDecl's File List When Creating Synthesized Files
See #59144 for more on why this is a bad idea.

Patch out the synthesized file unit accessor to only clear the source cache, then patch up all the places that were assuming they could iterate over the module's file list and see synthesized files.

rdar://94164512
2022-06-11 11:07:05 -06:00
Doug Gregor
c9c50b4ae0 [Requirement machine] Ignore unavailable conformances on superclass constraints.
When determining whether a superclass conforms to a particular protocol,
skip unavailable conformances. This way, we don't minimize away a
constraint that might only apply to subclasses of the specified
superclass.

Fixes rdar://91853658.
2022-05-27 13:09:15 -07:00
Franklin Schrans
9cd44ca5d1 [SymbolGraphGen] Emit symbols from exported modules
When emitting a symbol graph file for a module that import modules via
`@_exported import`, emits those modules' symbols as well.

SR-15753

rdar://89547374
2022-02-28 17:21:25 +00:00
Victoria Mitchell
cab1669e09 only recurse getDisplayDecls in SymbolGraphGen 2022-02-19 10:32:29 -07:00
Victoria Mitchell
aeaf6b22db [AST] check modules before recursing for display decls 2022-01-18 08:51:29 -07:00
Victoria Mitchell
ec6c3fb3d7 Revert "Merge pull request #40877 from apple/revert-40810-QuietMisdreavus/sourcefile-export"
This reverts commit caf2f087e3, reversing
changes made to 5a9abb2119.
2022-01-18 08:51:10 -07:00
nate-chandler
05a4c57149 Revert "[AST] scan @_exported import modules of source files for display decls" 2022-01-14 09:10:34 -08:00
Victoria Mitchell
b5dc995d3e add module/file debug dumpers 2022-01-13 09:01:52 -07:00
Ellie Shin
d95d0a0a7d Merge pull request #40450 from apple/es-index
[Indexing] If module aliasing is used, store module real names to index unit/record files
Resolves rdar://82896373
2021-12-07 23:49:01 -08:00
Ellie Shin
e358302f54 Always print real module name via printModuleUSR 2021-12-07 14:43:41 -08:00
Ellie Shin
0ff713d44c [Indexing] Use module real name in case module aliasing is used
Resolves rdar://82896373
2021-12-07 02:22:36 -08:00
Xi Ge
6377c3a742 Revert "Revert "serialization: obfuscate the serialized search paths"" 2021-12-02 13:21:04 -08:00
Saleem Abdulrasool
11d5d6d4ca Revert "serialization: obfuscate the serialized search paths" 2021-12-02 08:18:23 -08:00
Xi Ge
0047d81f9a serialization: obfuscate the serialized search paths
We noticed some Swift clients rely on the serialized search paths in the module to
find dependencies and droping these paths altogether can lead to build failures like
rdar://85840921.

This change teaches the serialization to obfuscate the search paths and the deserialization
to recover them. This allows clients to keep accessing these paths without exposing
them when shipping the module to other users.
2021-12-01 11:47:41 -08:00
Kuba (Brecka) Mracek
c89eca6c34 Enforce consistent usage of -experimental-hermetic-seat-at-link flag (#39986)
We've recently added the -experimental-hermetic-seal-at-link compiler flag,
which turns on aggressive dead-stripping optimizations and assumes that library
code can be optimized against client code because all users of the library
code/types are present at link/LTO time. This means that any module that's
built with -experimental-hermetic-seal-at-link requires all clients of this
module to also use -experimental-hermetic-seal-at-link. This PR enforces that
by storing a bit in the serialized module, and checking the bit when importing
modules.
2021-11-30 10:44:58 -08:00
Becca Royal-Gordon
1880118e70 Restructure getDisplayDecl() Sendable forcing
Move this into a helper function that lives in Sema, avoiding libswiftAST calling into libswiftSema.
2021-11-19 17:51:27 -08:00
Ellie Shin
6f34844b49 Merge pull request #39705 from apple/es-module-alias-serialize
[Module aliasing] Serialize SIL and binaries with module real names for referenced or imported modules. Resolves rdar://83632529
2021-10-18 21:55:45 -07:00
elsh
e3d5ae0172 Add SIL re-ingest test 2021-10-14 19:03:31 -07:00
elsh
e1dfdba1e6 Add doc comments and tests for AST / SIL 2021-10-14 16:18:02 -07:00
Mishal Shah
c2fd49cebb Merge pull request #39473 from apple/rebranch
Update swift:main to support llvm-project:stable/20210726 changes (Rebranch merge)
2021-10-11 09:00:51 -07:00
swift-ci
3f8fea8508 Merge remote-tracking branch 'origin/main' into rebranch 2021-10-06 10:17:29 -07:00
Alexis Laferrière
9cf45faefd [Sema] Objective-C SPI are always imported
rdar://83186214
2021-10-05 10:12:49 -07:00
elsh
b5f8c7901c move the lookup to the getRealName() 2021-09-30 12:43:41 -07:00
elsh
b00fcdc3f1 Update comments 2021-09-29 16:40:22 -07:00
elsh
fc420d04e2 Modify setModuleAliases and lookup
Add examples to documentation comment
2021-09-29 16:40:22 -07:00
elsh
0e05d10308 Add module alias map and lookup func to ASTContext
Set module underlying name in ModuleDecl if a module alias exists
rdar://83682112
2021-09-29 16:40:22 -07:00
Adrian Prantl
e754f5a6c4 Disable resilience for modules imported by the MemoryBuffer loader.
The MemoryBuffer loader is used by LLDB during debugging to import binary Swift
modules from .swift_ast sections. Modules imported from .swift_ast sections are
never produced from textual interfaces. By disabling resilience the expression
evaluator in the debugger can directly access private members.

rdar://79462915
2021-08-30 17:45:55 -07:00
eeckstein
deb02c188c Merge pull request #38951 from eeckstein/fix-cmo-crash
cross-module-optimization: Don't serialize functions which reference implementationOnly-imported functions
2021-08-23 18:22:29 +02:00
Becca Royal-Gordon
c517b45bb4 Merge pull request #38948 from beccadax/the-copypasta-is-stale
[NFC] Factor out ASTContext `operator new`s
2021-08-20 11:04:56 -07:00