Commit Graph

1894 Commits

Author SHA1 Message Date
Joe Groff
8242110bbe Merge pull request #76831 from jckarter/builtin-vector
Builtin.FixedArray
2024-10-23 05:20:21 -10:00
Joe Groff
a184782a38 Introduce a Builtin.FixedArray type.
`Builtin.FixedArray<let N: Int, T: ~Copyable & ~Escapable>` has the layout of `N` elements of type `T` laid out
sequentially in memory (with the tail padding of every element occupied by the array). This provides a primitive
on which the standard library `Vector` type can be built.
2024-10-22 16:21:45 -07:00
Allan Shortlidge
b346385544 AST: Refactor AvailabilityContext into a value type.
Make the pointer to uniqued storage an implementation detail of an
`AvailabilityContext` value. This way clients of `AvailabilityContext` don't
need to think about pointers and can have access to mutating operations on a
context when appropriate.
2024-10-21 15:16:08 -07:00
Allan Shortlidge
0730209302 AST: Move AvailabilityContext into its own header and cpp file. 2024-10-21 15:16:08 -07:00
Allan Shortlidge
439c5951ec AST: Introduce AvailabilityContext.
This class is designed to be a compact representation of the active
availability constraints in a specific scope. For now, it only models platform
introduction availability but it will soon be updated to cover additional
availability constraints, like platform unavailability.

In anticipation of needing to reference `AvailabilityContext`s from
`TypeRefinementContext`s and increasing memory requirements for these contexts,
a cache of uniqued instances of `AvailabilityContext` are stored in a
`llvm::FoldingSet` on `ASTContext`.
2024-10-17 11:26:28 -07:00
Egor Zhdan
3a200deee9 [cxx-interop] Add UnsafeCxxContiguousIterator & UnsafeCxxMutableContiguousIterator protocols
This adds a pair of Swift protocols that represents C++ iterator types conforming to `std::contiguous_iterator_tag` requirements. These are random access iterators that guarantee that the values are stored in consequent memory addresses.

This will be used to optimize usage of C++ containers such as `std::vector` from Swift, for instance, by providing an overload of `withContiguousStorageIfAvailable` for contiguous containers.

rdar://137877849
2024-10-15 14:30:09 +01:00
Alexis Laferrière
ff803c6df1 Sema: Move the availability macros cache to the ASTContext
The availability macros definitions are parsed from the command line and
stored in a cache. The cache was in the Parser, which would have it be
computed for each file using availability macros. Let's move it to the
ASTContext instead where it can generally be computed once per invocation
and used across the module.

rdar://134797088
2024-10-01 09:07:56 -07:00
Steven Wu
82c9fdf68b [Blocklist] Make sure blocklist config is read through VFS
Make sure block-list file is read through VFS so CASFS can be used to
read the configuration to ensure sound caching, and also the path of the
blocklist can be canonicalized via path remapping.
2024-09-26 17:02:10 -07:00
Slava Pestov
c77fae3a2d Basic: Add -fine-grained-timers flag
By default, -stats-output-dir does not collect per-request timers and
counters, because of overhead.
2024-09-23 18:04:25 -04:00
Doug Gregor
49aa0e966f Ensure that SourceFiles always have a backing buffer in the SourceManager
The "buffer ID" in a SourceFile, which is used to find the source file's
contents in the SourceManager, has always been optional. However, the
effectively every SourceFile actually does have a buffer ID, and the
vast majority of accesses to this information dereference the optional
without checking.

Update the handful of call sites that provided `nullopt` as the buffer
ID to provide a proper buffer instead. These were mostly unit tests
and testing programs, with a few places that passed a never-empty
optional through to the SourceFile constructor.

Then, remove optionality from the representation and accessors. It is
now the case that every SourceFile has a buffer ID, simplying a bunch
of code.
2024-09-16 21:46:42 -07:00
Doug Gregor
b597f6bed4 Consolidate get(Opaque|Opened)TypeArchetypeProperties into archetypeProperties() 2024-09-09 13:02:49 -07:00
Augusto Noronha
5f851b664d Merge pull request #76065 from augusto2112/clash-abi-name-demangler
Account for multiple modules when looking up the DeclContext of a type
2024-09-06 14:22:24 -07:00
Alejandro Alonso
71fee06c9a Requestify GTPD::getValueType 2024-09-04 15:13:46 -07:00
Slava Pestov
b9b6bb7b69 AST: Introduce new kind of sugared GenericTypeParamType
This one just stores an identifier instead of a declaration.
2024-09-04 15:13:46 -07:00
Alejandro Alonso
f4f60f4344 Remove Value requirement Add GenericTypeParamKind 2024-09-04 15:13:43 -07:00
Alejandro Alonso
7c85261a77 Add runtime support 2024-09-04 15:13:27 -07:00
Alejandro Alonso
75c2cbf593 Implement value generics
Some requirement machine work

