void ASTDumper::VisitBlockDecl(BlockDecl *D) {
  for (BlockDecl::param_iterator I = D->param_begin(), E = D->param_end();
       I != E; ++I)
    dumpDecl(*I);

  if (D->isVariadic()) {
    IndentScope Indent(*this);
    OS << "...";
  }

  if (D->capturesCXXThis()) {
    IndentScope Indent(*this);
    OS << "capture this";
  }
  for (BlockDecl::capture_iterator I = D->capture_begin(),
       E = D->capture_end(); I != E; ++I) {
    IndentScope Indent(*this);
    OS << "capture";
    if (I->isByRef())
      OS << " byref";
    if (I->isNested())
      OS << " nested";
    if (I->getVariable()) {
      OS << ' ';
      dumpBareDeclRef(I->getVariable());
    }
    if (I->hasCopyExpr())
      dumpStmt(I->getCopyExpr());
  }

  dumpStmt(D->getBody());
}
示例#2
0
void StmtDumper::VisitBlockExpr(BlockExpr *Node) {
  DumpExpr(Node);

  BlockDecl *block = Node->getBlockDecl();
  OS << " decl=" << block;

  IndentLevel++;
  if (block->capturesCXXThis()) {
    OS << '\n'; Indent(); OS << "(capture this)";
  }
  for (BlockDecl::capture_iterator
         i = block->capture_begin(), e = block->capture_end(); i != e; ++i) {
    OS << '\n';
    Indent();
    OS << "(capture ";
    if (i->isByRef()) OS << "byref ";
    if (i->isNested()) OS << "nested ";
    if (i->getVariable())
      DumpDeclRef(i->getVariable());
    if (i->hasCopyExpr()) DumpSubTree(i->getCopyExpr());
    OS << ")";
  }
  IndentLevel--;

  OS << '\n';
  DumpSubTree(block->getBody());
}