hokein created this revision. hokein added a reviewer: sammccall. Herald added a project: clang.
We forgot to initialize the NumExpr member in one of the constructors, which leads crashes in preamble serialization. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D78284 Files: clang/include/clang/AST/Expr.h clang/lib/AST/Expr.cpp clang/test/PCH/cxx-recovery-expr.cpp Index: clang/test/PCH/cxx-recovery-expr.cpp =================================================================== --- /dev/null +++ clang/test/PCH/cxx-recovery-expr.cpp @@ -0,0 +1,13 @@ +// Test with pch. +// RUN: %clang_cc1 -emit-pch -frecovery-ast -fallow-pch-with-compiler-errors -o %t %s +// RUN: %clang_cc1 -include-pch %t -fno-validate-pch -emit-llvm -o - %s + +#ifndef HEADER +#define HEADER + +int func(int); +int s = func(); + +#else + +#endif Index: clang/lib/AST/Expr.cpp =================================================================== --- clang/lib/AST/Expr.cpp +++ clang/lib/AST/Expr.cpp @@ -4574,7 +4574,7 @@ RecoveryExpr *RecoveryExpr::CreateEmpty(ASTContext &Ctx, unsigned NumSubExprs) { void *Mem = Ctx.Allocate(totalSizeToAlloc<Expr *>(NumSubExprs), alignof(RecoveryExpr)); - return new (Mem) RecoveryExpr(EmptyShell()); + return new (Mem) RecoveryExpr(EmptyShell(), NumSubExprs); } void OMPArrayShapingExpr::setDimensions(ArrayRef<Expr *> Dims) { Index: clang/include/clang/AST/Expr.h =================================================================== --- clang/include/clang/AST/Expr.h +++ clang/include/clang/AST/Expr.h @@ -6034,7 +6034,8 @@ private: RecoveryExpr(ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef<Expr *> SubExprs); - RecoveryExpr(EmptyShell Empty) : Expr(RecoveryExprClass, Empty) {} + RecoveryExpr(EmptyShell Empty, unsigned NumSubExprs) + : Expr(RecoveryExprClass, Empty), NumExprs(NumSubExprs) {} size_t numTrailingObjects(OverloadToken<Stmt *>) const { return NumExprs; }
Index: clang/test/PCH/cxx-recovery-expr.cpp =================================================================== --- /dev/null +++ clang/test/PCH/cxx-recovery-expr.cpp @@ -0,0 +1,13 @@ +// Test with pch. +// RUN: %clang_cc1 -emit-pch -frecovery-ast -fallow-pch-with-compiler-errors -o %t %s +// RUN: %clang_cc1 -include-pch %t -fno-validate-pch -emit-llvm -o - %s + +#ifndef HEADER +#define HEADER + +int func(int); +int s = func(); + +#else + +#endif Index: clang/lib/AST/Expr.cpp =================================================================== --- clang/lib/AST/Expr.cpp +++ clang/lib/AST/Expr.cpp @@ -4574,7 +4574,7 @@ RecoveryExpr *RecoveryExpr::CreateEmpty(ASTContext &Ctx, unsigned NumSubExprs) { void *Mem = Ctx.Allocate(totalSizeToAlloc<Expr *>(NumSubExprs), alignof(RecoveryExpr)); - return new (Mem) RecoveryExpr(EmptyShell()); + return new (Mem) RecoveryExpr(EmptyShell(), NumSubExprs); } void OMPArrayShapingExpr::setDimensions(ArrayRef<Expr *> Dims) { Index: clang/include/clang/AST/Expr.h =================================================================== --- clang/include/clang/AST/Expr.h +++ clang/include/clang/AST/Expr.h @@ -6034,7 +6034,8 @@ private: RecoveryExpr(ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef<Expr *> SubExprs); - RecoveryExpr(EmptyShell Empty) : Expr(RecoveryExprClass, Empty) {} + RecoveryExpr(EmptyShell Empty, unsigned NumSubExprs) + : Expr(RecoveryExprClass, Empty), NumExprs(NumSubExprs) {} size_t numTrailingObjects(OverloadToken<Stmt *>) const { return NumExprs; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits