Commit Graph

18474 Commits

Author SHA1 Message Date
Joe Groff
3582691e65 Merge pull request #66302 from jckarter/noncopyable-switch-require-consume
Require `switch` on a noncopyable-type binding to be explicitly `consumed`.
2023-06-03 12:08:26 -07:00
Joe Groff
359e045192 Require switch on a noncopyable-type binding to be explicitly consume-d.
Pattern matching as currently implemented is consuming, but that's not
necessarily what we want to be the default behavior when borrowing pattern
matching is implemented. When a binding of noncopyable type is pattern-matched,
require it to be annotated with the `consume` operator explicitly. That way,
when we introduce borrowing pattern matching later, we have the option to make
`switch x` do the right thing without subtly changing the behavior of existing
code. rdar://110073984
2023-06-02 18:14:37 -07:00
Rintaro Ishizaki
86d405bcd0 [Macros] Unify MacroExpansionDecl/MacroExpansionExpr expansion logic
'MacroExpansionDecl' and 'MacroExpansionExpr' have many common methods.
Introduce a common base class 'FreestandingMacroExpansion' that holds
'MacroExpansionInfo'.

Factor out common expansion logic to 'evaluateFreestandingMacro'
function that resembles 'evaluateAttachedMacro'.
2023-06-02 11:54:05 -07:00
Slava Pestov
7499c222ee AST: Requestify lookup of protocol referenced by ImplementsAttr
Direct lookup relied in primary file checking to have filled in the
protocol type stored in the ImplementsAttr. This was already wrong
with multi-file test cases in non-WMO mode, and crashed in the
ASTPrinter if printing a declaration in a non-primary file.

I don't have a standalone test case that is independent of my
upcoming ASTPrinter changes, but this is a nice cleanup regardless.
2023-06-02 13:17:25 -04:00
Ben Barham
18f56c9de5 [NFC][ASTGen] Add wrapping structs for commonly bridged types
Adds wrapping structs for a bunch of commonly bridged types (but not all
the AST nodes yet).
2023-06-02 10:11:46 -07:00
Sophia Poirier
8ccabbdae8 Merge pull request #66244 from sophiapoirier/MaterializePackExpr-getEndLock-logical-inversion
[Variadic Generics] correct a logical inversion typo in MaterializePa…
2023-06-02 10:42:44 -04:00
Slava Pestov
fd81f8135d Merge pull request #66294 from slavapestov/pack-element-type-part-2
PackElementType changes, part 2
2023-06-02 07:32:54 -04:00
Slava Pestov
c441187355 AST: Break circularity in PackArchetypeType::getReducedShape()
This can't happen yet, but with an upcoming change, we hit an infinite
recursion here with PackExpansionType::get() -> getReducedShape()
-> mapTypeIntoContext() -> PackExpansionType::get().
2023-06-01 22:36:24 -04:00
Slava Pestov
c20532eb16 AST: Move TypeBase::isParameterPack() to ParameterPack.cpp 2023-06-01 19:20:11 -04:00
Ellie Shin
3cd653d7ae Merge pull request #66226 from apple/es-alias-rename
Update module aliasing terms in diagnostics and comments
2023-06-01 15:51:25 -07:00
Becca Royal-Gordon
b14c00d521 Support required inits in @objcImpl
• Allow `required init`s in @objcImpl extensions of a class’s main body
• Validate that the presence or absence of a `required` modifier matches the imported header declaration.

Fixes rdar://110016760.
2023-06-01 13:21:02 -07:00
Doug Gregor
54d2ea0a17 [Member name lookup] Only look to expand macros in types/extensions that matter
Keep track of those types and extensions that have any macro expansions,
so that when we need to check whether to expand macros to satisfy name
lookup, we only look through that list---rather than looking at every
extension again.

This improves compile times significantly for a source file with a
large number of extensions on a single type. However, there is still
much to do here.
2023-05-31 16:06:09 -07:00
Doug Gregor
af3ea4d142 [Name lookup] Only walk types/extensions to expand macros when we need to
Keep track of which types/extensions have members that could be produced by
a macro expansion, including the names of those members. Use this to
avoid walking into extensions or type definitions to expand macros
when they don't have any related macros.
2023-05-31 15:37:46 -07:00
Ellie Shin
8c66776ce1 Update module aliasing terms in diagnostics and comments
s/underlying_name/real_name

