[cfe-commits] r57304 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/Decl.cpp lib/Sema/Sema.h lib/Sema/SemaExpr.cpp
Steve Naroff
snaroff at apple.com
Wed Oct 8 11:44:00 PDT 2008
Author: snaroff
Date: Wed Oct 8 13:44:00 2008
New Revision: 57304
URL: http://llvm.org/viewvc/llvm-project?rev=57304&view=rev
Log:
Instantiate the BlockDecl in ActOnBlockStart() so we can use it as a DeclContext.
This required changes to attach the compound statement later on (like we do for functions).
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=57304&r1=57303&r2=57304&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Oct 8 13:44:00 2008
@@ -992,21 +992,21 @@
Stmt *Body;
protected:
BlockDecl(DeclContext *DC, SourceLocation CaretLoc,
- ParmVarDecl **args, unsigned numargs, Stmt *body)
+ ParmVarDecl **args, unsigned numargs)
: Decl(Block, CaretLoc), DeclContext(Block),
- Args(args, args+numargs), Body(body) {}
+ Args(args, args+numargs), Body(0) {}
virtual ~BlockDecl();
virtual void Destroy(ASTContext& C);
public:
static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
- ParmVarDecl **args, unsigned numargs,
- CompoundStmt *body);
+ ParmVarDecl **args, unsigned numargs);
SourceLocation getCaretLocation() const { return getLocation(); }
Stmt *getBody() const { return Body; }
+ void setBody(Stmt *B) { Body = B; }
/// arg_iterator - Iterate over the ParmVarDecl's for this block.
typedef llvm::SmallVector<ParmVarDecl*, 8>::const_iterator param_iterator;
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=57304&r1=57303&r2=57304&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Oct 8 13:44:00 2008
@@ -77,10 +77,9 @@
}
BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
- ParmVarDecl **args, unsigned numargs,
- CompoundStmt *body) {
+ ParmVarDecl **args, unsigned numargs) {
void *Mem = C.getAllocator().Allocate<BlockDecl>();
- return new (Mem) BlockDecl(DC, L, args, numargs, body);
+ return new (Mem) BlockDecl(DC, L, args, numargs);
}
FieldDecl *FieldDecl::Create(ASTContext &C, SourceLocation L,
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=57304&r1=57303&r2=57304&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Oct 8 13:44:00 2008
@@ -1070,6 +1070,8 @@
bool hasPrototype;
bool isVariadic;
+ BlockDecl *TheDecl;
+
/// TheScope - This is the scope for the block itself, which contains
/// arguments etc.
Scope *TheScope;
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=57304&r1=57303&r2=57304&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Oct 8 13:44:00 2008
@@ -2889,6 +2889,8 @@
BSI->Params.push_back((ParmVarDecl *)FTI.ArgInfo[i].Param);
BSI->isVariadic = FTI.isVariadic;
}
+ BSI->TheDecl = BlockDecl::Create(Context, CurContext, CaretLoc,
+ &BSI->Params[0], BSI->Params.size());
}
/// ActOnBlockError - If there is an error parsing a block, this callback
@@ -2932,10 +2934,8 @@
BlockTy = Context.getBlockPointerType(BlockTy);
- BlockDecl *NewBD = BlockDecl::Create(Context, CurContext, CaretLoc,
- &BSI->Params[0], BSI->Params.size(),
- Body.take());
- return new BlockExpr(NewBD, BlockTy);
+ BSI->TheDecl->setBody(Body.take());
+ return new BlockExpr(BSI->TheDecl, BlockTy);
}
/// ExprsMatchFnType - return true if the Exprs in array Args have
More information about the cfe-commits
mailing list