- Add BlockDecl AST node.
- Modify BlockExpr to reference the BlockDecl.

This is "cleanup" necessary to improve our lookup semantics for blocks (to fix <rdar://problem/6272905> clang block rewriter: parameter to function not imported into block?).

Still some follow-up work to finish this (forthcoming).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57298 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 3ddf819..c900a73 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -76,6 +76,13 @@
                                 TypeSpecStartLoc);
 }
 
+BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, 
+                             ParmVarDecl **args, unsigned numargs, 
+                             CompoundStmt *body) {
+  void *Mem = C.getAllocator().Allocate<BlockDecl>();
+  return new (Mem) BlockDecl(DC, L, args, numargs, body);
+}
+
 FieldDecl *FieldDecl::Create(ASTContext &C, SourceLocation L,
                              IdentifierInfo *Id, QualType T, Expr *BW) {
   void *Mem = C.getAllocator().Allocate<FieldDecl>();
@@ -285,3 +292,20 @@
       return Members[i];
   return 0;
 }
+
+//===----------------------------------------------------------------------===//
+// BlockDecl Implementation
+//===----------------------------------------------------------------------===//
+
+BlockDecl::~BlockDecl() {
+}
+
+void BlockDecl::Destroy(ASTContext& C) {
+  if (Body)
+    Body->Destroy(C);
+
+  for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
+    (*I)->Destroy(C);
+    
+  Decl::Destroy(C);
+}