Rename requirement to Value

Rename more things to Value

Fix integer checking for requirement

some docs and parser changes

Minor fixes
2024-09-04 15:13:25 -07:00
Slava Pestov
abb8e8feb1 AST: Remove old form of getOpenedExistentialSignature() 2024-09-04 10:42:19 -04:00
Slava Pestov
dbda573e88 AST: Remove OpenedArchetypeType::getSelfInterfaceTypeFromContext() 2024-09-04 10:42:19 -04:00
Slava Pestov
c47f352df7 AST: Use new form of getOpenedExistentialSignature() in GenericEnvironment::forOpenedExistential() 2024-09-04 10:42:18 -04:00
Slava Pestov
3f317a10fc Merge pull request #76216 from slavapestov/existential-signature-rework-part-2
Convert more callers to use new form of ASTContext::getOpenedExistentialSignature()
2024-09-03 23:22:00 -04:00
Augusto Noronha
141c96fee1 Account for multiple modules when looking up the DeclContext of a type
When looking up the decl context of a type, ASTDemangler has to take
into account that there are multiple different modules where that type
could've come from. This is due to two facts:

- Thanks to the `-module-abi-name` flag, multiple modules can share
the same ABI name (which is the module name that is usually used when
mangling a type).
- In some situations mangling can use the module's real name, for
example, when mangling for the debugger or USRs coupled with @_originallyDefinedIn.

rdar://134095412
2024-09-03 16:44:41 -07:00
Slava Pestov
e3ff6f0697 AST: Fiddle with GenericEnvironment::forOpenedExistential() again 2024-09-03 17:31:26 -04:00
Allan Shortlidge
3f626f50fe Merge pull request #76203 from tshortli/availability-context-cleanup
AST: Clean up `AvailabilityContext` and uses
2024-09-03 09:42:25 -07:00
Slava Pestov
ba585fd6c0 Merge pull request #76206 from slavapestov/existential-signature-rework-part-1
AST: Add new implementation of getOpenedExistentialSignature()
2024-09-03 10:05:29 -04:00
Allan Shortlidge
89ea92d550 AST: Introduce ASTContext::getTargetPlatformStringForDiagnostics().
NFC.
2024-09-02 18:24:31 -07:00
Egor Zhdan
39b8b3c67e Merge pull request #76106 from swiftlang/egorzhdan/cxx-mutable-rac
[cxx-interop] Add `CxxMutableRandomAccessCollection` protocol
2024-09-02 11:35:43 +01:00
Slava Pestov
cf0fdc0917 AST: Add new implementation of getOpenedExistentialSignature()
This will replace all existing usages of the old implementation.
2024-09-01 18:03:26 -04:00
Egor Zhdan
0ab681514b [cxx-interop] Add CxxMutableRandomAccessCollection protocol
This conforms mutable C++ container types, such as `std::vector`, to `MutableCollection` via a new overlay protocol `CxxMutableRandomAccessCollection`.

rdar://134531554
2024-08-28 12:43:42 +01:00
Steven Wu
7ed9a52633 [PrefixMap] Remap clang cc1 args when building swift interfaces
Fix a bug that swift clang importer is not setup correctly when prefix
map is used. There are two separate issues:
* CC1 args used to setup clang import when building swift (interface and
  sources) are not correctly remapped.
* When loading SDKInfo from SDK path, the SDKSettings.json is not
  loading from VFS, thus the file cannot be loaded from remapped path.

