Commit Graph

1737 Commits

Author SHA1 Message Date
Robert Widmann
91c262bcb7 Move TokenKinds.def.gyb to AST 2022-11-16 13:38:25 -08:00
Doug Gregor
0f9a70601a Parse and record top-level "items" rather than always forcing declarations.
In the Swift grammar, the top-level of a source file is a mix of three
different kinds of "items": declarations, statements, and expressions.
However, the existing parser forces all of these into declarations at
parse time, wrapping statements and expressions in TopLevelCodeDecls,
so the primary API for getting the top-level entities in source files
is based on getting declarations.

Start generalizing the representation by storing ASTNode instances at
the top level, rather than declaration pointers, updating many (but
not all!) uses of this API. The walk over declarations is a (cached)
filter to pick out all of the declarations. Existing parsed files are
unaffected (the parser still creates top-level code declarations), but
the new "macro expansion" source file kind skips creating top-level
code declarations so we get the pure parse tree. Additionally, some
generalized clients (like ASTScope lookup) will now look at the list
of items, so they'll be able to walk into statements and expressions
without the intervening TopLevelCodeDecl.

Over time, I'd like to phase out `getTopLevelDecls()` entirely,
relying on the new `getTopLevelItems()` for parsed content. We can
introduce TopLevelCodeDecls more lazily for semantic walks.
2022-11-01 08:04:15 -07:00
Hamish Knight
b645e63ce5 [AST] NFC: Refactor GenericTypeParamDecl construction
Add distinct overloads for the parser,
deserialization and code synthesis.
2022-10-14 15:40:12 +01:00
Holly Borla
c4b946195e [AST] Replace the "type sequence" terminology with "parameter pack". 2022-10-10 16:28:13 -07:00
Alastair Houghton
d092d4bb66 [Threading][Tests] Don't test timeouts on threading=none.
The preprocessor condition stopping tests from running for threading=none
was in slightly the wrong place.

rdar://100707643
2022-10-03 09:26:25 +01:00
Alastair Houghton
d0f42cad11 [Threading][Win32] Fix the wait functions for Win32 to always over-wait.
Rather than bodging the test to make it more robust, fix the functions
in the Threading layer to behave the same as they do on other platforms,
i.e. to guarantee that they always wait *at least* the amount of time
you asked for.

rdar://100236038
2022-09-29 17:01:59 +01:00
Alastair Houghton
10ab608707 [UnitTests][Threading] Tweak ConditionVariable test for Windows.
Windows' behaviour wrt `Sleep` family functions can be odd.  Apparently,
if you specify a time lower than a system tick, they can return early.
This makes the test flaky when it shouldn't be.  To fix it, we use the
Multimedia functions to adjust the system tick count as low as we can
get it.

rdar://100236038
2022-09-29 15:41:38 +01:00
Alastair Houghton
4495d63c12 [Threading] Add ConditionVariable support.
Swift Concurrency would like to be able to use condition variables.
Add support to the threading packages.

rdar://100236038
2022-09-27 16:21:13 +01:00
Josh Soref
436484c8c8 Gardening: Fix spelling mistakes in */SourceKit
* about
* and
* answering
* because
* before
* cancellation
* clear
* comment
* complete
* corresponding
* cursor
* custom
* dependencies
* doesn't
* expression
* extension
* immediately
* implementation
* implicit
* innovation
* intentionally
* occasionally
* oldest
* parameter
* property
* response
* reuseastcontext
* snapshot
* sourcekit_swift_runtime_link_flags
* synchronously
* target
* that
* unlabeled
* usefulness
* work

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-09-21 02:03:25 -04:00
Robert Widmann
3764ef8a9a Drop libSyntax's Unit Tests
We no longer intend to support the libSyntax AST, so let's drop
the tests that are only going to get in the way of us iterating
on the Swift Syntax tree.
2022-09-14 23:16:08 -07:00
Robert Widmann
86ee409675 Update Unit Tests for Function Parameter Syntax Change
This broke in https://github.com/apple/swift-syntax/pull/793 when
I updated the function parameter declaration representation to
include isolated and const.
2022-09-14 18:33:11 -07:00
Robert Widmann
18b79ffcfd Resolve a Layering Violation in libBasic
Basic should not be allowed to link Parse, yet it was doing so
to allow Version to provide a constructor that would conveniently
parse a StringRef. This entrypoint also emitted diagnostics, so it
pulled in libAST.

