This is an archive of the discontinued LLVM Phabricator instance.

[clang][utils] Modify make-ast-dump-check.sh to generate AST serialization dump tests
ClosedPublic

Authored by riccibruno on Jun 13 2020, 4:55 AM.

Details

Summary

An AST serialization dump test is a test which compares the output of -ast-dump on the source and of -ast-dump-all on a PCH generated from the source. Modulo a few differences the outputs should match.

This patch to make-ast-dump-check.sh enables automatically generating these tests.

Diff Detail

Event Timeline

riccibruno created this revision.Jun 13 2020, 4:55 AM

Example of a test:

+1, thank you for looking into this!
I suspect there's a few issues to be discovered with this :)

+1, thank you for looking into this!
I suspect there's a few issues to be discovered with this :)

Indeed; I already got one in D81787.

riccibruno added a reviewer: lebedev.ri.EditedJun 14 2020, 4:36 AM

Summarising a quick discussion with @lebedev.ri on IRC yesterday: this is not necessarily the best way to test the serialization of AST nodes, in that we could instead perform some kind of structural equivalence test. However this approach has the huge advantage of being simply a matter of 1. Adding a few run lines to each ast-dump-*, and 2. running this script on the test.
(see rG6a79f5aa5dbc2528444b4dfb92bb68039c5a32e9 for an example of what the output looks like)

What I'd like to do (and get approval for, since I don't think it is worthwhile to individually put each changed test for review) is go over each AST dump tests (ie: each ast-dump-*) and do the above (possibly splitting some tests intro multiple files if they are too big).

Edit: Excluding AST dump tests which are about the serialization itself, or modules.

aaron.ballman accepted this revision.Jun 15 2020, 4:37 AM

Summarising a quick discussion with @lebedev.ri on IRC yesterday: this is not necessarily the best way to test the serialization of AST nodes, in that we could instead perform some kind of structural equivalence test. However this approach has the huge advantage of being simply a matter of 1. Adding a few run lines to each ast-dump-*, and 2. running this script on the test.
(see rG6a79f5aa5dbc2528444b4dfb92bb68039c5a32e9 for an example of what the output looks like)

What I'd like to do (and get approval for, since I don't think it is worthwhile to individually put each changed test for review) is go over each AST dump tests (ie: each ast-dump-*) and do the above (possibly splitting some tests intro multiple files if they are too big).

Edit: Excluding AST dump tests which are about the serialization itself, or modules.

This seems reasonable to me. LGTM

This revision is now accepted and ready to land.Jun 15 2020, 4:37 AM

SGTM, thank you!

This revision was automatically updated to reflect the committed changes.