diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-03-31 22:49:32 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-03-31 22:49:32 +0000 |
commit | 822ac874ae99f326b59eb340bd47e96f69c0cf3b (patch) | |
tree | ded40deb5b03195922ee50a506514bf1f6a2f608 /lib/Rewrite/RewriteObjC.cpp | |
parent | bc8b44c4ee7f9c4c3ad296369e72feda61bdb580 (diff) |
Fix couple of rewriter bugs related to rewriting a
__block block declaration. //rdar://9204669
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128682 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite/RewriteObjC.cpp')
-rw-r--r-- | lib/Rewrite/RewriteObjC.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index 36ae3953f3..54d6fbb236 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -5142,8 +5142,11 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) { ByrefType += " void (*__Block_byref_id_object_copy)(void*, void*);\n"; ByrefType += " void (*__Block_byref_id_object_dispose)(void*);\n"; } - - Ty.getAsStringInternal(Name, Context->PrintingPolicy); + + QualType T = Ty; + (void)convertBlockPointerToFunctionPointer(T); + T.getAsStringInternal(Name, Context->PrintingPolicy); + ByrefType += " " + Name + ";\n"; ByrefType += "};\n"; // Insert this type in global scope. It is needed by helper function. @@ -5201,7 +5204,12 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) { ByrefType += utostr(flag); } ByrefType += "};\n"; - ReplaceText(DeclLoc, endBuf-startBuf+Name.size(), ByrefType); + unsigned nameSize = Name.size(); + // for block or function pointer declaration. Name is aleady + // part of the declaration. + if (Ty->isBlockPointerType() || Ty->isFunctionPointerType()) + nameSize = 1; + ReplaceText(DeclLoc, endBuf-startBuf+nameSize, ByrefType); } else { SourceLocation startLoc; |