Minor cleanup of the rewriter.

llvm-svn: 97280
This commit is contained in:
Fariborz Jahanian 2010-02-26 22:36:30 +00:00
parent a433ee3302
commit be730c9e34
1 changed files with 22 additions and 18 deletions

View File

@ -4955,28 +4955,32 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
// Add inner imported variables now used in current block. // Add inner imported variables now used in current block.
int countOfInnerDecls = 0; int countOfInnerDecls = 0;
for (unsigned i = 0; i < InnerBlockDeclRefs.size(); i++) { if (!InnerBlockDeclRefs.empty()) {
BlockDeclRefExpr *Exp = InnerBlockDeclRefs[i]; for (unsigned i = 0; i < InnerBlockDeclRefs.size(); i++) {
ValueDecl *VD = Exp->getDecl(); BlockDeclRefExpr *Exp = InnerBlockDeclRefs[i];
if (!Exp->isByRef() && !BlockByCopyDeclsPtrSet.count(VD)) { ValueDecl *VD = Exp->getDecl();
if (!Exp->isByRef() && !BlockByCopyDeclsPtrSet.count(VD)) {
// We need to save the copied-in variables in nested // We need to save the copied-in variables in nested
// blocks because it is needed at the end for some of the API generations. // blocks because it is needed at the end for some of the API generations.
// See SynthesizeBlockLiterals routine. // See SynthesizeBlockLiterals routine.
InnerDeclRefs.push_back(Exp); countOfInnerDecls++; InnerDeclRefs.push_back(Exp); countOfInnerDecls++;
BlockDeclRefs.push_back(Exp); BlockDeclRefs.push_back(Exp);
BlockByCopyDeclsPtrSet.insert(VD); BlockByCopyDeclsPtrSet.insert(VD);
BlockByCopyDecls.push_back(VD); BlockByCopyDecls.push_back(VD);
if (Exp->getType()->isObjCObjectPointerType() || }
Exp->getType()->isBlockPointerType()) if (Exp->isByRef() && !BlockByRefDeclsPtrSet.count(VD)) {
ImportedBlockDecls.insert(VD); InnerDeclRefs.push_back(Exp); countOfInnerDecls++;
} BlockDeclRefs.push_back(Exp);
if (Exp->isByRef() && !BlockByRefDeclsPtrSet.count(VD)) { BlockByRefDeclsPtrSet.insert(VD);
InnerDeclRefs.push_back(Exp); countOfInnerDecls++; BlockByRefDecls.push_back(VD);
BlockDeclRefs.push_back(Exp); }
BlockByRefDeclsPtrSet.insert(VD);
BlockByRefDecls.push_back(VD);
ImportedBlockDecls.insert(VD);
} }
// Find any imported blocks...they will need special attention.
for (unsigned i = 0; i < InnerBlockDeclRefs.size(); i++)
if (InnerBlockDeclRefs[i]->isByRef() ||
InnerBlockDeclRefs[i]->getType()->isObjCObjectPointerType() ||
InnerBlockDeclRefs[i]->getType()->isBlockPointerType())
ImportedBlockDecls.insert(InnerBlockDeclRefs[i]->getDecl());
} }
InnerDeclRefsCount.push_back(countOfInnerDecls); InnerDeclRefsCount.push_back(countOfInnerDecls);