diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-02-10 20:18:25 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-02-10 20:18:25 +0000 |
commit | e61a1d4c57bbce3dfaa191a4b4de48ad79ac0b83 (patch) | |
tree | 18cd07402d7c8d939ed504e1de15458c3d466c26 /lib/Frontend/RewriteObjC.cpp | |
parent | a404ea673cbee5e74af710a5f1ab571e71580b67 (diff) |
Patch to rewrite blocks into unique api names.
Fixes radar 7630551
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95796 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/RewriteObjC.cpp')
-rw-r--r-- | lib/Frontend/RewriteObjC.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp index 3ee266a110..50a281fbcc 100644 --- a/lib/Frontend/RewriteObjC.cpp +++ b/lib/Frontend/RewriteObjC.cpp @@ -4158,16 +4158,23 @@ void RewriteObjC::InsertBlockLiteralsWithinFunction(FunctionDecl *FD) { SynthesizeBlockLiterals(FunLocStart, FuncName); } +static void BuildUniqueMethodName(std::string &Name, + ObjCMethodDecl *MD) { + ObjCInterfaceDecl *IFace = MD->getClassInterface(); + Name = IFace->getNameAsCString(); + Name += "__" + MD->getSelector().getAsString(); + // Convert colons to underscores. + std::string::size_type loc = 0; + while ((loc = Name.find(":", loc)) != std::string::npos) + Name.replace(loc, 1, "_"); +} + void RewriteObjC::InsertBlockLiteralsWithinMethod(ObjCMethodDecl *MD) { //fprintf(stderr,"In InsertBlockLiteralsWitinMethod\n"); //SourceLocation FunLocStart = MD->getLocStart(); SourceLocation FunLocStart = MD->getLocStart(); - std::string FuncName = MD->getSelector().getAsString(); - // Convert colons to underscores. - std::string::size_type loc = 0; - while ((loc = FuncName.find(":", loc)) != std::string::npos) - FuncName.replace(loc, 1, "_"); - + std::string FuncName; + BuildUniqueMethodName(FuncName, MD); SynthesizeBlockLiterals(FunLocStart, FuncName.c_str()); } @@ -4779,13 +4786,9 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) { if (CurFunctionDef) FuncName = CurFunctionDef->getNameAsString(); - else if (CurMethodDef) { - FuncName = CurMethodDef->getSelector().getAsString(); - // Convert colons to underscores. - std::string::size_type loc = 0; - while ((loc = FuncName.find(":", loc)) != std::string::npos) - FuncName.replace(loc, 1, "_"); - } else if (GlobalVarDecl) + else if (CurMethodDef) + BuildUniqueMethodName(FuncName, CurMethodDef); + else if (GlobalVarDecl) FuncName = std::string(GlobalVarDecl->getNameAsString()); std::string BlockNumber = utostr(Blocks.size()-1); |