Commit Graph

37841 Commits

Author SHA1 Message Date
Steven Wu
c7d66b8845 Teach swift to compute cache key for compiler outputs
Teach swift how to serialize its input into CAS to create a cache key
for compiler outputs. To compute the cache key for the output, it first
needs to compute a base-key for the compiler invocation. The base key is
computed from: swift compiler version and the command-line arguments for
the invocation.

Each compiler output from swift will gets its own key. The key for the
output is computed from: the base key for the compiler invocation + the
primary input for the output + the output type.
2023-04-24 13:55:38 -07:00
Alex Hoppen
8abe38f9e2 [Rename] Also syntactically rename a macro’s definition
Previously we were skipping the macro’s definition (i.e. the part after `=` in a macro declaration if it wasn’t type checked. Since syntactic rename doesn’t type-check anything, it was thus skippin the macro definition. Add a flag to `ASTWalker` that allows `NameMatcher` to opt-out of this behavior.
2023-04-24 13:33:57 -07:00
nate-chandler
0c0ec72255 Merge pull request #65377 from nate-chandler/rdar108385761
[SILGen] Consuming a param implies it's eager-move.
2023-04-24 12:49:46 -07:00
Nate Chandler
6ad9581bd6 [SIL] NFC: Clarified doc comment. 2023-04-24 10:38:11 -07:00
Tim Kientzle
9bfe1b1691 Merge branch 'main' into tbkka-RemoteMirror-MPE-zero-sized-plus-generics 2023-04-24 08:22:38 -07:00
Tim Kientzle
db14ae840e Merge pull request #65332 from tbkka/tbkka-RemoteMirror-nested-generics
[RemoteMirror] Fix lookup of generic type parameters
2023-04-24 08:06:30 -07:00
Erik Eckstein
e7af73e2de Replace the swift-llvm-opt binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:53:12 +02:00
Erik Eckstein
2b2bc45e08 Replace the swift-dependency-tool binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:51:04 +02:00
Erik Eckstein
8ce6038a42 Replace the sil-passpipeline-dumper binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:49:33 +02:00
Erik Eckstein
e3a174b85e Replace the sil-llvm-gen binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:48:23 +02:00
Erik Eckstein
bc7b632d3e Replace the sil-nm binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:47:13 +02:00
Erik Eckstein
b6132d10e5 Replace the sil-func-extractor binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:45:22 +02:00
Erik Eckstein
2e9c241034 Replace the sil-opt binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:44:04 +02:00
Tim Kientzle
488fb82034 Refactor to handle the parent list separately
Handle the top node directly in `createBoundGenericType`
so that we can be sure to always include it regardless
of whether it has direct generic type params or not.

The helper function can now focus only on handling
parents (where we must only include ones that actually
contain generic type params).  This separates the two
different cases and makes it a little easier to follow.

I refactored `reconstructParentsOfBoundGenericType` to
be iterative rather than recursive, though I'm not sure that
really matters.
2023-04-22 13:36:47 -07:00
Tim Kientzle
5350cd5d15 Rework createBoundGenericTypeReconstructingParent
The recursive structure made it a little awkward to correctly
distinguish between the root node (which has to be included
regardless of whether it has direct generic params)
and the parent nodes (which must only be included if they
have direct params).

So I rewrote this to do a simple two-pass iteration:
* The first pass walks the parent list collecting candidates
* The second pass walks the list backwards, assigning generic params

We then just stack the start node onto the end of the
list regardless of whether it has generic params.
2023-04-22 12:20:39 -07:00
Meghana Gupta
3d75abc570 Add an option to force boundary completion of lexical values 2023-04-21 22:41:22 -07:00
Nate Chandler
525541fd1c [Sema] Ban @_eagerMove on Copyable things. 2023-04-21 21:59:31 -07:00
Nate Chandler
abba5ef857 [SILGen] Consuming a param implies it's eager-move
If a parameter is marked consuming and its type is Copyable, that
parameter has eager-move semantics.  Apply that attribute to the
SILFunctionArgument corresponding to the parameter.

rdar://108385761
2023-04-21 21:59:31 -07:00
Slava Pestov
ce5bef8f4d Merge pull request #65361 from slavapestov/sil-type-subst-cloner-sillyness
SIL: TypeSubstCloner::remapASTType() should not call getLoweredRValueType()
2023-04-21 18:52:32 -04:00
Pavel Yaskevich
8a26df8166 [ConstraintSystem] NFC: Standardize the way of type holefication
Introduce `ConstraintSystem::recordTypeVariablesAsHoles` as a
standard way to record that unbound type variables found in a
type are holes in the given constraint system.
2023-04-21 15:22:13 -07:00
Doug Gregor
ae4a5ded8f [Macros] Improve parsing, representation, and serialization of role attributes
Parse compound and special names in the macro role attributes
(`@freestanding` and `@attached`). This allows both compound names and
initializers, e.g., `init(coding:)`.

Fixes rdar://107967344.
2023-04-21 11:36:06 -07:00
Slava Pestov
8bb3248ab3 SIL: TypeSubstCloner::remapASTType() should not call getLoweredRValueType()
SILCloner::visitScalarPackIndexInst() was calling remapASTType() on
a PackType. This was becoming a SILPackType, which would then crash
in a cast<>.
2023-04-21 14:17:08 -04:00
Pavel Yaskevich
1c3667b52a Merge pull request #65310 from calda/cal--SE-3065-bad-pattern-check
[SE-0365] Fix issue where boolean condition before `let self` condition would prevent using implicit self
2023-04-21 09:54:27 -07:00
stevenwong
3cabe08d29 [Parser] Make parser aware of the unexpected attributes 2023-04-21 23:38:57 +08:00
Alex Lorenz
346ba0153a Merge pull request #65338 from hyp/eng/enum-fix-indirect
[interop][SwiftToCxx] do not expose unsupported enums yet
2023-04-21 08:15:42 -07:00
nate-chandler
c972a9337d Merge pull request #65309 from nate-chandler/rdar98542123
[SIL] Accesses to globals are deinit barriers.
2023-04-21 07:02:40 -07:00
Hamish Knight
017794a7d7 Merge pull request #65098 from hamishknight/poundland 2023-04-21 09:26:10 +01:00
Alex Lorenz
71ef7e8d3d [interop][SwiftToCxx] do not expose unsupported enums yet
This includes indirect enums, enums with multiple associated values, or enums whose associated value is a type we don't yet support
2023-04-20 18:05:00 -07:00
Nate Chandler
5b6c1d6660 [SIL] Accesses to globals are deinit barriers.
Accesses to globals can't be reordered with deinits since deinits could
read such globals.

rdar://98542123
2023-04-20 18:02:41 -07:00
Ellie Shin
b081404daa Print package-name in .private.swiftinterface only for better abstraction
Resolves rdar://107638447
2023-04-20 17:45:22 -07:00
Ellie Shin
578c63a372 Merge pull request #65111 from apple/es-str
Allow all unicode characters in package-name input
2023-04-20 17:13:37 -07:00
Tim Kientzle
02160e68a0 Recursively reconstruct nested generics, skipping non-generic
This is a more correct fix for the issue that inspired PR #62854.
In particular, this does not change the numbering of generic
argument levels, and so does not break generic type parameter
lookups.

Added a new test case to verify that nested types that mix
generics and non-generics in different ways consistently identify
the correct generic argument labels.
2023-04-20 14:31:06 -07:00
Tim Kientzle
89f98e9d7c Partially Revert "Fix wrong calculation of generic params per level when building decl"
(Keeps the test, but reverts the code changes; the test will be updated later.)

This reverts most of commit 893d83ba0a from PR #62854
2023-04-20 14:30:38 -07:00
Cal Stephens
ee906f7ba5 Merge branch 'main' into cal--SE-3065-bad-pattern-check 2023-04-20 13:41:48 -07:00
Cal Stephens
870dbccf88 Consolidate LabeledConditionalStmt::rebindsSelf logic into shared helper 2023-04-20 13:39:05 -07:00
Ellie Shin
3a4cd362ac Allow all unicode characters in package-name input
Error if the input is empty
Resolves rdar://104617274
2023-04-20 11:16:30 -07:00
Cal Stephens
d1677c623e Add getInitializerOrNull 2023-04-20 09:39:55 -07:00
Holly Borla
d7388346c5 Merge pull request #65313 from hborla/fix-macro-expansion-walking
[Macros] Fix type-checking local pattern bindings in macro-expanded closures.
2023-04-20 07:39:55 -07:00
Holly Borla
b958e43528 [Macros] Remove ModuleDecl::isInGeneratedBuffer.
This method was misleading. The majority of callers (all but one!) don't want
to unconditionally treat all locations in any macro expansion buffer the
same way, because the code also must handle nested macro expansions. There
is one part of SourceKit (and possibly others) that really do want to ignore
all macro expansions, but those can be handled within SourceKit / IDE code,
because I don't believe this utility is useful in the frontend.
2023-04-19 21:28:09 -07:00
Holly Borla
265c8a47d9 [Macros] Fix an issue where the constraint system skipped local declarations
inside closures while type checking a macro expansion.

PreCheckExpr, ConstraintGenerator, and other walkers do not walk into macro
expansions. However, the implementation of this macro walking behavior in
ASTWalker would skip any declaration that appears inside any macro expansion
buffer. This is incorrect for cases where the parent is in the same macro
expansion buffer, because the local declaration is not inside a new macro
expansion. This caused bogus errors when type checking expanded macro expressions
containing closures with local declarations, because pre-check and constraint
generation mistakenly skipped local pattern bindings.
2023-04-19 20:11:38 -07:00
Rintaro Ishizaki
8dcca5809f Merge pull request #65263 from rintaro/nullterminatedstringref-rdar108215490
[Basic] Ensure empty NullTerminatedStringRef have valid pointer
2023-04-19 15:22:47 -07:00
Slava Pestov
f1b8d9d111 Merge pull request #65278 from slavapestov/astprinter-pack-requirement
ASTPrinter: Fix printing of pack requirements
2023-04-19 16:14:40 -04:00
Rintaro Ishizaki
a0eb32e4d7 [Macros] Create llvm::MemoryBuffer directly from macro expansion result
Saves one memory copy. No need to create a temporary
NullTerminatedStringRef.
2023-04-19 10:50:56 -07:00
Slava Pestov
df5d531dc6 ASTPrinter: Fix printing of pack requirements
Also remove the flag for printing 'each' and make it always on.
2023-04-19 13:04:51 -04:00
Steven Wu
b9f9eeb198 Merge pull request #65058 from cachemeifyoucan/eng/PR-swift-cas-fs
[CAS] Integrate CAS into swift compiler
2023-04-19 09:11:30 -07:00
Artem Chikin
a5017db87a Merge pull request #65234 from artemcm/TestableDependencyOptionalLookup
[Dependency Scanning] Consider optional dependencies of `@testable` textual dependencies with an adjacent binary module
2023-04-19 08:41:45 -07:00
Anthony Latsis
0028322485 Merge pull request #65246 from AnthonyLatsis/nfc-debug-constraints
[NFC] CS: Misc minor debug output tweaks
2023-04-19 02:46:05 +03:00
Rintaro Ishizaki
43eabf1828 [Basic] Ensure empty NullTerminatedStringRef have valid pointer
NullterminatedStringRef is meant to be safe for reading 'data()' as a
valid C-string.

rdar://108215490
2023-04-18 13:20:26 -07:00
Anthony Latsis
82ac9328ae [NFC] CS: Misc minor debug output tweaks
* Use fancy arrows (`→`) because they are distinct from and shorter than `->`,
  and fancier.
* We have two ways of demarcating locators: `@ <locator>` and `[[<locator>]];`.
  Stick to the first, which is shorter and clearer.
* 'attempting type variable' → 'attempting binding'. *Bindings* are attempted,
  not type variables.
* `considering ->` → `considering:`. I think a colon is semantically more fit
  and makes things easier to read if the considered constraint has arrows in its
  description or types. It’s also shorter this way.
2023-04-18 22:42:59 +03:00
Slava Pestov
7fa676e53d SIL: Introduce SILType::hasParameterizedExistential() 2023-04-18 12:54:49 -04:00