[cfe-dev] State of the serialization tests, and plan to fix it
Bruno Ricci via cfe-dev
cfe-dev at lists.llvm.org
Tue Apr 2 05:39:57 PDT 2019
I recently discovered that serialization of the AST is only very lightly
tested. What is tested is mostly that parsing works with an external
source, but that in itself does not guarantee that the round trip
serialization + deserialization is lossless. In addition some nodes are
not tested at all. This can be seen in the coverage report available here:
I would like to fix this and am looking for comments on the following plan:
Go through each AST node and ensure that its state is dumped fully. To avoid
polluting to output of ast-dump, split the various bits of state into two
parts, the first part being the part generally useful for people working
on clang (ie: mostly what is currently dumped), and the second part being
the rest (which is rather subjective obviously).
(though this can be skipped if the additional data in the output in
the AST dump is judged to be acceptable.)
Then use that to check that the serialization works as intended. There is
the possibility of re-using the ast-dump tests (in AST/ast-dump-*) here.
Of course this does not prevent someone from adding some data to some
node and forgetting to update both the serialization and the AST dump.
Possible alternative plan:
Superficially it seems like ASTStructuralEquivalence could be used. However
as far as I can tell, as its name implies, it only look at the structure
at the AST and does not look to the various bits of each node. Additionally,
it does not currently handle statements and expression at all.
I am missing something here, and does anyone have a better idea ?
More information about the cfe-dev