Sink the version parser entrypoint down into Parse where it belongs
and point all the clients to the right place.
2022-09-09 00:21:30 -07:00
Slava Pestov
046c2040ce Merge pull request #60726 from slavapestov/variadic-generics-bits
AST: Plumbing for pack conformances and a few other variadic generics bits
2022-08-24 08:59:40 -04:00
Artem Chikin
7d94c24123 Merge pull request #60712 from artemcm/RemoveRedundantScanCommandCombo
[Dependency Scan] Remove redundant recombination of arguments in 'initCompilerInstanceForScan' into a string, before being re-parsed.
2022-08-23 12:57:11 -07:00
Slava Pestov
7a16b0275b AST: Allow one-element tuple types to be constructed
These will never appear in the source language, but can arise
after substitution when the original type is a tuple type with
a pack expansion type.

Two examples:
- original type: (Int, T...), substitution T := {}
- original type: (T...), substitution T := {Int}

We need to model these correctly to maintain invariants.

Callers that previously used to rely on TupleType::get()
returning a ParenType now explicitly check for the one-element
case instead.
2022-08-23 11:12:00 -04:00
Artem Chikin
baec3154a0 [Dependency Scan] Remove redundant recombination of arguments in 'initCompilerInstanceForScan' into a string, before being re-parsed.
This does not seem to serve a purpose other than corrupting arguments with whitespaces - they get merged into one large string where the whitespace boundary between arguments and whitespaces within arguments are blurred.

Part of rdar://98985453
2022-08-22 16:12:58 -07:00
Pavel Yaskevich
5a164c5f8a [Frontend] Switch from YAML to .strings based localization 2022-08-22 10:23:06 -07:00
Alex Hoppen
e22e443596 [SourceKit] Re-enable cancellation of non-completion requests
This enables the ability to cancel requests, which aren’t code completion requests, again.

Previous crashes in SILGen are prevented by disabling cancellation during the SIL stages. Instead, we add dedicated cancellation checkpoints before and after SIL.

rdar://98390926
2022-08-16 16:02:23 +02:00
Rintaro Ishizaki
85ea21cf2b Merge pull request #60563 from rintaro/no-garbage-in-swift
Terminology change: 'garbage' -> 'unexpected'
2022-08-15 17:18:42 -07:00
Rintaro Ishizaki
a673043737 Terminology change: 'garbage' -> 'unexpected'
There are no "garbage" characters in Swift code. They are just
"unexpected."
2022-08-15 14:32:28 -07:00
swift-ci
a760571edb Merge remote-tracking branch 'origin/main' into rebranch 2022-08-04 09:13:27 -07:00
Alex Hoppen
c2695f0ffc [libSyntax] Allow adding garbage nodes in between any two children of a syntax node
When the source code is invalid, this allows us to represent tokens that could not be used to form a valid syntax tree with more fidelity.

This commit does not start using GarbageNodes yet, it just sets everything up for them.
2022-08-04 09:20:31 +02:00
swift-ci
efdf3b5ff9 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-20 16:15:13 -07:00
Doug Gregor
3e53290187 Merge pull request #60052 from DougGregor/syntax-decl-cleanup
[Syntax] Clean up syntax grammar for declaration nodes
2022-07-20 16:09:28 -07:00
swift-ci
8771684a28 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-14 02:13:20 -07:00
Doug Gregor
73debb48f3 [Syntax] Factor out the detail for a declaration modifier. 2022-07-13 21:49:23 -07:00
Erik Eckstein
6760dc420c SIL: add a utility which can manage per-value and per-instruction bitfields and flags efficiently.
It's used to implement `InstructionSet` and `ValueSet`: sets of SILValues and SILInstructions.
Just like `BasicBlockSet` for basic blocks, the set is implemented by setting bits directly in SILNode.
This is super efficient because insertion and deletion to/from the set are basic bit operations.

