Commit Graph

3 Commits

Author SHA1 Message Date
Alastair Robertson
b4b3e86c47 TypeGraphParser: Fix lifetimes of ContainerInfo objects
Containers store references to ContainerInfos, so the ContainerInfos
must live beyond the stack they were created on. Use static variables
for simplicity.
2023-07-18 17:18:28 +01:00
Alastair Robertson
4d96848bdb TypeGraphParser: Throw custom error types
We can catch these exceptions and print clearer failure messages.

Before:
  unknown file: Failure
  C++ exception with description "Invalid type for child" thrown in the test body.

After:
  ../test/type_graph_utils.cpp:44: Failure
  Failed
  Error parsing input graph: Invalid type for child
2023-07-18 17:18:28 +01:00
Alastair Robertson
30cd23fa53 TypeGraph: Introduce TypeGraphParser to simplify unit testing
TypeGraphParser parses a textual type graph, as emitted by Printer.

It also doubles as a way of ensuring that Printer displays all
information about a type graph, to aid with debugging.

Convert Flattener unit tests over to this new framework as a first step.
2023-07-13 17:38:49 +01:00