Commit Graph

58 Commits

Author SHA1 Message Date
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
Ellie Shin
37af51dc4c Merge branch 'main' into es-pkg-acl 2023-01-19 16:18:17 -08:00
Ellie Shin
1c66d02f92 Add package access level to enum AccessLevel
Resolves rdar://104198440
2023-01-19 15:54:18 -08:00
Doug Gregor
76e0d5e726 [Macro] API digester support for macro declarations 2023-01-02 21:22:05 -08:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Allan Shortlidge
0d37f52fe0 APIDigester: Break cycle between Frontend and APIDigester targets.
Also push a utility that was previously on `SILDeclRef` down to AST so that the SIL dependency can be removed entirely from APIDigester.
2022-10-26 20:30:36 -07:00
Hamish Knight
4716f61fba [AST] Introduce explicit actions for ASTWalker
Replace the use of bool and pointer returns for
`walkToXXXPre`/`walkToXXXPost`, and instead use
explicit actions such as `Action::Continue(E)`,
`Action::SkipChildren(E)`, and `Action::Stop()`.
There are also conditional variants, e.g
`Action::SkipChildrenIf`, `Action::VisitChildrenIf`,
and `Action::StopIf`.

There is still more work that can be done here, in
particular:

- SourceEntityWalker still needs to be migrated.
- Some uses of `return false` in pre-visitation
methods can likely now be replaced by
`Action::Stop`.
- We still use bool and pointer returns internally
within the ASTWalker traversal, which could likely
be improved.

