forked from OSchip/llvm-project
[AST] Fix an undefine behavior when creating an empty recovery expr.
Summary: We forgot to initialize the NumExpr member in one of the constructors, which leads crashes in preamble serialization. Reviewers: sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D78284
This commit is contained in:
parent
27e63d9b0e
commit
94d6dd01ba
|
@ -6080,7 +6080,8 @@ public:
|
|||
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; }
|
||||
|
||||
|
|
|
@ -4652,7 +4652,7 @@ RecoveryExpr *RecoveryExpr::Create(ASTContext &Ctx, SourceLocation BeginLoc,
|
|||
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) {
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue