[PATCH] Implement CapturedStmt AST

Wei Pan wei.pan at intel.com
Tue Feb 5 12:55:47 PST 2013



================
Comment at: lib/AST/Stmt.cpp:1040-1042
@@ +1039,5 @@
+  // Copy all Capture objects into the context.
+  unsigned Size = NumCaptures * sizeof(Capture);
+  void *buffer = Context.Allocate(Size, llvm::alignOf<Capture *>());
+  memcpy(buffer, begin, Size);
+
----------------
Dmitri Gribenko wrote:
> Please use tail allocation for this.
This was following the implementation of BlockDecl and LambdaExpr. What do you mean tail allocation here?

================
Comment at: lib/AST/Stmt.cpp:1047
@@ +1046,3 @@
+
+bool CapturedStmt::capturesVariable(const VarDecl *variable) const {
+  for (capture_const_iterator I = capture_begin(),
----------------
Dmitri Gribenko wrote:
> First letter of the parameter name should be uppercase: 'Variable'.
Will do.

================
Comment at: lib/AST/StmtPrinter.cpp:452
@@ +451,3 @@
+void StmtPrinter::VisitCapturedStmt(CapturedStmt *Node) {
+  PrintStmt(Node->getSubStmt());
+}
----------------
Dmitri Gribenko wrote:
> Please add tests for this.  AST printer is already broken enough and under-tested, and we should ensure that we don't make the situation worse.
> 
Do you mean adding a test in "unittests/AST/StmtPrinterTest.cpp". We will add a test in our Sema patch.  Thanks!


http://llvm-reviews.chandlerc.com/D370



More information about the cfe-commits mailing list