rdar://134458611
2024-08-23 10:32:20 -07:00
Slava Pestov
e9b6f0b82d AST: Remove OpenedArchetypeType::get() overload taking an interface type 2024-08-21 19:47:30 -04:00
Slava Pestov
ae77d6f0c1 AST: Replace one-off predicates with SubstitutionMap::getRecursiveProperties() 2024-08-21 13:19:10 -04:00
Slava Pestov
43c33d78b3 AST: Calculate recursive properties for opened existential types 2024-08-20 16:54:51 -04:00
Slava Pestov
5577f27661 AST: Opened existential environments store outer substitutions 2024-08-20 16:54:51 -04:00
Slava Pestov
b434c9fb56 Merge pull request #75984 from slavapestov/clean-up-opened-archetype
Clean up OpenedArchetypeType construction and more
2024-08-20 16:52:55 -04:00
Slava Pestov
ff308e9510 AST: Remove TypeBase::openAnyExistentialType() 2024-08-20 12:15:27 -04:00
Slava Pestov
0c2f28fd3d AST: Remove GenericSignature parameter from OpenedArchetypeType::get() 2024-08-20 12:15:27 -04:00
Doug Gregor
39f1e97bf9 [Safe mode] Diagnose uses of declarations involving unsafe types
When referencing a declaration, check whether any of the types in that
reference are unsafe. This can diagnose cases where the original
declaration either wasn't actually unsafe, or is being provided with
unsafe types via generics.
2024-08-19 14:33:09 -07:00
Slava Pestov
375363a473 AST: Move global conformance lookup entry points to ConformanceLookup.h 2024-08-08 23:35:58 -04:00
Doug Gregor
cfd0a3fc53 Thread a source location through canImport evaluation in CompilerBuildConfiguration
Unlike all of the other build configuration checks, `canImport` has
side effects including the emission of various diagnostics. Thread a
source location through here so the diagnostics end up on the right
line.
2024-08-04 05:58:53 -07:00
Allan Shortlidge
4224479a43 NFC: Update stale references to next(_:).
In the accepted proposal for SE-0421, `next(_:)` became `next(isolation:)`.
Some of the references to that method in the codebase need to be updated
accordingly.
2024-07-30 09:47:20 -07:00
Allan Shortlidge
6fb6a56b20 SILGen: Introduce macCatalyst support for if #available.
Upstream the necessary changes to compile `if #available` queries correctly
when a `macabi` target triple or a `-target-variant` is specified.
2024-07-23 17:00:10 -07:00
smonteiro2
684e9ebf0c [cxx-interop] Implements CxxMutableSpan, created from an UnsafeMutableBufferPointer
* Added tests for generic functions
* Add some tests for mutable spans
* Initialize ConstSpan from UnsafeMutableBufferPointer
* Change hardening flag
2024-07-19 10:38:52 +01:00
Kavon Farvardin
b02b94cd52 NCGenerics: handle failure to load stdlib
The stdlib module can end up being a non-null ModuleDecl that contains
no files, due to a failure to load the stdlib.

In such an unusual case, fall-back to synthesizing Copyable/Escapable
into the Builtin module so that Sema can proceed.

rdar://129092011
2024-07-12 15:48:40 -07:00
Allan Shortlidge
14200e412c SILGen/stdlib: Remove _diagnoseUnavailableCodeReached_aeic().
It should no longer be necessary to provide an `@_alwaysEmitIntoClient` version
of `_diagnoseUnavailableCodeReached()`. This workaround was originally added to
provide compatibility with projects that were misconfigured to compile against
a newer stdlib but link against an older one.

Resolves rdar://119892482.
2024-07-11 14:53:03 -07:00
Andrew Trick
12acde2215 Merge pull request #75096 from meg-gupta/lifetimedeparg
Add support for lifetime dependence in parameter position
2024-07-10 22:56:23 -07:00
Meghana Gupta
154989463b Add support for lifetime dependence in parameter position 2024-07-10 14:20:03 -07:00
Slava Pestov
26fffae30a AST: Simplify SubstitutionMap representation
There was a bunch of logic to lazily populate replacement types
corresponding to reducible generic parameters. This didn't seem
to have a clear purpose so let's remove it.
2024-07-10 13:28:26 -04:00
Slava Pestov
a5ee9ad3d5 AST: Dump more stuff with -analyze-request-evaluator 2024-07-09 21:29:12 -04:00
Slava Pestov
7ba2b76966 Basic: Add -analyze-request-evaluator flag to dump request cache statistics 2024-07-06 23:35:39 -04:00