Commit Graph

240 Commits

Author SHA1 Message Date
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07: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
QuietMisdreavus
85d59d2e55 don't use Clang modules in the "only re-export public symbols" check (#66610)
rdar://110399757
2023-06-15 10:13:18 -06:00
QuietMisdreavus
e120a82e0c [SymbolGraphGen] refactor protocol conformance inheritance checking (#66012)
rdar://109418762
2023-05-22 09:27:58 -06:00
QuietMisdreavus
07fc40c522 allow any ValueDecl to take part in picking a best candidate (#65441)
rdar://105099207
2023-04-27 08:03:12 -06:00
Hamish Knight
c1843479f1 Drop SerializedOK parameter from getRawComment
It doesn't seem like there's any client that's
actually taking advantage of setting it to `false`,
and its default value of `false` is more likely
than not going to cause clients to accidentally
miss comments that they may want. In fact, this
was exactly the case for code completion's brief
field. Finally, the parameter wasn't even
consistently applied, as we would attempt to
deserialize swiftdoc comments even if it were
`false`.
2023-04-26 12:38:37 +01:00
QuietMisdreavus
ff5c5312e8 [SymbolGraphGen] move "protocol implementations" check into isImplicitlyPrivate (#64867)
rdar://107432084
2023-04-05 09:53:53 -06:00
Steven Wu
09b8af86fb Virtualize swift compiler outputs (#63206)
Using a virutal output backend to capture all the outputs from
swift-frontend invocation. This allows redirecting and/or mirroring
compiler outputs to multiple location using different OutputBackend.

As an example usage for the virtual outputs, teach swift compiler to
check its output determinism by running the compiler invocation
twice and compare the hash of all its outputs.

Virtual output will be used to enable caching in the future.
2023-04-05 23:34:37 +08:00
QuietMisdreavus
8fd028c4a8 [SymbolGraphGen] emit USRs for primary associated types in DeclarationFragmentPrinter (#60007)
* add a SymbolGraph test for primary associated types

* print USRs of primary associated types
2023-04-03 11:52:53 -06:00
QuietMisdreavus
0d74959af6 don't print macro definitions in symbol graphs (#64732)
rdar://106862694
2023-03-29 17:04:00 -06:00
QuietMisdreavus
d9c8dca5d1 [SymbolGraphGen] allow SourceKit to print declarations for private stdlib symbols (#64556)
Resolves rdar://103112656
Resolves #62457
2023-03-28 10:30:36 -06:00
Ellie Shin
7d23db3646 Create PackageUnit class, and Package entries to DeclContext / ASTHierarchy
Previously enum AccessLimitKind was
added to distinguish access scopes b/t package and public while keeping
DeclContext null but it proved to be too limiting. This PR creates package specific entries for DeclContext and
ASTHierarchy. It create a new class PackageUnit that can be set as the parent DeclContext of ModuleDecl. This PR
contains addition of such entries but not the use of them; the actual use of them will be in the upcoming PRs.

Resolves rdar://106155600
2023-03-02 13:20:51 -08:00
QuietMisdreavus
164e93e0a7 Merge pull request #63726 from apple/QuietMisdreavus/skip-proto-impls
[SymbolGraphGen] add new flag to skip "protocol implementation" symbols

rdar://59899968
2023-02-28 10:50:01 -07:00
Victoria Mitchell
9cca3c1405 allow implementation symbols to remain if they have their own docs 2023-02-17 17:46:50 -07:00
Ben Barham
72fb01c0e1 [SymbolGraph] Generate symbol graphs for macro declarations 2023-02-16 17:59:29 -08:00
Victoria Mitchell
4ec3e5291f add new flag to skip "protocol implementation" symbols
rdar://59899968
2023-02-16 14:00:04 -07:00
Victoria Mitchell
aafa418290 review: break the attribute name into its own fragment again 2023-02-15 14:21:38 -07:00
Victoria Mitchell
8eb2c50967 don't split attribute fragments with a separate typeIdentifier fragment
rdar://104930571
2023-02-13 15:15:57 -07:00
QuietMisdreavus
36ab59629d Merge pull request #63391 from apple/QuietMisdreavus/factory-init-sgf
don't print the "not inherited" mark in SGF declarations
2023-02-07 15:12:37 -07:00
Victoria Mitchell
d208dd9993 don't print the "not inherited" mark in SGF declarations
rdar://104917487
2023-02-02 14:53:03 -07:00
Alex Hoppen
2fb487f4b2 [SymbolGraph] Sort edges to get consistent symbol graph string representations 2023-02-02 22:03:25 +01:00
Max Obermeier
8c6fe1cca4 fix #61531 swift-symbolgraph-extract crashes when trying to emit the 'Swift' module (#62825)
fix a crash in symbol graph generation caused by an empty SmallVector access while expanding protocol compositions during conformance expansion for extension block symbols

rdar://103322385
2023-01-06 09:06:17 -07:00
Max Obermeier
adc1131857 fix apple/swift-docc#422 (#62409)
do not emit extension block symbols for extensions to external types when the extended type is re-exported by the extending module
2022-12-06 09:46:02 -07: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
Robert Widmann
91c262bcb7 Move TokenKinds.def.gyb to AST 2022-11-16 13:38:25 -08:00
Max Obermeier
429f15f619 connect memberOf relationship of default implementation targets to extension block symbol if extension block symbol format is used (#61406) 2022-11-15 16:10:59 -07:00
Max Obermeier
ddf5cf944c fix symbol graph bug where enabling extension block format caused inheritsFrom relationships of extended symbols to be emitted in extension graphs (#61951) 2022-11-15 09:18:09 -07:00
Doug Gregor
5ab6b72604 [Macros] Turn Macro into a declaration node.
Although the declaration of macros doesn't appear in Swift source code
that uses macros, they still operate as declarations within the
language. Rework `Macro` as `MacroDecl`, a generic value declaration,
which appropriate models its place in the language.

The vast majority of this change is in extending all of the various
switches on declaration kinds to account for macros.
2022-11-13 12:21:29 -08:00
Ben Barham
1526cfacd6 Merge pull request #61838 from bnbarham/symbol-graph-should-print-custom-attrs
[SymbolGraph] Output custom attributes
2022-11-01 11:35:45 -07:00
Ben Barham
1aee0af1d4 [SymbolGraph] Output custom attributes
Custom attributes were being skipped as their attribute name started
with a "_". Underscored attributes are typically unstable and thus
shouldn't be printed, but "_" is not being used for that purpose in the
case of "_custom".

Rather than checking for "_" or "__", just use `UserInaccessible`. This
property is used for attributes that shouldn't be shown to users in eg.
completion/printing/etc.

Resolves rdar://99029554.
2022-10-31 15:16:59 -07:00
Allan Shortlidge
af032afb9d Serialization: Break the cycle between Serialization and SymbolGraphGen.
Push the top level logic for writing out swiftmodules and associated files into the frontend library which has access to all the necessary dependencies.
2022-10-29 21:37:09 -07:00
Holly Borla
38a2c8218b [Requirement] Rename RequirementKind::SameCount to SameShape. 2022-10-06 20:48:40 -07:00
QuietMisdreavus
4413cee7bf don't use null types when determining extension access level (#61227)
rdar://100169094

Co-authored-by: Max Obermeier <themomax@icloud.com>
2022-09-21 14:19:04 -06:00
Max Obermeier
453fd2231b Allow for emission of swift.extension symbols for extensions to external types in swiftSymbolGraphGen (#59047)
This includes:
 - bumping the SWIFT_SYMBOLGRAPH_FORMAT_MINOR version
 - introduction of the "swift.extension" symbol and "extensionTo" relationship
 - adding support for ExtensionDecl to the Symbol class
 - adding a "typeKind" field to the symbol's extension mixin which indicates what kind
   of symbol was extended
 - intoduction of the -emit-extension-block-symbols flag, which enables the behavior
   outlined below
 - adaptions to SymbolGraphASTWalker that ensure a swift.extension symbol is emitted
   for each extension to a type that does not exist in the local symbol graph
 - adaptions to SymbolGraph and SymbolGraphASTWalker that ensure member and conformance
   relationships are correctly associated with the swift.extension symbol instead of
   the original type declaration's (extended nominal's) symbol where applicable
 - adaptions to SymbolGraphASTWalker that ensure swift.extension symbols are connected
   to their respective extended nominal's symbol using an extensionTo relationship

Testing:
- adds SymbolGraph tests that test behavior only relevant in
  -emit-extension-block-symbols mode
- adapts some SymbolGraph tests to additionally test similar behavior for
  extensions to external types in -emit-extension-block-symbols mode
- adapts some SymbolGraph tests to (additionally or exclusively) test the
  behavior with -emit-extension-block-symbols mode enabled

Bugfixes:
- fixes a bug where some conformsTo relationships implicated by the conformances
  declared on an extension to an external type were not emitted
  (see test/SymbolGraph/Relationships/ConformsTo/Indirect.swift)

Further changes:
- documents the strategy for naming and associating children declared in extensions
  to typealiases (see test/SymbolGraph/Relationships/MemberOf/Typealias.swift,
  test/SymbolGraph/Symbols/Names.swift)
2022-09-16 12:02:40 -06:00
QuietMisdreavus
d043378412 [SymbolGraphGen] Refactor export-import logic (#61049)
rdar://98808363
2022-09-13 10:08:10 -06:00
QuietMisdreavus
f674b473ec introduce a @_documentation(...) attribute to influence SymbolGraphGen (#60242)
* add @_documentation(...) attribute to influence SymbolGraphGen

rdar://79049241
2022-09-06 14:12:42 -06:00
Victoria Mitchell
8073a2a586 give inherited/synthesized objc symbols a synthesized base type
rdar://98670682
2022-09-01 11:26:46 -06:00
Slava Pestov
5c32f2136e AST: Introduce RequirementKind::SameCount 2022-08-23 11:12:00 -04:00
Slava Pestov
eb77da1ca3 SymbolGraph: Stop calling getAllConformances() on protocols 2022-08-23 00:03:37 -04:00
swift-ci
ff3985fbe3 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-22 18:14:54 -07:00
swift-ci
cf85fc5b6c Merge pull request #58568 from jsoref/spelling-lib-symbolgraphgen
Spelling lib symbolgraphgen
2022-07-22 18:00:56 -07:00
swift-ci
a0c70488e9 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-20 08:54:21 -07:00
QuietMisdreavus
a83a17c88b Revert "consider requirements of an underscored protocol to also be underscored (take two) (#59531)" (#60096)
This reverts commit ababa79398.
2022-07-20 09:54:03 -06:00
swift-ci
bb56ee29d0 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-08 08:14:09 -07:00
QuietMisdreavus
2d874788f6 [SymbolGraphGen] only include the given symbol for qualified imports (#59852)
* only include the given symbol for qualified imports

rdar://96309088

* re-exporting one type should not allow unrelated types to sneak in

* ensure that children of re-exported types are also re-exported
2022-07-08 09:13:08 -06:00
swift-ci
3936df3b85 Merge remote-tracking branch 'origin/main' into rebranch 2022-06-23 12:34:34 -07:00
QuietMisdreavus
ababa79398 consider requirements of an underscored protocol to also be underscored (take two) (#59531)
* Revert "Revert "consider requirements of an underscored protocol to also be underscored""

* make SkipsPublicUnderscore more resilient to non-determinism
2022-06-23 13:26:21 -06:00
swift-ci
294ae6edbe Merge remote-tracking branch 'origin/main' into rebranch 2022-06-16 19:54:26 -07:00
QuietMisdreavus
5e065f0c31 Revert "consider requirements of an underscored protocol to also be underscored (#59480)"
This reverts commit a8ecfc94ec.
2022-06-16 20:33:34 -06:00
swift-ci
3a37d71b71 Merge remote-tracking branch 'origin/main' into rebranch 2022-06-16 13:34:31 -07:00