The cost is an additional word in SILNode. But this is basically negligible: it just adds ~0.7% of memory used for SILInstructions.
In my experiments, I didn't see any relevant changes in memory consumption or compile time.
2022-07-13 14:27:50 +02:00
swift-ci
80161c6d49 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-11 11:53:51 -07:00
Robert Widmann
003b362a65 Differentiate Shebang from Garbage
Add #! as an explicit kind of trivia.
2022-07-08 18:28:57 -07:00
swift-ci
83a6161e32 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-08 14:13:45 -07:00
Robert Widmann
e2bb54fcb5 Remove Modeling for Fully-Generic Primary Associated Type Syntax
Constraints in these positions were not accepted. Remove the modeling
for them.
2022-07-08 10:51:25 -07:00
swift-ci
eec184df23 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-07 02:14:43 -07:00
Yuta Saito
356156dfb9 [Threading][unittest] skip try_lock checks under none threading 2022-07-07 01:57:38 +00:00
Alastair Houghton
14e01b015a [Threading][UnitTests] Don't use threads in the unit test in no-threads mode.
If the threading package is set to "none", don't actually use threads in the
unit tests.

rdar://95011060
2022-07-07 01:57:38 +00:00
swift-ci
a9ee4f4a90 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-05 13:14:44 -07:00
Doug Gregor
3c892a153c Update runtime compatibility hooks to version 5.8 2022-07-05 10:07:52 -07:00
swift-ci
e720aaef9d Merge remote-tracking branch 'origin/main' into rebranch 2022-06-30 20:53:40 -07:00
Robert Widmann
19b27c5eb7 Merge pull request #59763 from CodaFi/mangolia 2022-06-30 20:46:38 -07:00
swift-ci
3e99d630a5 Merge remote-tracking branch 'origin/main' into rebranch 2022-06-30 15:53:44 -07:00
Robert Widmann
dde0d8f609 Generalize the Mangling of Constrained Existential Types
Upgrade the old mangling from a list of argument types to a
list of requiremnets. For now, only same-type requirements
may actually be mangled since those are all that are available
to the surface language.

Reconstruction of existential types now consists of demangling (a list of)
base protocol(s), decoding the constraints, and converting the same-type
constraints back into a list of arguments.

rdar://96088707
2022-06-30 15:32:37 -07:00
Augusto Noronha
6a82edd366 Fix nested generic typerefs applying generic params at the wrong level
Generic params of typerefs are supposed to be "attached" on the level
they belong, not as a flat list, unlike other parts of the system. Fix
the application of bound generic params by checking how many were
already applied in the hierarchy and ignoring those already attached.
2022-06-22 16:33:38 -07:00
swift-ci
750a3dc7e6 Merge remote-tracking branch 'origin/main' into rebranch 2022-06-15 08:14:55 -07:00
Mike Ash
30cb7a20c3 Merge pull request #59349 from mikeash/concurrency-tracing-log-categories
[Concurrency] Set final subsystem/categories for concurrency tracing.
2022-06-15 11:14:25 -04:00
Mike Ash
72499c5753 [Concurrency] Set final subsystem/categories for concurrency tracing. 2022-06-13 11:36:09 -04:00
Ben Barham
0d96000b94 [next] Add missing chrono include
`std::chrono::high_resolution_clock` is being used in
`FrozenMultiMapTest.cpp` but it was relying on `chrono` being included
transitively. Include it directly.
2022-06-09 12:50:01 -07:00
Alastair Houghton
6962758c8c [Threading] Add the ability to use any C++ callable in swift::once().
This allows the use of C++ lambdas and functors, in addition to plain
old functions.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
0e9318cec5 [Threading] Put everything through git clang-format.
Just formatting changes.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
210b772800 [UnitTests][Windows] Link with Synchronization.lib
The runtime unit tests also need to link with Synchronization.lib.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
3bfc7e0731 [Threading][Windows] Link the unit test against Synchronization.lib
We need to link the threading unit test against Synchronization.lib
to pick up the Win32 APIs we're using.

rdar://90776105
2022-06-07 07:39:52 +01:00
Alastair Houghton
6d1b6dbd1c [Threading] Fix the Linux build.
A few fixes specifically for the Linux build.

rdar://90776105
2022-06-07 07:39:52 +01:00