aboutsummaryrefslogtreecommitdiff
path: root/lib/Rewrite/RewriteObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-01-27 23:18:15 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-01-27 23:18:15 +0000
commit1e8011e2fcddc4a638d210ec2dcd21adcf7b1763 (patch)
treede8d2986ec916f1d635b53c1f286dbf1710dcb5b /lib/Rewrite/RewriteObjC.cpp
parent1eee5dc0465c0ab4810e21d365e881152d7f53c0 (diff)
Fix an objective-c rewriter bug rewriting a __block
variable declaration of a struct declared type. // rdar://8918702 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124451 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite/RewriteObjC.cpp')
-rw-r--r--lib/Rewrite/RewriteObjC.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp
index 488ee6044e..659fe74154 100644
--- a/lib/Rewrite/RewriteObjC.cpp
+++ b/lib/Rewrite/RewriteObjC.cpp
@@ -252,7 +252,7 @@ namespace {
void RewriteTypeIntoString(QualType T, std::string &ResultStr,
const FunctionType *&FPRetType);
void RewriteByRefString(std::string &ResultStr, const std::string &Name,
- ValueDecl *VD);
+ ValueDecl *VD, bool def=false);
void RewriteCategoryDecl(ObjCCategoryDecl *Dcl);
void RewriteProtocolDecl(ObjCProtocolDecl *Dcl);
void RewriteForwardProtocolDecl(ObjCForwardProtocolDecl *Dcl);
@@ -4118,10 +4118,12 @@ void RewriteObjC::SynthesizeMetaDataIntoBuffer(std::string &Result) {
void RewriteObjC::RewriteByRefString(std::string &ResultStr,
const std::string &Name,
- ValueDecl *VD) {
+ ValueDecl *VD, bool def) {
assert(BlockByRefDeclNo.count(VD) &&
"RewriteByRefString: ByRef decl missing");
- ResultStr += "struct __Block_byref_" + Name +
+ if (def)
+ ResultStr += "struct ";
+ ResultStr += "__Block_byref_" + Name +
"_" + utostr(BlockByRefDeclNo[VD]) ;
}
@@ -5112,7 +5114,7 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) {
const char *endBuf = SM->getCharacterData(X);
std::string Name(ND->getNameAsString());
std::string ByrefType;
- RewriteByRefString(ByrefType, Name, ND);
+ RewriteByRefString(ByrefType, Name, ND, true);
ByrefType += " {\n";
ByrefType += " void *__isa;\n";
RewriteByRefString(ByrefType, Name, ND);
@@ -5405,7 +5407,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
ValueDecl *ND = (*I);
std::string Name(ND->getNameAsString());
std::string RecName;
- RewriteByRefString(RecName, Name, ND);
+ RewriteByRefString(RecName, Name, ND, true);
IdentifierInfo *II = &Context->Idents.get(RecName.c_str()
+ sizeof("struct"));
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,