diff options
| author | Steve Naroff <snaroff@apple.com> | 2008-10-08 18:44:00 +0000 | 
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2008-10-08 18:44:00 +0000 | 
| commit | 44078b95eead47fe345c3010d93ec1fd464fa493 (patch) | |
| tree | 2ec5b2360d35b300680734c47ea72c49fea59b30 /clang | |
| parent | 944375abae345c55802a6db809b2462cc780d7e2 (diff) | |
| download | bcm5719-llvm-44078b95eead47fe345c3010d93ec1fd464fa493.tar.gz bcm5719-llvm-44078b95eead47fe345c3010d93ec1fd464fa493.zip  | |
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).
llvm-svn: 57304
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/AST/Decl.h | 8 | ||||
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Sema/Sema.h | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 8 | 
4 files changed, 12 insertions, 11 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 88cbe854214..bb8c14c4088 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -992,21 +992,21 @@ class BlockDecl : public Decl, public DeclContext {    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; diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index c900a734ae0..fe2e95d1579 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -77,10 +77,9 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC,  }  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, diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index 406d9f7e7e1..0600ae14243 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -1070,6 +1070,8 @@ struct BlockSemaInfo {    bool hasPrototype;    bool isVariadic; +  BlockDecl *TheDecl; +      /// TheScope - This is the scope for the block itself, which contains    /// arguments etc.    Scope *TheScope; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index b8b614db073..cdba6ec6ea6 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -2889,6 +2889,8 @@ void Sema::ActOnBlockStart(SourceLocation CaretLoc, Scope *BlockScope,        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 @@ Sema::ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, StmtTy *body,    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  | 

