mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 07:56:06 +00:00

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
41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
// Test without serialization:
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -ast-dump %s \
|
|
// RUN: | FileCheck %s
|
|
//
|
|
// Test with serialization:
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -emit-pch -o %t %s
|
|
// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value \
|
|
// RUN: -include-pch %t -ast-dump-all /dev/null \
|
|
// RUN: | FileCheck %s
|
|
|
|
// Make sure that the Stmt * for the body of the LambdaExpr is
|
|
// equal to the Stmt * for the body of the call operator.
|
|
void Test0() {
|
|
[]() {
|
|
return 42;
|
|
};
|
|
}
|
|
|
|
// CHECK: FunctionDecl {{.*}} Test0
|
|
//
|
|
// CHECK: CXXMethodDecl {{.*}} operator() 'int () const' inline
|
|
// CHECK-NEXT: CompoundStmt 0x[[TMP0:.*]]
|
|
// CHECK: IntegerLiteral {{.*}} 'int' 42
|
|
//
|
|
// CHECK: CompoundStmt 0x[[TMP0]]
|
|
// Check: IntegerLiteral {{.*}} 'int' 42
|
|
|
|
void Test1() {
|
|
[](auto x) { return x; };
|
|
}
|
|
|
|
// CHECK: FunctionDecl {{.*}} Test1
|
|
//
|
|
// CHECK: CXXMethodDecl {{.*}} operator() 'auto (auto) const' inline
|
|
// CHECK-NEXT: ParmVarDecl {{.*}} referenced x 'auto'
|
|
// CHECK-NEXT: CompoundStmt 0x[[TMP1:.*]]
|
|
// CHECK: DeclRefExpr {{.*}} 'x' 'auto'
|
|
//
|
|
// CHECK: CompoundStmt 0x[[TMP1]]
|
|
// CHECK: DeclRefExpr {{.*}} 'x' 'auto'
|