diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2012-04-30 19:46:53 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-04-30 19:46:53 +0000 |
| commit | 5979c31ea71f1090b053add036589a6a700afe48 (patch) | |
| tree | b02df8aa8c9ddc1da22a7a17848852064b06c21a | |
| parent | b47610a0738d3448718d244e48218912451afa50 (diff) | |
| download | bcm5719-llvm-5979c31ea71f1090b053add036589a6a700afe48.tar.gz bcm5719-llvm-5979c31ea71f1090b053add036589a6a700afe48.zip | |
minor refactoring of modern objc translator.
llvm-svn: 155843
| -rw-r--r-- | clang/lib/Rewrite/RewriteModernObjC.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/clang/lib/Rewrite/RewriteModernObjC.cpp b/clang/lib/Rewrite/RewriteModernObjC.cpp index d463cb021c3..5cd6836cc35 100644 --- a/clang/lib/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Rewrite/RewriteModernObjC.cpp @@ -3494,6 +3494,22 @@ bool RewriteModernObjC::BufferContainsPPDirectives(const char *startBuf, return false; } +static bool IsTagDefinedInsideClass(ASTContext *Context, + ObjCInterfaceDecl *IDecl, TagDecl *Tag) { + if (!IDecl) + return false; + SourceLocation TagLocation; + if (RecordDecl *RD = dyn_cast<RecordDecl>(Tag)) { + RD = RD->getDefinition(); + if (!RD) + return false; + TagLocation = RD->getLocation(); + return Context->getSourceManager().isBeforeInTranslationUnit( + IDecl->getLocation(), TagLocation); + } + return false; +} + /// RewriteObjCFieldDeclType - This routine rewrites a type into the buffer. /// It handles elaborated types, as well as enum types in the process. bool RewriteModernObjC::RewriteObjCFieldDeclType(QualType &Type, @@ -7248,11 +7264,7 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { if (IvarT->isRecordType()) { RecordDecl *RD = IvarT->getAs<RecordType>()->getDecl(); - RD = RD->getDefinition(); - bool structIsInside = RD && - Context->getSourceManager().isBeforeInTranslationUnit( - iFaceDecl->getDecl()->getLocation(), RD->getLocation()); - if (structIsInside) { + if (IsTagDefinedInsideClass(Context, iFaceDecl->getDecl(), RD)) { // decltype(((Foo_IMPL*)0)->bar) * std::string RecName = iFaceDecl->getDecl()->getName(); RecName += "_IMPL"; |

