[cfe-commits] [PATCH] Fix AST reader failures when types are read recursively

Erik Olofsson erik.olofsson at hansoft.se
Mon Jul 30 05:30:29 PDT 2012

Adds asserts to make sure we don't end up with two pointers to the same type when types are read recursively.

Fixed the TYPE_TEMPLATE_SPECIALIZATION case where this assert was hit.

Originally I started working on this because I had an assert in the ASTReader when a decltype was loaded. I tracked down the revision where it stopped working to the revision when the hash function was changed in FoldingSet. I debugged this and it ended up happening or not depending on the order that things were saved in ASTWriter. The assert was because it tried to profile a half finished decltype.

The fix for recursive decltype reads is done by creating a dummy type that recursive GetType finds. This pointer is then used as placement new when the real type is created so old pointers are still valid and point to the final type. I couldn't find a better way to do this. Refactoring all type reads to create the final type at the beginning instead of at the end might be a better way but requires many more changes.

I have not been able to create a test case for the decltype failure. I have only been able to make it fail for our full internal project. The patch also adds asserts for type offsets written in the wrong order as I hit this when I reversed the order of the types to try to reproduce this with a simpler test case.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: RecursiveASTSerialization.patch
Type: application/octet-stream
Size: 7901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120730/b5e33732/attachment.obj>

More information about the cfe-commits mailing list