But I'm leaving those as future work for now as
this patch is already large enough.
2022-09-13 10:35:29 +01:00
Slava Pestov
f0907d3e10 APIDigester: Stop calling getAllConformances() on protocols 2022-08-23 00:03:36 -04:00
Hamish Knight
6e51841d14 [AST] Enforce that composeTuple drops parameter flags
Callers may either assert that the parameter flags
are empty, or ask for them to be dropped.
2022-08-02 13:56:31 +01:00
Xi Ge
2fba124779 ABIChecker: diagnose removal of deprecated symbols by default
rdar://95385661
2022-06-17 10:37:28 -07:00
Xi Ge
0567a9b142 ABI checker: include SPI group names in ABI descriptor files 2022-06-04 21:45:14 -07:00
Xi Ge
e46b5f5966 ABIChecker: for decls with @_originallyDefinedIn, use original module names in ABI descriptors
rdar://93615410
2022-06-03 22:41:43 -07:00
Xi Ge
7bab30c718 ABIChecker: diagnose moving a non-final member from a class to an extension to the class
rdar://93498817
2022-06-03 12:54:41 -07:00
Xi Ge
26952f74de ABI checker: include a field to indicate whether a decl is from extension 2022-06-03 12:54:11 -07:00
Luciano Almeida
8aa3c31231 [DeclCollector] Handle pound diagnostic decl in addMembersToRoot 2022-05-20 23:28:39 -03:00
Alexis Laferrière
a63f071ea2 [Serialization] Remove 'EnableSameSDKCheck' it's not needed with the soft-reject 2022-05-16 11:22:48 -07:00
Josh Soref
55d9c8353b Spelling apidigester (#42542)
* spelling: analyzer

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: considered

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: diagnostic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: inherited

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: interface

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: invoke

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: populating

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: referenced

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: requirement

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-22 18:53:51 -07:00
Xi Ge
6206d7cc9d sema: accept an array literal of enum case references as compile-time constant 2022-03-24 21:44:09 -07:00
Allan Shortlidge
1be8913c9b NFC: Fix a number of warnings emitted when building swift-frontend. 2022-03-04 16:15:33 -08:00
Xi Ge
e1aaee4fec Frontend: add a frontend flag to generate empty ABI descriptors to workaround deserialization issues
ABI descriptors should always be emitted as sidecars for library-evolution-enabled modules.
However, generating these files requires traversing the entire module (like indexing), which may
hit additional deserialization issues. To unblock builds, this patch introduces a flag to skip
the traversing logic so that we emit an empty ABI descriptor file. The empty file serves as
a placeholder so that build system doesn't need to know the details.
2022-02-23 23:18:20 -08:00
Xi Ge
0992e97e5e ConstValues: record the values of const variable references in the side-car file 2022-02-21 19:22:25 -08:00
Xi Ge
d7d3fe375a Merge pull request #41367 from nkcsgexi/set-up-payload-for-const
ABIChecker: teach ABI descriptor JSON to also keep track of constant values known at compile-time
2022-02-15 11:21:42 -08:00
Xi Ge
23556aee05 ABIChecker: teach ABI descriptor JSON to also keep track of constant values known at compile-time
Emitted at the emit-module step, ABI descriptor is of an entensible JSON format. This patch sets
up a segment in the file to also keep track of all compile-time constant values for other tools
to consume. As the initial step, we only keep track of string literals in the source files.
2022-02-13 21:32:21 -08:00
Slava Pestov
a1c03db381 AST: Generalize ProtocolDecl::getRequirementSignature() to a new RequirementSignature type
The RequirementSignature generalizes the old ArrayRef<Requirement>
which stores the minimal requirements that a conforming type's
witnesses must satisfy, to also record the protocol typealiases
defined in the protocol.
2022-02-13 00:24:23 -05:00
Xi Ge
3ef8165626 ABI checker: refactor the format of the ABI descriptor JSON to be more extensible. NFC 2022-02-12 14:39:51 -08:00
Holly Borla
6e6ca13268 [Type System] Use the constraint type of an existential type in
various places that expect ProtocolType or ProtocoolCompositionType.
2022-01-13 19:30:44 -08:00
Xi Ge
0dbcf79f29 ABI checker: check validity of extended nominals before continue
rdar://87150470
2022-01-10 12:26:58 -08:00
Doug Gregor
a5f676028b Eliminate remaining dependencies on a single underlying opaque type
The first generic parameter of an `OpaqueTypeDecl` was still being used
as the "underlying" interface type of the opaque type, which is
incorrect for both structural and named opaque result types. Eliminate
this notion, because the (declared) interface type already has the
correct structure.

Only ABI checking depended on the old "underlying" type, so rework it to
instead substitute into properly for structural opaque result types as
well.

Deserialization required a small adjustment to eliminate a cycle
because the interface type of an `OpaqueTypeDecl` involves opaque
archetype types, which reference the declaration itself... so
deserialize the interface type later, now that it's correct.
2022-01-04 11:55:42 -08:00
Doug Gregor
b60c88566f Fix serialization for structural opaque result types 2021-12-27 21:18:53 -08:00
Alex Hoppen
63c31033fc [Frontend] Load standard libarary in CompilerInstance::setup
Instead of checking that the stdlib can be loaded in a variety of places, check it when setting up the compiler instance. This required a couple more checks to avoid loading the stdlib in cases where it’s not needed.

To be able to differentiate stdlib loading failures from other setup errors, make `CompilerInstance::setup` return an error message on failure via an inout parameter. Consume that error on the call side, replacing a previous, more generic error message, adding error handling where appropriate or ignoring the error message, depending on the context.
2021-12-13 15:32:08 +01:00
Saleem Abdulrasool
349af3707d Merge pull request #40305 from compnerd/semitruck
gardening: make c++98-compat-extra-semi an error
2021-11-30 08:18:36 -08:00
Saleem Abdulrasool
910fbee14e gardening: make c++98-compat-extra-semi an error
This cleans up 90 instances of this warning and reduces the build spew
when building on Linux.  This helps identify actual issues when
building which can get lost in the stream of warning messages.  It also
helps restore the ability to build the compiler with gcc.
2021-11-27 11:40:17 -08:00
Becca Royal-Gordon
1880118e70 Restructure getDisplayDecl() Sendable forcing
Move this into a helper function that lives in Sema, avoiding libswiftAST calling into libswiftSema.
2021-11-19 17:51:27 -08:00
Artem Chikin
d2b062df49 Revert "ABI checker: use dedicated mangled name field to diagnose mangled name changes"
This reverts commit b937d0da86.
2021-10-25 11:02:21 -07:00
Xi Ge
b937d0da86 ABI checker: use dedicated mangled name field to diagnose mangled name changes 2021-10-21 10:51:19 -07:00
Xi Ge
5cf758d7ff ABI Checker: include mangled names in ABI descriptor files
Previously, we use USR as a delegate for mangled name. However, USR won't incorporate name changes made
by attributes like @_silgen_name. Instead, we should add a dedicated field for canonical mangled names.

rdar://84202064
2021-10-21 10:10:10 -07:00
Xi Ge
fee60ffd4f Revert "ABI Checker: include mangled names in ABI descriptor files"
This reverts commit a870b06055.
2021-10-21 10:09:49 -07:00
Xi Ge
a870b06055 ABI Checker: include mangled names in ABI descriptor files
Previously, we use USR as a delegate for mangled name. However, USR won't incorporate name changes made
by attributes like @_silgen_name. Instead, we should add a dedicated field for canonical mangled names.

rdar://84202064
2021-10-20 20:58:00 -07:00
Nate Chandler
b4291916f2 Merge branch 'main' into rebranch
Conflicts:
        include/swift/SIL/SILBuilder.h
2021-09-15 13:30:12 -07:00
Alexis Laferrière
51cec86085 [APIDigester] Don't check whether the stdlib was built for a different SDK
The API digester forces loading the stdlib which may pick up an stdlib
from a different SDK than the one being tested. Disable the check
enforcing loading only swiftmodules built for the same SDK.
2021-09-13 16:44:16 -07:00
swift-ci
b56685ee37 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-10 13:35:21 -07:00
Hamish Knight
af14bba276 [AST] Simplify AnyFunctionType::composeTuple
Remove the canonicalVararg parameter and
CanParamArrayRef wrapper. Almost none of the
callers want canonicalVararg, and the one that
does calls `getCanonicalType` on the result
anyway.
2021-09-09 21:46:31 +01:00
swift-ci
1996fff7e1 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-06 09:53:04 -07:00
Xi Ge
eb8e52b8d6 ABIChecker: allow retrying when loading ABI descriptor file 2021-09-05 20:07:38 -07:00
swift-ci
8e7ca62491 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-03 19:43:11 -07:00
Xi Ge
a8b95cb9cd ABIChecker: don't fail when hitting EnumCaseDecl
All enum elments should have been handled separately so we don't need to anything special
for EnumCaseDecl except consuming them.
2021-09-03 16:45:24 -07:00
swift-ci
048047ee97 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-24 09:13:39 -07:00
Xi Ge
d7f5dc4b28 ABIChecker: diagnose mangled name changes
Moving generic constraint from extension to its member or vice versa may change the mangled name
of the member without changing the generic signature, thus introducing ABI breakages. This change
teaches the ABI checker to diagnose USR (mangled name) changes to cover such cases.

rdar://78276290
2021-08-23 17:06:37 -07:00
swift-ci
13a25aa85b Merge remote-tracking branch 'origin/main' into rebranch 2021-08-20 09:13:20 -07:00
Xi Ge
35cb97b8ad ABIChecker: minor refactoring to move code to APIDigester lib. NFC 2021-08-19 22:27:14 -07:00