rdar://110028578
2023-05-31 11:47:11 -07:00
Sophia Poirier
ced806ab52 [Variadic Generics] correct a logical inversion typo in MaterializePackExpr::getEndLoc (introduced in 0594efc0c) 2023-05-31 10:10:52 -04:00
Sophia Poirier
0594efc0ce Merge pull request #66214 from sophiapoirier/tuple-expansion-without-dot-element
[Variadic Generics] drop requirement of .element for tuple expansion
2023-05-30 16:29:55 -04:00
Steven Wu
daaee2705b Merge pull request #65924 from cachemeifyoucan/eng/PR-swift-cache-replay
[CAS] Teach swift-frontend to replay result from cache
2023-05-30 12:56:46 -07:00
Alexis Laferrière
814ca434f0 Merge pull request #66186 from xymus/force-workaround
[Serialization] Add flag to force unsafe recovery from some xref failures
2023-05-30 08:55:17 -07:00
Sophia Poirier
93864f6c15 [Variadic Generics] drop requirement of .element for tuple expansion rdar://107160966 2023-05-30 11:37:55 -04:00
Anton Korobeynikov
0b7d8ab78c [AutoDiff] Remove 'readnone' attribute from autoDiffCreateLinearMapContext. (#66203)
It certainly has side effects and returned value every time is different.
This way we ensure multiple calls are not CSE'd or LICM'ed.

Fixes #65989
2023-05-29 23:56:33 -07:00
Doug Gregor
5cdd34aa93 Merge pull request #66198 from DougGregor/closure-local-discriminators-in-macro-expansions
[Macros] Rework the way we assign closure and local discriminators
2023-05-28 23:03:34 -07:00
Doug Gregor
7386a7e7bd [Macros] Rework the way we assign closure and local discriminators
Setting closure and local discriminators depends on an in-order walk
of the AST. For macros, it was walking into both macro expansions and
arguments. However, this doesn't work well with lazy macro expansions,
and could result in some closures/local variables not getting
discriminators set at all.

Make the assignment of discriminators only walk macro arguments, and
then lazily assign discriminators for anything within a macro
expansion or in ill-formed code. This replaces the single global "next
autoclosure discriminator" scheme with a per-DeclContext scheme, that
is more reliable/robust, although it does mean that discriminators
of closures and locals within macro expansions are dependent on
ordering. That shouldn't matter, because these are local values.

Fixes rdar://108682196.
2023-05-28 16:49:20 -07:00
Michael Gottesman
577e76b0f6 [move-only] Change closure capture diagnostic for let patterns to say that it cannot be captured by an escaping closure.
rdar://109742587
2023-05-28 13:58:59 -07:00
Ellie Shin
79a2ff5efd Merge pull request #66189 from apple/es-diag
Improve diagnostics when package acl is used but no package-name is passed
2023-05-27 12:23:10 -07:00
Ellie Shin
854e7dca46 s/passed/specified 2023-05-26 17:10:32 -07:00
Alexis Laferrière
261f32cb84 Merge pull request #66139 from xymus/r-module-recovery 2023-05-26 16:00:43 -07:00
Ellie Shin
61dd3008f8 Improve diagnostics when package acl is used but no package-name is passed 2023-05-26 15:59:51 -07:00
Alexis Laferrière
d50f20e4a8 [Serialization] Make a warning the diagnostic about attempting recovery
Use the `attempting forced recovery` diagnostic as main warning to which
we attach other messages as notes. Also mention the flag in the
diagnostic to reinforce that the flag is active.
2023-05-26 15:28:01 -07:00
Artem Chikin
bc5e8bafed Merge pull request #66148 from artemcm/PrivateClangSubmoduleScan
[Dependency Scannning] Handle special case import of Clang Private "submodules"
2023-05-26 14:50:06 -07:00
Alexis Laferrière
642980cbb1 [Serialization] Add flag to force unsafe recovery from some xref failures
Intro a deserialization mode controlled by the flag
`-experimental-force-workaround-broken-modules` to attempt unsafe
recovery from deserialization failures caused by project issues.

The one issue handled at this time is when a type moves from one module
to another. With this new mode the compiler may be able to pick a
matching type in a different module. This is risky to use, but may help
in a pinch for a client to fix and issue in a library over which they
have no control.
2023-05-26 14:36:28 -07:00
Pavel Yaskevich
950ff0f9b5 Merge pull request #66153 from xedin/rework-pack-conf-isinvalid
[AST] NFC: Fold `PackConformance::isInvalid` into `ProtocolConformanceRef::isInvalid`
2023-05-26 14:32:27 -07:00
Kuba (Brecka) Mracek
2d5f33e2e3 Add @_used and @_section attributes for global variables and top-level functions (#65901)
* Add @_used and @_section attributes for global variables and top-level functions

This adds:
- @_used attribute that flags as a global variable or a top-level function as
  "do not dead-strip" via llvm.used, roughly the equivalent of
  __attribute__((used)) in C/C++.
- @_section("...") attribute that places a global variable or a top-level
  function into a section with that name, roughly the equivalent of
  __attribute__((section("..."))) in C/C++.
2023-05-26 14:02:32 -07:00
Pavel Yaskevich
fe8fd91307 [AST] NFC: Fold PackConformance::isInvalid into ProtocolConformanceRef::isInvalid
Instead of making callers responsible for that (like in other cases),
let's fold the code check `isInvalid` to make mistakes less likely.
2023-05-26 08:53:11 -07:00
Slava Pestov
9b3faad523 Merge pull request #66126 from slavapestov/pack-element-refactoring
Preliminary work for introducing PackElementType
2023-05-26 09:13:53 -04:00
Doug Gregor
7d0510a1bf Merge pull request #66131 from DougGregor/interfaces-without-macros 2023-05-25 21:07:12 -07:00
Artem Chikin
78b4391e0d [Dependency Scannning] Handle special case import of Clang Private "submodules"
There is a special case that already exists in 'ClangImporter' for implicit module loading:
Import of a "submodule" named "Foo.Private" is treated as a top-level module named "Foo_Private".
Clang has special support for this.

Resolves rdar://108287140
2023-05-25 14:00:28 -07:00
Doug Gregor
418471494b [Module printing] Don't print attached macros in generated interfaces
Macros are expanded as part of interface generation, so they shouldn't
also be printed into the Swift interface.

Fixes rdar://109378191.
2023-05-25 11:24:53 -07:00
Slava Pestov
b2bc2c72ec AST: Introduce PackElementType 2023-05-25 11:17:30 -04:00
Konrad `ktoso` Malawski
d685c1c67d Merge pull request #66119 from ktoso/wip-distributed-ban-__owned 2023-05-25 16:58:45 +02:00
swift-ci
47206732f5 Merge pull request #66090 from kavon/noncopyable-diagnostics-cleanup
polish up the noncopyable diagnostics
2023-05-25 02:07:06 -07:00
Konrad `ktoso` Malawski
6e14025b95 [Distributed] Explicitly ban __owned and other specifiers we dont support 2023-05-25 10:59:01 +02:00
Kavon Farvardin
03d2017a84 reword 'other consume here' to 'consumed again here'
this also fixes a bug where sometimes we simply emit
'consumed here' twice and other times we'd said 'other
consume here' for the same "consumed more than once"
message. so I went through and changed all of the 2nd
consumes into "consumed again".

rdar://109281444
2023-05-24 20:56:39 -07:00
Kavon Farvardin
71763a124e merge similar diagnostics together under a unified naming scheme for more consistent word tense
sil_movekillscopyablevalue_* and sil_moveonlychecker_* can share diagnostics.

rdar://109281444
2023-05-24 20:56:38 -07:00
Kavon Farvardin
667459ee75 tighten up consistency in terminology
- refer to a "consuming use" as simply a "consume", to reserve "use" for non-consuming uses.
- refer to "non-consuming uses" as just a "use".
- don't call it a "user defined deinit" and instead a "deinitializer" to match Sema
- be specific about what binding a closure is capturing that is preventing consumption.

rdar://109281444
2023-05-24 20:56:38 -07:00
Kavon Farvardin
e9e6cdaf2e remove "within a closure" since you can't consume any captured noncopyable binding
rdar://109281444
2023-05-24 20:56:38 -07:00
Kavon Farvardin
616395c6ed specify "inout" for missing reinit error
rdar://109281444
2023-05-24 20:56:37 -07:00
Kavon Farvardin
90077ab593 update diagnostics in clang importer
rdar://109281444
2023-05-24 20:56:37 -07:00
Kavon Farvardin
3149102fea reword "boundary use" to just "non-consuming"
rdar://109281444
2023-05-24 20:56:37 -07:00
Kavon Farvardin
d3730d896d reword diagnostics for partial consume of fields
also moves the error to the invalid partial consume.

rdar://109281444
2023-05-24 20:56:37 -07:00
Kavon Farvardin
31aa2f77e3 polish noncopyable types diagnostic wordings
- replaces "move-only" terminology with "noncopyable"
- replaces compiler jargon like "guaranteed parameters"
  and "lvalue" with corresponding language-level notions
- simplifies diagnostics about closures.

and probably more.

rdar://109281444
2023-05-24 20:56:36 -07:00