Commit Graph

84 Commits

Author SHA1 Message Date
Venkatesh Sriram
aa498087ac Merge pull request #78462 from venkatesh5789/partial-keypath-extraction
[Compile Time Constant Extraction] Extract Partial Keypath Expressions
2025-01-09 11:11:07 +05:30
Allan Shortlidge
680bb5b05b ConstExtract: Adopt SemanticAvailableAttr more thoroughly. 2025-01-07 07:31:29 -08:00
Venkatesh Sriram
14a5207f48 [Compile Time Constant Extraction] Extract Partial Keypath Expressions 2025-01-07 16:46:05 +05:30
Allan Shortlidge
887bc1124f ConstExtract: Adopt Decl::getSemanticAvailableAttrs(). 2024-12-19 08:40:00 -08:00
Kuba Mracek
6f4ae28520 [ASTMangler] Pass ASTContext to all instantiations of ASTMangler 2024-12-02 15:01:04 -08:00
Venkatesh Sriram
0d9e62e143 Merge pull request #76917 from venkatesh5789/external-conformance-info
[Compile Time Constant Extraction] Add information about where a particular conformance has been defined
2024-10-17 10:19:07 -07:00
Venkatesh Sriram
9ca55fdf89 [Compile Time Constant Extraction] Add information about where a particular conformance has been defined 2024-10-15 15:46:21 -07:00
James Paolantonio
5e1de491b6 [Const extract] Extract static function calls (#76251)
Co-authored-by: James Paolantonio <j_paolantonio@apple.com>
2024-10-10 09:59:20 -04:00
Venkatesh Sriram
f04486db3e [Compile Time Constant Extraction] Extract listed Availability Attributes for buildLimitedAvailability in Result Builders 2024-09-26 14:14:10 -07:00
Venkatesh Sriram
82f85d83c2 Merge pull request #75219 from venkatesh5789/result-builder-extraction
[Compile Time Constant Extraction] Extract Result Builder Expressions
2024-07-24 18:27:17 -07:00
Venkatesh Sriram
4c3439f942 [Compile Time Constant Extraction] Extract Result Builder Expressions 2024-07-24 10:08:24 -07:00
Artem Chikin
3e8e44d34e Merge pull request #74698 from artemcm/ConstExtractConformanceExtractionFix
[Compile Time Constant Extraction] Query nominal type *conformances* to get at the protocols, instead of `getAllProtocols()`.
2024-06-27 09:56:27 -07:00
Venkatesh Sriram
465634cada Merge pull request #74491 from venkatesh5789/interpolated-string-extraction
[Compile Time Constant Extraction] Extract Interpolated String Literals
2024-06-26 10:34:42 -07:00
Artem Chikin
1be5dbba38 [Compile Time Constant Extraction] Ensure macro-expanded declarations are visited in WMO
Resolves rdar://130036855
2024-06-25 14:23:41 -07:00
Artem Chikin
f5f0c0043d [Compile Time Constant Extraction] Query nominal type conformances to get at the protocols, instead of getAllProtocols.
As it stands, for extension macros which add protocol conformances, the list of protocols specified on the macro's 'conformances:' parameter gets added in its entirety to the list of a nominal type's protocols in 'ConformanceLookupTable::addMacroGeneratedProtocols'. Whereas the macro itself, may only add *some* of the specified conformances. This means that `getAllProtocols` may contain a super-set of protocols captured in `getAllConformances`, some of which may not actually be generated by the macro.

This change narrowly fixes ConstExtract to query actual generated conformances. Though, potentially we should make 'ConformanceLookupTable::addMacroGeneratedProtocols' behave in a way that reflects the protocols the macro actually adds the conformances to, instead of the ones it may add conformances to.

Resolves rdar://130316531
2024-06-25 12:29:29 -07:00
Venkatesh Sriram
9820865a80 [Compile Time Constant Extraction] Extract Interpolated String Literals 2024-06-25 11:11:20 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Venkatesh Sriram
a0d62d972e Merge pull request #73718 from venkatesh5789/keypath-extraction
[Compile Time Constant Extraction] Extract KeyPath Expressions
2024-05-23 10:01:36 -07:00
Venkatesh Sriram
6e797f5047 [Compile Time Constant Extraction] Extract KeyPath Expressions 2024-05-22 11:24:48 -07:00
James Paolantonio
b37640800c Remove duplicate hasAttachedPropertyWrapper check (#73456)
Co-authored-by: James Paolantonio <j_paolantonio@apple.com>
2024-05-08 11:35:55 -04:00
artemcm
486654eb58 [Const Extract] Extract property wrapper details even when no default init is present 2024-04-25 11:42:51 -07:00
Apollo Zhu
708fb13c5b Extract decl in macro added extensions 2024-03-18 22:58:17 -07:00
Slava Pestov
37dbd05354 ConstExtract: Update for noncopyable generics (sort of) 2024-03-01 11:05:54 -05:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Apollo Zhu
9f9b3abeaa [Compile Time Constant Extraction] Extract from macro expansions
Fix logic for @_objcImplementation
2023-12-06 16:08:02 -08:00
Apollo Zhu
a8fd83703b Allow extractConstantsFromMembers on all nominal decls 2023-11-30 18:35:17 -08:00
Zhiyu Zhu/朱智语
6d3017cde3 [Compile Time Constant Extraction] Extract from extensions of types not declared in the same file/module (#70081)
Resolves rdar://118904022
2023-11-29 09:07:52 -08:00
Zhiyu Zhu/朱智语
9d1a92eb72 [Compile Time Constant Extraction] Add @extractConstantsFromMembers (#69944)
Add @extractConstantsFromMembers attribute under ExtractConstantsFromMembers experimental feature flag
2023-11-29 08:49:57 -08:00
Doug Gregor
236418dbf8 Make the "typechecked function body" request more central and resilient
The "typechecked function body" request was defined to type-check a
function body that is known to be present, and not skipped, and would
assert these conditions, requiring its users to check whether a body
was expected. Often, this means that callers would use `getBody()`
instead, which retrieves the underlying value in whatever form it
happens to be, and assume it has been mutated appropriately.

Make the "typechecked function body" request, triggered by
`getTypecheckedBody()`, more resilient and central. A `NULL` result is
now acceptable, signifying that there is no body. Clients will need to
tolerate NULL results.

* When there is no body but should be one, produce an appropriate
error.
* When there shouldn't be a body but is, produce an appropriate error
* Handle skipping of function bodies here, rather than elsewhere.

Over time, we should move clients off of `getBody` and `hasBody`
entirely, and toward `getTypecheckedBody` or some yet-to-be-introduced
forms like `getBodyAsWritten` for the pre-typechecked body.
2023-11-26 09:09:29 -08:00
Artem Chikin
faa9751c37 [Compile Time Constant Extraction] Emit underlying types for typealias types
Resolves rdar://113402135
2023-08-18 10:44:46 -07:00
Pavel Yaskevich
b21e8426a0 [AST] NFC: Remove @runtimeMetadata related code 2023-08-15 12:16:40 -07:00
Slava Pestov
9ebb5f2e03 AST: Rename VarDecl::getType() to VarDecl::getTypeInContext()
This is a futile attempt to discourage future use of getType() by
giving it a "scary" name.

We want people to use getInterfaceType() like with the other decl kinds.
2023-08-04 14:19:25 -04:00
Artem Chikin
f39d62f65d Merge pull request #67692 from artemcm/ConstExtractPrintTypesOutOfContext
[Compile Time Constant Extraction] Map types with archetypes out of context, before mangling them for printing.
2023-08-03 11:08:58 -07:00
Artem Chikin
8fb4294507 [Compile Time Constant Extraction] Map types with archetypes out of context, before mangling them for printing.
Matching logic in the ASTPrinter. Otherwise we attempt to mangle types with archetypes in them, which cannot be done, and causes the compiler to crash.

Resolves rdar://113039215
2023-08-02 17:37:59 -07:00
Artem Chikin
0ea41efded [Compile Time Constant Extraction] Deprecated extraction of property mangled
names. It can often be more complex than the code can currently handle (e.g.
properties whose types include archetypes), and we
do not have a good motivating use-case to extract them.

Resolves rdar://113039215
2023-08-01 15:52:52 -07:00
Artem Chikin
72ed4e37ff [Compile Time Constant Extraction] Refactor collection of opaque type requirements
To reduce duplication of logic with other parts of the compiler, instead of destructuring the constraint type, write the requirements in the opaque type declaration's generic signature.
2023-06-30 11:02:24 -07:00
Slava Pestov
5ce14265e4 Fix some random compiler warnings 2023-06-29 16:29:10 -04:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Artem Chikin
9a11e048e5 Merge pull request #66639 from artemcm/ConstExtractConformanceInfo
[Compile Time Constant Extraction] Add extraction of all conformances and type aliases of applicable nominal types
2023-06-23 08:35:11 -07:00
Artem Chikin
3f0c0f0553 [Compile Time Constant Extraction] Add extraction of all conformances and type aliases of applicable nominal types
This change adds to the extracted type metadata the following fields:
- Conformances: this is a list of all protocols that the given nominal type conforms to
- associated type aliases: this is a list of all associated types across all conformances that the given nominal type substitutes with concrete types. For a given associated type, we gather:
  - Associated type name
  - Substituted type's fully-qualified name
  - Substituted type's mangled name
  - If the substituted type is opaque:
    - List of conformance requirements of this opaque type
    - List of same-type requirements of this opaque type
2023-06-22 07:13:24 -07:00
Steven Wu
8fb0d5f803 Virtualize swiftconstvalues output
Virtualize swiftconstvalues output so it can be cached inside CAS.
2023-06-12 13:22:10 -07:00
Artem Chikin
79073edb5b [Compile Time Constant Extraction] Extract the instance type for type values - not the metatype
The intended design is to extract actual types of type values appearing in conformance properties, whereas the original extraction code-path queried and recorded the type values' types - their metatypes.

Resolves rdar://108609420
2023-04-27 08:11:38 -07:00
James Paolantonio
bb2a2e8efe [Compile Time Constant Extraction] Look through InjectIntoOptionalExpr (#64416) 2023-03-16 15:42:22 -04:00
Artem Chikin
87f1c2f6bd [Compile Time Constant Extraction] Extract mangled names for Type values
Resolves rdar://106151566
2023-03-06 17:47:55 -03:00
swift-ci
03b7ad6b33 Merge pull request #64004 from artemcm/ConstExtractFixes
[Compile Time Constant Extraction] Look through Optional injection and underlying-to-opaque conversions
2023-03-02 11:30:03 -08:00
Artem Chikin
76b9281fac [Compile Time Constant Extraction] Handle expression-less default argument expressions
Resolves rdar://106006282
2023-03-02 08:48:28 -08:00
Artem Chikin
86b8ca6f91 [Compile Time Constant Extraction] Look through underlying-to-opaque conversions
Resolves rdar://106006689
2023-03-01 11:01:34 -08:00
Artem Chikin
ee9b4766ad [Compile Time Constant Extraction] Extract InjectIntoOptional arguments
Resolves rdar://106059663
2023-03-01 09:22:45 -08:00
Doug Gregor
200f2340d9 [Macros] Be deliberate about walking macro arguments vs. expansions
Provide ASTWalker with a customization point to specify whether to
check macro arguments (which are type checked but never emitted), the
macro expansion (which is the result of applying the macro and is
actually emitted into the source), or both. Provide answers for the
~115 different ASTWalker visitors throughout the code base.

Fixes rdar://104042945, which concerns checking of effects in
macro arguments---which we shouldn't do.
2023-02-28 17:48:23 -08:00
James Paolantonio
9e94cb9c6e [Compile Time Constant Extraction] Extract Types (#63820) 2023-02-23 13:18:35 -05:00