diff options
| author | Mike Stump <mrs@apple.com> | 2009-02-19 22:01:56 +0000 |
|---|---|---|
| committer | Mike Stump <mrs@apple.com> | 2009-02-19 22:01:56 +0000 |
| commit | a67033294a028a9a33530bb3454758ba33acd842 (patch) | |
| tree | c88ffd51d4c57b31624943d53efb26c3e80fb9c1 /clang/lib/Sema | |
| parent | a118a0715779a8ec73d254b28169349a4ca4fe54 (diff) | |
| download | bcm5719-llvm-a67033294a028a9a33530bb3454758ba33acd842.tar.gz bcm5719-llvm-a67033294a028a9a33530bb3454758ba33acd842.zip | |
Add enough checking to ensure that non-constant block literals don't
appear to be constant. I'll probably redo this and throw it all away
later once we have codegen for BlockDeclRefExprs.
llvm-svn: 65070
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/Sema.h | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index 3eb68b50590..2a4b4657be6 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -2004,7 +2004,8 @@ struct BlockSemaInfo { llvm::SmallVector<ParmVarDecl*, 8> Params; bool hasPrototype; bool isVariadic; - + bool hasBlockDeclRefExprs; + BlockDecl *TheDecl; /// TheScope - This is the scope for the block itself, which contains diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 5d1d9353868..c95b5ee52d6 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -865,6 +865,9 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, // as they do not get snapshotted. // if (CurBlock && ShouldSnapshotBlockValueReference(CurBlock, VD)) { + // Blocks that have these can't be constant. + CurBlock->hasBlockDeclRefExprs = true; + // The BlocksAttr indicates the variable is bound by-reference. if (VD->getAttr<BlocksAttr>()) return Owned(new (Context) BlockDeclRefExpr(VD, @@ -4331,6 +4334,7 @@ void Sema::ActOnBlockStart(SourceLocation CaretLoc, Scope *BlockScope) { BSI->ReturnType = 0; BSI->TheScope = BlockScope; + BSI->hasBlockDeclRefExprs = false; BSI->TheDecl = BlockDecl::Create(Context, CurContext, CaretLoc); PushDeclContext(BlockScope, BSI->TheDecl); @@ -4442,7 +4446,7 @@ Sema::ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, StmtTy *body, BlockTy = Context.getBlockPointerType(BlockTy); BSI->TheDecl->setBody(Body.take()); - return new (Context) BlockExpr(BSI->TheDecl, BlockTy); + return new (Context) BlockExpr(BSI->TheDecl, BlockTy, BSI->hasBlockDeclRefExprs); } Sema::ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc, |

