[clang][Serialization] Don't duplicate the body of LambdaExpr during deserialization
authorBruno Ricci <riccibrun@gmail.com>
Thu, 2 Jul 2020 13:13:35 +0000 (14:13 +0100)
committerBruno Ricci <riccibrun@gmail.com>
Thu, 2 Jul 2020 13:13:35 +0000 (14:13 +0100)
commite4d178a752444453f0ab8d2b9085087208aa8296
tree9fdb199a616749b6809f895c384b684043ddaabd
parent5c02a2421b951a14d1294598d0082b32659c7082
[clang][Serialization] Don't duplicate the body of LambdaExpr during deserialization

05843dc6ab97a00cbde7aa4f08bf3692eb83109d changed the serialization of the body
of LambdaExpr to avoid a mutation in LambdaExpr::getBody and to avoid a missing
body in LambdaExpr::children.

Unfortunately this replaced one bug by another: we are now duplicating the body
during deserialization; that is after deserialization the identity:

E->getBody() == E->getCallOperator()->getBody() does not hold.

Fix that by instead lazily loading the body from the call operator when needed.

Differential Revision: https://reviews.llvm.org/D83009

Reviewed By: martong, aaron.ballman, vabridgers
clang/include/clang/AST/ExprCXX.h
clang/lib/AST/ExprCXX.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/AST/ast-dump-lambda-body-not-duplicated.cpp [new file with mode: 0644]