Commit Graph

9 Commits

Author SHA1 Message Date
Tony Allevato
f249db3f85 Use cached evaluator results when looking up function types.
Also improve the output for thrown error destinations in
parsable modes.
2025-01-22 14:26:14 -05:00
Anthony Latsis
68746a0579 [NFC] AST: Rename IdentTypeReprUnqualifiedIdentTypeRepr 2024-03-02 08:28:47 +03:00
Becca Royal-Gordon
8770c7f826 Rework ASTDumper (#68438)
This PR refactors the ASTDumper to make it more structured, less mistake-prone, and more amenable to future changes. For example:

```cpp
  // Before:
  void visitUnresolvedDotExpr(UnresolvedDotExpr *E) {
    printCommon(E, "unresolved_dot_expr")
      << " field '" << E->getName() << "'";
    PrintWithColorRAII(OS, ExprModifierColor)
      << " function_ref=" << getFunctionRefKindStr(E->getFunctionRefKind());
    if (E->getBase()) {
      OS << '\n';
      printRec(E->getBase());
    }
    PrintWithColorRAII(OS, ParenthesisColor) << ')';
  }

  // After:
  void visitUnresolvedDotExpr(UnresolvedDotExpr *E, StringRef label) {
    printCommon(E, "unresolved_dot_expr", label);

    printFieldQuoted(E->getName(), "field");
    printField(E->getFunctionRefKind(), "function_ref", ExprModifierColor);

    if (E->getBase()) {
      printRec(E->getBase());
    }

    printFoot();
  }
```

* Values are printed through calls to base class methods, rather than direct access to the underlying `raw_ostream`.
    * These methods tend to reduce the chances of bugs like missing/extra spaces or newlines, too much/too little indentation, etc.
    * More values are quoted, and unprintable/non-ASCII characters in quoted values are escaped before printing.
* Infrastructure to label child nodes now exists.
    * Some weird breaks from the normal "style", like `PatternBindingDecl`'s original and processed initializers, have been brought into line.
* Some types that previously used ad-hoc dumping functions, like conformances and substitution maps, are now structured similarly to the dumper classes.
* I've fixed the odd dumping bug along the way. For example, distributed actors were only marked `actor`, not `distributed actor`.

This PR doesn't change the overall style of AST dumps; they're still pseudo-S-expressions. But the logic that implements this style is now isolated into a relatively small base class, making it feasible to introduce e.g. JSON dumping in the future.
2023-09-11 23:56:38 -07:00
Anthony Latsis
746c7aff7d [NFC] AST: Rename CompoundIdentTypeReprMemberTypeRepr 2023-01-07 07:14:41 +03:00
Ellie Shin
4814ea483f Update dump-ast test 2021-11-10 00:30:25 -08:00
Ellie Shin
09093e89dc Pass in out param to ImportPath getters
Modify ASTDumper to print module real names
Add doc comments
2021-11-10 00:30:25 -08:00
Ellie Shin
7cabcc913e Update dump ast test 2021-11-10 00:30:25 -08:00
elsh
9143bd4805 Update test 2021-10-18 17:37:26 -07:00
elsh
7a3a032ce8 Use module real name in ASTPrinter 2021-10-15 03:57:21 -07:00