diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -3587,8 +3587,11 @@ llvm::PointerIntPair VarAndKind; SourceLocation Loc; + Capture() = default; + public: friend class ASTStmtReader; + friend class CapturedStmt; /// Create a new capture. /// diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -1345,6 +1345,11 @@ : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures), CapDeclAndKind(nullptr, CR_Default) { getStoredStmts()[NumCaptures] = nullptr; + + // Construct default capture objects. + Capture *Buffer = getStoredCaptures(); + for (unsigned I = 0, N = NumCaptures; I != N; ++I) + new (Buffer++) Capture(); } CapturedStmt *CapturedStmt::Create(const ASTContext &Context, Stmt *S,