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.

Attachment: RecursiveASTSerialization.patch
Description: Binary data

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to