Containers store references to ContainerInfos, so the ContainerInfos
must live beyond the stack they were created on. Use static variables
for simplicity.
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
i.e. unions with non-POD members
We can't examine untagged unions, but we should be able to support
looking inside tagged unions at some point in the future.
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.
Summary:
Stubbing tuple without alignment info can cause failures. I added a test
case for this which failed before this fix but works now.
Test Plan:
Ran the test.
Summary:
If a container has 0 template params (e.g. IOBuf, IOBufQueue), it wasn't
being added to containerTypeMap. This causes the deserialization to go wrong
as TreeBuilder doesn't treat the types as container
Test Plan:
make test
Use fully qualified names to determine if a class is really the child of
our type. It may be that it is the child of another type with an
identical name in another namespace.
visit(Type&) and visit(Type*) were helper functions than did cycle
detection and provided nicer syntax for the type.accept(*this) calls.
However, because they overloaded the visit() function, it was easy to
accidentally call a concrete visit method (e.g. visit(Class&)) instead
of the virtual-dispatching visit(Type&).
By changing the name of this wrapper, it will make it much more obvious
when code is introduced which bypasses the cycle detection.
Pass-through-types represent classes to be turned into containers. We
don't want these to turn these containers into Dummy's on a second run
of TypeIdentifier.
This will eventually be used to enable running with Tree Builder v2.
For now, when it is disabled it puts CodeGen v2 into compatibility mode,
disabling features which weren't present in CodeGen v1 so that its
output can be understood by Tree Builder v1.
These aren't used for anything yet, but should be useful for stable IDs
when printing nodes before and after passes and for faster cycle
detection than the current map of pointers.
As we now store ContainerInfo objects in OICodeGen::Config, we can not
copy it any more. Change all places that took copies to take const
references instead.
The copy in OICodeGen modified membersToStub, the contents of which form
part of OICache's hash. However, as OICache also previously had its own
copy, it would not have been OICodeGen's modifications.
- Change member and parent offsets to work in bits, not bytes
- Printer still displays offsets in bytes, with decimals when using
bitfields
- AddPadding: Don't pad bitfields
- CodeGen: Emit code for bitfields
For std::vector and std::list, template parameters are not required to
be defined before they can be used. Delay sorting them until the end.
Also fix a CodeGen bug where we were defining typedefs in the middle of
the forward declarations. They only need to be defined when other types
are defined.