зеркало из https://github.com/microsoft/clang.git
Fixup more objc rwriter bug having to do with
rewriting of blocks which have objective-c stuff which need be rewritten as well. // rdar://9254348 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129300 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
09f43ed8a1
Коммит
1d015313b2
|
@ -246,6 +246,10 @@ public:
|
||||||
/// could not be rewritten, or false if successful.
|
/// could not be rewritten, or false if successful.
|
||||||
bool ReplaceStmt(Stmt *From, Stmt *To);
|
bool ReplaceStmt(Stmt *From, Stmt *To);
|
||||||
|
|
||||||
|
/// ConvertToString converts statement 'From' to a string using the
|
||||||
|
/// pretty pronter.
|
||||||
|
std::string ConvertToString(Stmt *From);
|
||||||
|
|
||||||
/// getEditBuffer - This is like getRewriteBufferFor, but always returns a
|
/// getEditBuffer - This is like getRewriteBufferFor, but always returns a
|
||||||
/// buffer, and allows you to write on it directly. This is useful if you
|
/// buffer, and allows you to write on it directly. This is useful if you
|
||||||
/// want efficient low-level access to apis for scribbling on one specific
|
/// want efficient low-level access to apis for scribbling on one specific
|
||||||
|
|
|
@ -5519,27 +5519,34 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
|
||||||
for (Stmt::child_range CI = S->children(); CI; ++CI)
|
for (Stmt::child_range CI = S->children(); CI; ++CI)
|
||||||
if (*CI) {
|
if (*CI) {
|
||||||
Stmt *newStmt;
|
Stmt *newStmt;
|
||||||
Stmt *S = (*CI);
|
Stmt *ChildStmt = (*CI);
|
||||||
if (ObjCIvarRefExpr *IvarRefExpr = dyn_cast<ObjCIvarRefExpr>(S)) {
|
if (ObjCIvarRefExpr *IvarRefExpr = dyn_cast<ObjCIvarRefExpr>(ChildStmt)) {
|
||||||
Expr *OldBase = IvarRefExpr->getBase();
|
Expr *OldBase = IvarRefExpr->getBase();
|
||||||
bool replaced = false;
|
bool replaced = false;
|
||||||
newStmt = RewriteObjCNestedIvarRefExpr(S, replaced);
|
newStmt = RewriteObjCNestedIvarRefExpr(ChildStmt, replaced);
|
||||||
if (replaced) {
|
if (replaced) {
|
||||||
if (ObjCIvarRefExpr *IRE = dyn_cast<ObjCIvarRefExpr>(newStmt))
|
if (ObjCIvarRefExpr *IRE = dyn_cast<ObjCIvarRefExpr>(newStmt))
|
||||||
ReplaceStmt(OldBase, IRE->getBase());
|
ReplaceStmt(OldBase, IRE->getBase());
|
||||||
else
|
else
|
||||||
ReplaceStmt(S, newStmt);
|
ReplaceStmt(ChildStmt, newStmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
newStmt = RewriteFunctionBodyOrGlobalInitializer(S);
|
newStmt = RewriteFunctionBodyOrGlobalInitializer(ChildStmt);
|
||||||
|
if (newStmt) {
|
||||||
|
if (Expr *PropOrImplicitRefExpr = dyn_cast<Expr>(ChildStmt))
|
||||||
|
if (PropSetters[PropOrImplicitRefExpr] == S) {
|
||||||
|
S = newStmt;
|
||||||
|
newStmt = 0;
|
||||||
|
}
|
||||||
if (newStmt)
|
if (newStmt)
|
||||||
*CI = newStmt;
|
*CI = newStmt;
|
||||||
|
}
|
||||||
// If dealing with an assignment with LHS being a property reference
|
// If dealing with an assignment with LHS being a property reference
|
||||||
// expression, the entire assignment tree is rewritten into a property
|
// expression, the entire assignment tree is rewritten into a property
|
||||||
// setter messaging. This involvs the RHS too. Do not attempt to rewrite
|
// setter messaging. This involvs the RHS too. Do not attempt to rewrite
|
||||||
// RHS again.
|
// RHS again.
|
||||||
if (Expr *Exp = dyn_cast<Expr>(S))
|
if (Expr *Exp = dyn_cast<Expr>(ChildStmt))
|
||||||
if (isa<ObjCPropertyRefExpr>(Exp)) {
|
if (isa<ObjCPropertyRefExpr>(Exp)) {
|
||||||
if (PropSetters[Exp]) {
|
if (PropSetters[Exp]) {
|
||||||
++CI;
|
++CI;
|
||||||
|
@ -5565,7 +5572,7 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
|
||||||
PropParentMap = 0;
|
PropParentMap = 0;
|
||||||
ImportedLocalExternalDecls.clear();
|
ImportedLocalExternalDecls.clear();
|
||||||
// Now we snarf the rewritten text and stash it away for later use.
|
// Now we snarf the rewritten text and stash it away for later use.
|
||||||
std::string Str = Rewrite.getRewrittenText(BE->getSourceRange());
|
std::string Str = Rewrite.ConvertToString(BE->getBody());
|
||||||
RewrittenBlockExprs[BE] = Str;
|
RewrittenBlockExprs[BE] = Str;
|
||||||
|
|
||||||
Stmt *blockTranscribed = SynthBlockInitExpr(BE, InnerBlockDeclRefs);
|
Stmt *blockTranscribed = SynthBlockInitExpr(BE, InnerBlockDeclRefs);
|
||||||
|
|
|
@ -303,3 +303,10 @@ bool Rewriter::ReplaceStmt(Stmt *From, Stmt *To) {
|
||||||
ReplaceText(From->getLocStart(), Size, Str);
|
ReplaceText(From->getLocStart(), Size, Str);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Rewriter::ConvertToString(Stmt *From) {
|
||||||
|
std::string SStr;
|
||||||
|
llvm::raw_string_ostream S(SStr);
|
||||||
|
From->printPretty(S, 0, PrintingPolicy(*LangOpts));
|
||||||
|
return SStr;
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,11 @@ typedef void (^BLOCK_TYPE)(void);
|
||||||
@implementation CoreDAVTaskGroup
|
@implementation CoreDAVTaskGroup
|
||||||
- (void)_finishInitialSync {
|
- (void)_finishInitialSync {
|
||||||
CoreDAVTaskGroup *folderPost;
|
CoreDAVTaskGroup *folderPost;
|
||||||
|
folderPost.completionBlock = ^{
|
||||||
|
self.IVAR = 0;
|
||||||
|
[self _finishInitialSync];
|
||||||
|
};
|
||||||
|
|
||||||
[folderPost setCompletionBlock : (^{
|
[folderPost setCompletionBlock : (^{
|
||||||
self.IVAR = 0;
|
self.IVAR = 0;
|
||||||
})];
|
})];
|
||||||
|
|
Загрузка…
Ссылка в новой задаче