diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Frontend/PCHReader.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Frontend/PCHWriter.cpp | 10 |
2 files changed, 22 insertions, 1 deletions
diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp index e474dc7a70d..2e8e7dd287d 100644 --- a/clang/lib/Frontend/PCHReader.cpp +++ b/clang/lib/Frontend/PCHReader.cpp @@ -197,6 +197,7 @@ void PCHDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) { void PCHDeclReader::VisitBlockDecl(BlockDecl *BD) { VisitDecl(BD); + BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadStmt())); unsigned NumParams = Record[Idx++]; llvm::SmallVector<ParmVarDecl *, 16> Params; Params.reserve(NumParams); @@ -294,6 +295,7 @@ namespace { unsigned VisitChooseExpr(ChooseExpr *E); unsigned VisitGNUNullExpr(GNUNullExpr *E); unsigned VisitShuffleVectorExpr(ShuffleVectorExpr *E); + unsigned VisitBlockExpr(BlockExpr *E); unsigned VisitBlockDeclRefExpr(BlockDeclRefExpr *E); }; } @@ -792,6 +794,13 @@ unsigned PCHStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { return NumExprs; } +unsigned PCHStmtReader::VisitBlockExpr(BlockExpr *E) { + VisitExpr(E); + E->setBlockDecl(cast_or_null<BlockDecl>(Reader.GetDecl(Record[Idx++]))); + E->setHasBlockDeclRefExprs(Record[Idx++]); + return 0; +} + unsigned PCHStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { VisitExpr(E); E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); @@ -2388,6 +2397,10 @@ Stmt *PCHReader::ReadStmt() { S = new (Context) ShuffleVectorExpr(Empty); break; + case pch::EXPR_BLOCK: + S = new (Context) BlockExpr(Empty); + break; + case pch::EXPR_BLOCK_DECL_REF: // FIXME: untested until we have statement and block support S = new (Context) BlockDeclRefExpr(Empty); diff --git a/clang/lib/Frontend/PCHWriter.cpp b/clang/lib/Frontend/PCHWriter.cpp index 14e979f2bc7..e71a60051ab 100644 --- a/clang/lib/Frontend/PCHWriter.cpp +++ b/clang/lib/Frontend/PCHWriter.cpp @@ -403,7 +403,7 @@ void PCHDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) { void PCHDeclWriter::VisitBlockDecl(BlockDecl *D) { VisitDecl(D); - // FIXME: emit block body + Writer.AddStmt(D->getBody()); Record.push_back(D->param_size()); for (FunctionDecl::param_iterator P = D->param_begin(), PEnd = D->param_end(); P != PEnd; ++P) @@ -496,6 +496,7 @@ namespace { void VisitChooseExpr(ChooseExpr *E); void VisitGNUNullExpr(GNUNullExpr *E); void VisitShuffleVectorExpr(ShuffleVectorExpr *E); + void VisitBlockExpr(BlockExpr *E); void VisitBlockDeclRefExpr(BlockDeclRefExpr *E); }; } @@ -940,6 +941,13 @@ void PCHStmtWriter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { Code = pch::EXPR_SHUFFLE_VECTOR; } +void PCHStmtWriter::VisitBlockExpr(BlockExpr *E) { + VisitExpr(E); + Writer.AddDeclRef(E->getBlockDecl(), Record); + Record.push_back(E->hasBlockDeclRefExprs()); + Code = pch::EXPR_BLOCK; +} + void PCHStmtWriter::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { VisitExpr(E); Writer.AddDeclRef(E->getDecl(), Record); |