Commit Graph

8 Commits

Author SHA1 Message Date
Tony Allevato
7ec3789cf7 [ASTDumper] Fix malformed JSON for async let _ = ....
By calling `printCommon` twice, this inserts a JSON object into
another JSON object without a key. This asserts inside LLVM's
JSON helper, but only if the compiler is built with assertions
enabled (which Xcode's compiler doesn't).

This also fixes the S-expression version, which is similarly busted:

```
(pattern_entry
  (async_let  type="Int"              (pattern_any type="Int")
  (original_init=call_expr type="Int" ...
```
2025-12-02 16:26:09 -05:00
Tony Allevato
8805d94c79 [ASTDumper] Print decl-refs, not full decls, for function captures.
This avoids infinite recursion when a function captures itself; e.g.,

```swift
func foo() {
  func bar() {
    bar()
  }
  bar()
}
```

It also just avoids printing unnecessarily verbose information,
since those decls would have already been dumped elsewhere in the
tree.
2025-11-24 13:12:02 -05:00
Tony Allevato
7cca6d6a1a [ASTDumper] Don't attempt to compute type USR for ModuleTypes.
`ModuleType`s show up in some rare places, like the left-hand-side of
a `DotSyntaxBaseIgnoredExpr` for a module-qualified function call.
ASTMangler does not support these because they're not real types.
2025-11-24 12:51:08 -05:00
Tony Allevato
5be2498632 Address review feedback. 2025-04-04 09:12:02 -04:00
Tony Allevato
718f9f0e9c Improve type USR generation and inheritance dumps.
- For type USRs, use `mapTypeOutOfContext()` to replace primary
  archetypes with type parameters. If the type contains local
  archetypes, replace them with their existential upper bounds.
- For inheritance of types, print the derived semantic information
  instead of the inheritance list as it is written.
- Dump conformance requirements as protocol decl USRs instead of
  type USRs, since the latter involves an existential conversion
  that loses suppressed protocols.
- Fix a small bug in conformance dumping where the `MemberLoading`
  field wasn't propagated to the nested printer, which caused
  protocols to be dumped as simple names instead of USRs.
2025-04-02 08:55:04 -04:00
Tony Allevato
a4c64b081d Address most of the simple review feedback. 2025-01-22 14:26:13 -05:00
Tony Allevato
52c009a2ec [AST] Improve JSON representation of various AST nodes. 2025-01-22 14:26:13 -05:00
Tony Allevato
a57fb4dfa9 [AST] Add minimal JSON support to ASTDumper.
This only takes the existing AST information and writes it as JSON
instead of S-expressions. Since many of these fields are stringified,
they're not ideal for the kind of analysis clients of the JSON format
would want to do. A future commit will update these values to use a
more structured representation.
2025-01-22 14:26:13 -05:00